Skip to content

Commit

Permalink
add go to bond before nominate alert
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Sep 11, 2020
1 parent 9102197 commit 0ff3c26
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 74 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
4 changes: 2 additions & 2 deletions lib/common/consts/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ const String cross_chain_transfer_address_laminar =
'5CLaminarAUSDCrossChainTransferxxxxxxxxxxxxxwisu';

/// app versions
const String app_beta_version = 'v1.0.1-beta.1';
const int app_beta_version_code = 1011;
const String app_beta_version = 'v1.0.1-beta.2';
const int app_beta_version_code = 1012;

/// js code versions
const Map<String, int> js_code_version_map = {
Expand Down
48 changes: 21 additions & 27 deletions lib/page-acala/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,27 @@ class _AcalaHomePageState extends State<AcalaHomePage> {

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (index) {
setState(() {
_tabIndex = index;
});
},
children: _buildPages(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _tabIndex,
iconSize: 22.0,
onTap: (index) {
setState(() {
_tabIndex = index;
});
_pageController.animateToPage(
index,
duration: Duration(milliseconds: 500),
curve: Curves.ease,
);
},
type: BottomNavigationBarType.fixed,
items: _navBarItems(_tabIndex),
),
return Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (index) {
setState(() {
_tabIndex = index;
});
},
children: _buildPages(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _tabIndex,
iconSize: 22.0,
onTap: (index) {
setState(() {
_tabIndex = index;
});
_pageController.jumpToPage(index);
},
type: BottomNavigationBarType.fixed,
items: _navBarItems(_tabIndex),
),
);
}
Expand Down
11 changes: 10 additions & 1 deletion lib/page-laminar/laminarEntry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ class LaminarEntry extends StatelessWidget {
child: Observer(
builder: (_) {
if (store.settings.loading) {
return CupertinoActivityIndicator();
return Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.width / 2),
child: Column(
children: [
CupertinoActivityIndicator(),
Text(I18n.of(context).assets['node.connecting']),
],
),
);
}
return ListView(
padding: EdgeInsets.all(16),
Expand Down
48 changes: 21 additions & 27 deletions lib/page/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,27 @@ class _HomePageState extends State<HomePage> {

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (index) {
setState(() {
_tabIndex = index;
});
},
children: _buildPages(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _tabIndex,
iconSize: 22.0,
onTap: (index) {
setState(() {
_tabIndex = index;
});
_pageController.animateToPage(
index,
duration: Duration(milliseconds: 500),
curve: Curves.ease,
);
},
type: BottomNavigationBarType.fixed,
items: _navBarItems(_tabIndex),
),
return Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (index) {
setState(() {
_tabIndex = index;
});
},
children: _buildPages(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _tabIndex,
iconSize: 22.0,
onTap: (index) {
setState(() {
_tabIndex = index;
});
_pageController.jumpToPage(index);
},
type: BottomNavigationBarType.fixed,
items: _navBarItems(_tabIndex),
),
);
}
Expand Down
31 changes: 29 additions & 2 deletions lib/page/staking/validators/overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:polka_wallet/common/components/textTag.dart';
import 'package:polka_wallet/page/account/txConfirmPage.dart';
import 'package:polka_wallet/page/staking/actions/bondPage.dart';
import 'package:polka_wallet/page/staking/validators/nominatePage.dart';
import 'package:polka_wallet/page/staking/validators/validatorDetailPage.dart';
import 'package:polka_wallet/service/substrateApi/api.dart';
Expand Down Expand Up @@ -62,6 +63,32 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
}
}

void _goToBond() {
var dic = I18n.of(context).staking;
showCupertinoDialog(
context: context,
builder: (_) {
return CupertinoAlertDialog(
title: Text(dic['action.nominate']),
content: Text(dic['action.nominate.bond']),
actions: <Widget>[
CupertinoButton(
child: Text(I18n.of(context).home['cancel']),
onPressed: () => Navigator.of(context).pop(),
),
CupertinoButton(
child: Text(I18n.of(context).home['ok']),
onPressed: () {
Navigator.of(context).pop();
Navigator.pushNamed(context, BondPage.route);
},
),
],
);
},
);
}

