Skip to content

Commit 00a8928

Browse files
authored
fix: (balance) 🐛 fixed multiple balance load bug (#217)
1 parent ad388d8 commit 00a8928

File tree

5 files changed

+62
-28
lines changed

5 files changed

+62
-28
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ install:
2525

2626
fix-lint:
2727
$(info Running flutter format)
28-
fvm flutter format --line-length 120 --set-exit-if-changed lib test
28+
fvm flutter format --line-length 120 --set-exit-if-changed starport_template/lib starport_template/test
29+

starport_template/lib/pages/assets_portfolio_page.dart

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import 'package:starport_template/widgets/starport_button_bar.dart';
1818
import 'package:transaction_signing_gateway/model/wallet_public_info.dart';
1919

2020
class AssetsPortfolioPage extends StatefulWidget {
21-
const AssetsPortfolioPage({Key? key}) : super(key: key);
21+
const AssetsPortfolioPage({
22+
Key? key,
23+
}) : super(key: key);
2224

2325
@override
2426
State<AssetsPortfolioPage> createState() => _AssetsPortfolioPageState();
@@ -35,12 +37,6 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
3537

3638
WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet;
3739

38-
@override
39-
void initState() {
40-
super.initState();
41-
_fetchWalletBalances();
42-
}
43-
4440
@override
4541
Widget build(BuildContext context) {
4642
return Scaffold(
@@ -54,7 +50,10 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
5450
Column(
5551
children: [
5652
_gradientAvatar(context),
57-
AssetPortfolioHeading(title: selectedWallet.name, onTap: _onTapDropDown),
53+
AssetPortfolioHeading(
54+
title: selectedWallet.name,
55+
onTap: _onTapDropDown,
56+
),
5857
SizedBox(height: CosmosTheme.of(context).spacingXL),
5958
const Divider(),
6059
SizedBox(height: CosmosTheme.of(context).spacingL),
@@ -65,8 +64,11 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
6564
StarportButtonBar(
6665
onReceivePressed: _onTapReceive,
6766
onSendPressed: () {
68-
Navigator.of(context)
69-
.push(MaterialPageRoute(builder: (context) => SelectAssetPage(balancesList: balancesList)));
67+
Navigator.of(context).push(
68+
MaterialPageRoute(
69+
builder: (context) => SelectAssetPage(balancesList: balancesList),
70+
),
71+
);
7072
},
7173
),
7274
],
@@ -97,12 +99,9 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
9799
);
98100
}
99101

100-
void _onTapAvatar(BuildContext context) =>
101-
Navigator.of(context).push(MaterialPageRoute(builder: (context) => const TransactionHistoryPage()));
102-
103-
Future _fetchWalletBalances() async {
104-
await StarportApp.walletsStore.getBalances(selectedWallet.publicAddress);
105-
}
102+
void _onTapAvatar(BuildContext context) => Navigator.of(context).push(
103+
MaterialPageRoute(builder: (context) => const TransactionHistoryPage()),
104+
);
106105

107106
Future<void> _onTapDropDown() async {
108107
final wallet = await showMaterialModalBottomSheet(
@@ -125,7 +124,9 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
125124
backgroundColor: Colors.transparent,
126125
builder: (context) => SizedBox(
127126
height: MediaQuery.of(context).size.height / 1.06,
128-
child: ReceiveMoneySheet(walletInfo: StarportApp.walletsStore.selectedWallet),
127+
child: ReceiveMoneySheet(
128+
walletInfo: StarportApp.walletsStore.selectedWallet,
129+
),
129130
),
130131
);
131132
}
@@ -134,7 +135,12 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
134135
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
135136
super.debugFillProperties(properties);
136137
properties
137-
..add(DiagnosticsProperty<WalletPublicInfo>('selectedWallet', selectedWallet))
138+
..add(
139+
DiagnosticsProperty<WalletPublicInfo>(
140+
'selectedWallet',
141+
selectedWallet,
142+
),
143+
)
138144
..add(DiagnosticsProperty<bool>('isBalancesLoading', isBalancesLoading))
139145
..add(DiagnosticsProperty<bool>('isSendMoneyLoading', isSendMoneyLoading))
140146
..add(IterableProperty<Balance>('balancesList', balancesList))

starport_template/lib/pages/create_wallet_page.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
174174
);
175175
if (mounted) {
176176
await Navigator.of(context).pushAndRemoveUntil(
177-
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
177+
MaterialPageRoute(
178+
builder: (_) => const AssetsPortfolioPage(),
179+
),
178180
(route) => false,
179181
);
180182
}

starport_template/lib/pages/import_wallet_page.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ class _ImportWalletPageState extends State<ImportWalletPage> {
124124
_showImportErrorDialog();
125125
} else if (mounted) {
126126
await Navigator.of(context).pushAndRemoveUntil(
127-
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
127+
MaterialPageRoute(
128+
builder: (_) => const AssetsPortfolioPage(),
129+
),
128130
(route) => false,
129131
);
130132
}

starport_template/lib/pages/sign_transaction_page.dart

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:starport_template/pages/assets_transfer_sheet.dart';
1212
import 'package:starport_template/pages/passcode_prompt_page.dart';
1313
import 'package:starport_template/starport_app.dart';
1414
import 'package:starport_template/widgets/sign_transaction_tab_view_item.dart';
15+
import 'package:transaction_signing_gateway/transaction_signing_gateway.dart';
1516

1617
class SignTransactionPage extends StatefulWidget {
1718
const SignTransactionPage({
@@ -31,13 +32,17 @@ class SignTransactionPage extends StatefulWidget {
3132
super.debugFillProperties(properties);
3233
properties
3334
..add(DiagnosticsProperty<Balance>('balance', balance))
34-
..add(DiagnosticsProperty<MsgSendTransaction>('transaction', transaction));
35+
..add(
36+
DiagnosticsProperty<MsgSendTransaction>('transaction', transaction),
37+
);
3538
}
3639
}
3740

3841
class _SignTransactionPageState extends State<SignTransactionPage> {
3942
double get recipientGetsAmount => widget.transaction.amount.value.toDouble() - widget.transaction.fee;
4043

44+
WalletPublicInfo get selectedWallet => StarportApp.walletsStore.selectedWallet;
45+
4146
@override
4247
Widget build(BuildContext context) {
4348
final theme = CosmosTheme.of(context);
@@ -123,13 +128,23 @@ class _SignTransactionPageState extends State<SignTransactionPage> {
123128
builder: (context) => SizedBox(
124129
height: MediaQuery.of(context).size.height / 2.24,
125130
child: AssetsTransferSheet(
126-
onTapDone: () => Navigator.of(context).pushAndRemoveUntil(
127-
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
128-
(route) => false,
129-
),
131+
onTapDone: () => _onTapAssetTranserSheetDone(context),
132+
),
133+
),
134+
);
135+
}
136+
137+
Future<void> _onTapAssetTranserSheetDone(BuildContext context) async {
138+
unawaited(
139+
Navigator.of(context).pushAndRemoveUntil(
140+
MaterialPageRoute(
141+
builder: (_) => const AssetsPortfolioPage(),
130142
),
143+
(route) => false,
131144
),
132145
);
146+
147+
await StarportApp.walletsStore.getBalances(selectedWallet.publicAddress);
133148
}
134149

135150
Padding _transactionFee(CosmosThemeData theme) {
@@ -152,8 +167,16 @@ class _SignTransactionPageState extends State<SignTransactionPage> {
152167
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
153168
super.debugFillProperties(properties);
154169
properties
155-
..add(DiagnosticsProperty<MsgSendTransaction>('transaction', widget.transaction))
170+
..add(
171+
DiagnosticsProperty<MsgSendTransaction>(
172+
'transaction',
173+
widget.transaction,
174+
),
175+
)
156176
..add(DoubleProperty('recipientGetsAmount', recipientGetsAmount))
157-
..add(DiagnosticsProperty<Balance>('balance', widget.balance));
177+
..add(DiagnosticsProperty<Balance>('balance', widget.balance))
178+
..add(
179+
DiagnosticsProperty<WalletPublicInfo>('selectedWallet', selectedWallet),
180+
);
158181
}
159182
}

0 commit comments

Comments
 (0)