Skip to content

Commit

Permalink
Minor syntax change to fix compiler warning. Added new method MockUpg…
Browse files Browse the repository at this point in the history
…raderOS.currentTypeFormatted to return the OS type pretty formatted.
  • Loading branch information
larryaasen committed Dec 7, 2024
1 parent f2a0b29 commit 1554281
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
flutter-version: ['3.24.0', '3.24.5']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ${{ matrix.runs-on-name }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 11.3.1

- Minor syntax change to fix compiler warning.
- Added new method MockUpgraderOS.currentTypeFormatted to return the OS type pretty formatted.

## 11.3.0

- [429] Improved the Hindi ('hi') translations. (thanks to @aruhant)
Expand Down
2 changes: 0 additions & 2 deletions lib/src/upgrade_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class UpgraderMessages {
return releaseNotes;
case UpgraderMessage.title:
return title;
default:
}
return null;
}

/// Determine the current language code, either from the context, or
Expand Down
13 changes: 13 additions & 0 deletions lib/src/upgrade_os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ class UpgraderOS {
}
}

/// Get the current OS type formatted, such as 'Android', 'iOS', etc.
String get currentTypeFormatted {
return switch (currentOSType) {
UpgraderOSType.android => 'Android',
UpgraderOSType.fuchsia => 'Fuchsia',
UpgraderOSType.ios => 'iOS',
UpgraderOSType.linux => 'Linux',
UpgraderOSType.macos => 'macOS',
UpgraderOSType.web => 'Web',
UpgraderOSType.windows => 'Windows',
};
}

@override
String toString() {
return 'operatingSystem: $operatingSystem, version: $operatingSystemVersion';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: upgrader
description: Flutter package for prompting users to upgrade when there is a newer version of the app in the store.
version: 11.3.0
version: 11.3.1
homepage: https://github.com/larryaasen/upgrader

environment:
Expand Down
11 changes: 11 additions & 0 deletions test/upgrader_os_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ void main() {
expect(MockUpgraderOS(windows: true).current, 'windows');
});

test('MockUpgraderOS currentTypeFormatted', () async {
expect(MockUpgraderOS().currentTypeFormatted, 'Android');
expect(MockUpgraderOS(android: true).currentTypeFormatted, 'Android');
expect(MockUpgraderOS(fuchsia: true).currentTypeFormatted, 'Fuchsia');
expect(MockUpgraderOS(ios: true).currentTypeFormatted, 'iOS');
expect(MockUpgraderOS(linux: true).currentTypeFormatted, 'Linux');
expect(MockUpgraderOS(macos: true).currentTypeFormatted, 'macOS');
expect(MockUpgraderOS(web: true).currentTypeFormatted, 'Web');
expect(MockUpgraderOS(windows: true).currentTypeFormatted, 'Windows');
});

test('MockUpgraderOS currentOSType', () async {
expect(MockUpgraderOS().currentOSType, UpgraderOSType.android);
expect(
Expand Down

0 comments on commit 1554281

Please sign in to comment.