CWA-168 | added defining app current version with PackageInfo in settings store

Oleksandr Sobol committed Feb 3, 2020 at 17:23 UTC 6ee4ddda0910b9bda57d2f1a93569f4211e3cd73
3 files changed +24 -3
lib/src/stores/settings/settings_store.dart
+16 -3
@@ -12,6 +12,7 @@ import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart
12 import 'package:cake_wallet/src/screens/settings/items/item_headers.dart';
13 import 'package:cake_wallet/generated/i18n.dart';
14 import 'package:cake_wallet/src/domain/common/default_settings_migration.dart';
15 +import 'package:package_info/package_info.dart';
16
17 part 'settings_store.g.dart';
18
@@ -47,7 +48,19 @@ abstract class SettingsStoreBase with Store {
48 serializeActionlistDisplayModes(actionlistDisplayMode)),
49 fireImmediately: false);
50
50 - currentVersion = _sharedPreferences.getInt('current_default_settings_migration_version');
51 + PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
52 + final version = packageInfo.version;
53 + final buildNumber = packageInfo.buildNumber;
54 + final List<String> versionList = version.split(RegExp("\\."));
55 + currentVersion = "";
56 +
57 + for (int i = 0; i < versionList.length - 1; i++) {
58 + currentVersion += versionList[ i ] + ".";
59 + }
60 +
61 + currentVersion += buildNumber;
62 + });
63 +
64 }
65
66 static const currentNodeIdKey = 'current_node_id';
@@ -145,7 +158,7 @@ abstract class SettingsStoreBase with Store {
158
159 SharedPreferences _sharedPreferences;
160 Box<Node> _nodes;
148 - int currentVersion;
161 + String currentVersion;
162
163 @action
164 Future setAllowBiometricalAuthentication(
@@ -268,7 +281,7 @@ abstract class SettingsStoreBase with Store {
281 ItemHeaders.support: S.current.settings_support,
282 ItemHeaders.termsAndConditions: S.current.settings_terms_and_conditions,
283 ItemHeaders.faq: S.current.faq,
271 - ItemHeaders.version: 'Version 1.0.$currentVersion'
284 + ItemHeaders.version: 'Version $currentVersion'
285 });
286 }
287
pubspec.lock
+7
@@ -469,6 +469,13 @@ packages:
469 url: "https://pub.dartlang.org"
470 source: hosted
471 version: "1.1.0"
472 + package_info:
473 + dependency: "direct main"
474 + description:
475 + name: package_info
476 + url: "https://pub.dartlang.org"
477 + source: hosted
478 + version: "0.4.0+13"
479 package_resolver:
480 dependency: transitive
481 description:
pubspec.yaml
+1
@@ -45,6 +45,7 @@ dependencies:
45 path: ./cw_monero
46 hive: ^1.2.0
47 hive_flutter: ^0.2.1
48 + package_info: ^0.4.0+13
49
50 # The following adds the Cupertino Icons font to your application.
51 # Use with the CupertinoIcons class for iOS style icons.