void _onSetPayee() {
var dic = I18n.of(context).staking;
showCupertinoModalPopup(
Expand Down Expand Up @@ -168,7 +195,7 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
subtitle: Text(dic['nominating']),
trailing: Container(
width: 100,
child: isController && bonded > 0
child: isController
? GestureDetector(
child: Column(
children: <Widget>[
Expand All @@ -184,7 +211,7 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
)
],
),
onTap: _onSetPayee,
onTap: bonded > 0 ? _onSetPayee : _goToBond,
)
: Column(
children: <Widget>[
Expand Down
6 changes: 3 additions & 3 deletions lib/service/substrateApi/apiStaking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ApiStaking {
Future<void> fetchAccountStaking() async {
final String pubKey = store.account.currentAccountPubKey;
if (pubKey != null && pubKey.isNotEmpty) {
queryOwnStashInfo();
queryOwnStashInfo(pubKey);
}
}

Expand Down Expand Up @@ -116,11 +116,11 @@ class ApiStaking {
return data;
}

Future<Map> queryOwnStashInfo() async {
Future<Map> queryOwnStashInfo(String pubKey) async {
final accountId = store.account.currentAddress;
Map data =
await apiRoot.evalJavascript('staking.getOwnStashInfo("$accountId")');
store.staking.setOwnStashInfo(data);
store.staking.setOwnStashInfo(pubKey, data);

final List<String> addressesNeedIcons =
store.staking.ownStashInfo.nominating != null
Expand Down
7 changes: 5 additions & 2 deletions lib/store/staking/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ abstract class _StakingStore with Store {
}

@action
void setOwnStashInfo(Map<String, dynamic> data, {bool shouldCache = true}) {
void setOwnStashInfo(String pubKey, Map<String, dynamic> data,
{bool shouldCache = true}) {
if (rootStore.account.currentAccount.pubKey != pubKey) return;

ownStashInfo = OwnStashInfoData.fromJson(data);

if (shouldCache) {
Expand All @@ -236,9 +239,9 @@ abstract class _StakingStore with Store {

@action
Future<void> addTxs(Map res, {bool shouldCache = false}) async {
if (res == null || res['extrinsics'] == null) return;
txsCount = res['count'];

if (res['extrinsics'] == null) return;
List<TxData> ls =
List.of(res['extrinsics']).map((i) => TxData.fromJson(i)).toList();

Expand Down
5 changes: 3 additions & 2 deletions lib/store/staking/staking.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions lib/store/staking/types/ownStashInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ abstract class _OwnStashInfoData {
Map<String, dynamic> validatorPrefs;
NomineesInfoData inactives;
Map<String, dynamic> unbondings;

}

@JsonSerializable()
Expand Down Expand Up @@ -55,7 +54,6 @@ abstract class _LedgerInfoData {
String controllerId;
String stashId;
Map<String, dynamic> exposure;
String rewardDestination;
Map<String, dynamic> stakingLedger;
Map<String, dynamic> validatorPrefs;
dynamic redeemable;
Expand Down
2 changes: 0 additions & 2 deletions lib/store/staking/types/ownStashInfo.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/utils/i18n/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const Map<String, String> enStaking = {
'action.redeem': 'Redeem Unbonded',
'action.payout': 'Payout',
'action.nominate': 'Nominate',
'action.nominate.bond':
'You need to bond Tokens before nominating. Go to bonding now?',
'action.nominee': 'Set Nominees',
'action.chill': 'Stop Nominating',
'action.reward': 'Reward Type',
Expand Down Expand Up @@ -107,6 +109,7 @@ const Map<String, String> zhStaking = {
'action.redeem': '解绑取回',
'action.payout': '领取收益',
'action.nominate': '提名',
'action.nominate.bond': '您需要在提名前进行 Token 质押绑定,现在去绑定吗?',
'action.nominee': '设置提名人',
'action.chill': '停止提名',
'action.reward': '分红方式',
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.1+1011
version: 1.0.1+1012

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

0 comments on commit 0ff3c26

Please sign in to comment.