From 6ee4ddda0910b9bda57d2f1a93569f4211e3cd73 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Mon, 3 Feb 2020 17:23:31 +0200 Subject: [PATCH] CWA-168 | added defining app current version with PackageInfo in settings store --- lib/src/stores/settings/settings_store.dart | 19 ++++++++++++++++--- pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/src/stores/settings/settings_store.dart b/lib/src/stores/settings/settings_store.dart index b9a78d24f..32ab0f9a2 100644 --- a/lib/src/stores/settings/settings_store.dart +++ b/lib/src/stores/settings/settings_store.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/src/stores/action_list/action_list_display_mode.dart import 'package:cake_wallet/src/screens/settings/items/item_headers.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/domain/common/default_settings_migration.dart'; +import 'package:package_info/package_info.dart'; part 'settings_store.g.dart'; @@ -47,7 +48,19 @@ abstract class SettingsStoreBase with Store { serializeActionlistDisplayModes(actionlistDisplayMode)), fireImmediately: false); - currentVersion = _sharedPreferences.getInt('current_default_settings_migration_version'); + PackageInfo.fromPlatform().then((PackageInfo packageInfo) { + final version = packageInfo.version; + final buildNumber = packageInfo.buildNumber; + final List versionList = version.split(RegExp("\\.")); + currentVersion = ""; + + for (int i = 0; i < versionList.length - 1; i++) { + currentVersion += versionList[ i ] + "."; + } + + currentVersion += buildNumber; + }); + } static const currentNodeIdKey = 'current_node_id'; @@ -145,7 +158,7 @@ abstract class SettingsStoreBase with Store { SharedPreferences _sharedPreferences; Box _nodes; - int currentVersion; + String currentVersion; @action Future setAllowBiometricalAuthentication( @@ -268,7 +281,7 @@ abstract class SettingsStoreBase with Store { ItemHeaders.support: S.current.settings_support, ItemHeaders.termsAndConditions: S.current.settings_terms_and_conditions, ItemHeaders.faq: S.current.faq, - ItemHeaders.version: 'Version 1.0.$currentVersion' + ItemHeaders.version: 'Version $currentVersion' }); } diff --git a/pubspec.lock b/pubspec.lock index a8b5c8ba7..d4adb3dbb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -469,6 +469,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + package_info: + dependency: "direct main" + description: + name: package_info + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0+13" package_resolver: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 306c34298..e20521171 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,6 +45,7 @@ dependencies: path: ./cw_monero hive: ^1.2.0 hive_flutter: ^0.2.1 + package_info: ^0.4.0+13 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.