Skip to content

Commit

Permalink
fix setNominees role
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Sep 11, 2020
1 parent 0ff3c26 commit 5a6b0eb
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 36 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 = 2;
CURRENT_PROJECT_VERSION = 3;
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 = 2;
CURRENT_PROJECT_VERSION = 3;
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 = 2;
CURRENT_PROJECT_VERSION = 3;
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.2';
const int app_beta_version_code = 1012;
const String app_beta_version = 'v1.0.1-beta.3';
const int app_beta_version_code = 1013;

/// js code versions
const Map<String, int> js_code_version_map = {
Expand Down
7 changes: 1 addition & 6 deletions lib/page/staking/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,7 @@ class _StakingActions extends State<StakingActions>
child: !hasData
? Container(
padding: EdgeInsets.only(top: 80, bottom: 80),
child: Column(
children: [
CupertinoActivityIndicator(),
Text(I18n.of(context).assets['node.connecting']),
],
),
child: CupertinoActivityIndicator(),
)
: Column(
children: <Widget>[
Expand Down
68 changes: 46 additions & 22 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/bondExtraPage.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';
Expand Down Expand Up @@ -63,7 +64,9 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
}
}

void _goToBond() {
void _goToBond({bondExtra = false}) {
if (store.staking.ownStashInfo == null) return;

var dic = I18n.of(context).staking;
showCupertinoDialog(
context: context,
Expand All @@ -80,7 +83,8 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
child: Text(I18n.of(context).home['ok']),
onPressed: () {
Navigator.of(context).pop();
Navigator.pushNamed(context, BondPage.route);
Navigator.pushNamed(
context, bondExtra ? BondExtraPage.route : BondPage.route);
},
),
],
Expand All @@ -90,6 +94,8 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
}

void _onSetPayee() {
if (store.staking.ownStashInfo == null) return;

var dic = I18n.of(context).staking;
showCupertinoModalPopup(
context: context,
Expand Down Expand Up @@ -146,20 +152,20 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
bool hashData = store.staking.ownStashInfo != null &&
store.staking.ownStashInfo.stakingLedger != null;

String controllerId = store.account.currentAddress;
int bonded = 0;
List nominators = [];
double nominatorListHeight = 48;
bool isController = false;
if (hashData) {
controllerId = store.staking.ownStashInfo.controllerId;
bonded = store.staking.ownStashInfo.stakingLedger['active'];
nominators = store.staking.ownStashInfo.nominating.toList();
if (nominators.length > 0) {
nominatorListHeight = double.parse((nominators.length * 56).toString());
}
isController = store.staking.ownStashInfo.isOwnController;
}
bool isController =
store.staking.ownStashInfo?.account?.accountId == controllerId;
final isStash = store.staking.ownStashInfo?.stashId ==
store.staking.ownStashInfo?.account?.accountId;

Color actionButtonColor = Theme.of(context).primaryColor;
Color disabledColor = Theme.of(context).disabledColor;
Expand Down Expand Up @@ -195,7 +201,7 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
subtitle: Text(dic['nominating']),
trailing: Container(
width: 100,
child: isController
child: store.staking.ownStashInfo?.controllerId == null && isStash
? GestureDetector(
child: Column(
children: <Widget>[
Expand All @@ -204,27 +210,45 @@ class _StakingOverviewPageState extends State<StakingOverviewPage>
color: actionButtonColor,
),
Text(
dic[nominators.length > 0
? 'action.nominee'
: 'action.nominate'],
dic['action.nominate'],
style: TextStyle(color: actionButtonColor),
)
],
),
onTap: bonded > 0 ? _onSetPayee : _goToBond,
onTap: _goToBond,
)
: Column(
children: <Widget>[
OutlinedCircle(
icon: Icons.add,
color: disabledColor,
),
Text(
dic['action.nominate'],
style: TextStyle(color: disabledColor),
: isStash && !isController
? Column(
children: <Widget>[
OutlinedCircle(
icon: Icons.add,
color: disabledColor,
),
Text(
dic['action.nominate'],
style: TextStyle(color: disabledColor),
)
],
)
],
),
: GestureDetector(
child: Column(
children: <Widget>[
OutlinedCircle(
icon: Icons.add,
color: actionButtonColor,
),
Text(
dic[nominators.length > 0
? 'action.nominee'
: 'action.nominate'],
style: TextStyle(color: actionButtonColor),
)
],
),
onTap: bonded > 0
? _onSetPayee
: () => _goToBond(bondExtra: true),
),
),
),
AnimatedContainer(
Expand Down
2 changes: 1 addition & 1 deletion lib/service/substrateApi/apiStaking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ApiStaking {
store.staking.setOwnStashInfo(pubKey, data);

final List<String> addressesNeedIcons =
store.staking.ownStashInfo.nominating != null
store.staking.ownStashInfo?.nominating != null
? store.staking.ownStashInfo.nominating.toList()
: [];
final List<String> addressesNeedDecode = [];
Expand Down
4 changes: 3 additions & 1 deletion lib/store/staking/staking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ abstract class _StakingStore with Store {
List<ValidatorData> ls = List<ValidatorData>();

data['info'].forEach((i) {
i['points'] = overview['eraPoints']['individual'][i['accountId']];
i['points'] = overview['eraPoints'] != null
? overview['eraPoints']['individual'][i['accountId']]
: 0;
ValidatorData data = ValidatorData.fromJson(i);
totalStaked += data.total;
data.nominators.forEach((n) {
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+1012
version: 1.0.1+1013

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

0 comments on commit 5a6b0eb

Please sign in to comment.