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

This commit is contained in:
Oleksandr Sobol 2020-02-03 17:23:31 +02:00
parent 9355b2a1f4
commit 6ee4ddda09
3 changed files with 24 additions and 3 deletions

View file

@ -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<String> 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<Node> _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'
});
}

View file

@ -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:

View file

@ -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.