Skip to content

Commit

Permalink
add api version in about page
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Oct 15, 2020
1 parent d1987ad commit 5072a04
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -518,7 +518,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -548,7 +548,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class _WalletAppState extends State<WalletApp> {
RemoteNodeListPage(_appStore.settings),
SS58PrefixListPage.route: (_) =>
SS58PrefixListPage(_appStore.settings),
AboutPage.route: (_) => AboutPage(),
AboutPage.route: (_) => AboutPage(_appStore),
RecoverySettingPage.route: (_) => RecoverySettingPage(_appStore),
RecoveryStatePage.route: (_) => RecoveryStatePage(_appStore),
RecoveryProofPage.route: (_) => RecoveryProofPage(_appStore),
Expand Down
4 changes: 2 additions & 2 deletions lib/common/consts/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ const String cross_chain_transfer_address_laminar =
'5CLaminarAUSDCrossChainTransferxxxxxxxxxxxxxwisu';

/// app versions
const String app_beta_version = 'v1.0.5-beta.1';
const int app_beta_version_code = 1051;
const String app_beta_version = 'v1.0.5-beta.2';
const int app_beta_version_code = 1052;

/// js code versions
const Map<String, int> js_code_version_map = {
Expand Down
14 changes: 14 additions & 0 deletions lib/page/profile/aboutPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import 'package:flutter/material.dart';
import 'package:polka_wallet/common/components/JumpToBrowserLink.dart';
import 'package:polka_wallet/common/components/roundedButton.dart';
import 'package:polka_wallet/common/consts/settings.dart';
import 'package:polka_wallet/service/substrateApi/api.dart';
import 'package:polka_wallet/service/walletApi.dart';
import 'package:polka_wallet/store/app.dart';
import 'package:polka_wallet/utils/UI.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

class AboutPage extends StatefulWidget {
AboutPage(this.store);

final AppStore store;

static final String route = '/profile/about';

@override
Expand All @@ -31,6 +37,10 @@ class _AboutPage extends State<AboutPage> {
@override
Widget build(BuildContext context) {
final Map dic = I18n.of(context).profile;
final currentJSVersion = WalletApi.getPolkadotJSVersion(
webApi.jsStorage,
widget.store.settings.endpoint.info,
);
return Scaffold(
backgroundColor: Theme.of(context).cardColor,
appBar: AppBar(
Expand Down Expand Up @@ -64,6 +74,10 @@ class _AboutPage extends State<AboutPage> {
padding: EdgeInsets.all(8),
child: Text('${dic['about.version']}: $app_beta_version'),
),
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text('API: $currentJSVersion'),
),
Padding(
padding: EdgeInsets.all(16),
child: RoundedButton(
Expand Down
2 changes: 2 additions & 0 deletions lib/service/substrateApi/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Api {
// check js code update
final network = store.settings.endpoint.info;
final jsVersions = await WalletApi.fetchPolkadotJSVersion();
if (jsVersions == null) return;

final version = jsVersions[network];
final versionMin = jsVersions['$network-min'];
final bool needUpdate =
Expand Down
9 changes: 6 additions & 3 deletions lib/service/walletApi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ class WalletApi {
GetStorage jsStorage,
String networkName,
) {
String version = jsStorage.read('$_jsCodeStorageVersionKey$networkName');
final int appJSVersion = js_code_version_map[networkName];
final String version =
jsStorage.read('$_jsCodeStorageVersionKey$networkName');
if (version != null) {
return int.parse(version);
final updatedVersion = int.parse(version);
return updatedVersion > appJSVersion ? updatedVersion : appJSVersion;
}
// default version
return js_code_version_map[networkName];
return appJSVersion;
}

static String getPolkadotJSCode(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: PolkaWallet made with Flutter.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.5+1051
version: 1.0.5+1052

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit 5072a04

Please sign in to comment.