Skip to content

Commit

Permalink
Add refresh GETH balance button if error state
Browse files Browse the repository at this point in the history
  • Loading branch information
simonesestito committed Jan 10, 2024
1 parent 8c6d5df commit 92a21b6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,6 @@
}
}
},
"etherscanLinkLabel": "View on Etherscan"
"etherscanLinkLabel": "View on Etherscan",
"refreshButtonLabel": "Refresh"
}
2 changes: 2 additions & 0 deletions lib/bloc/balance/balance_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class BalanceBloc extends Bloc<BalanceEvent, BalanceState> {
});
}

void refresh() => add(const LoadBalanceEvent());

FutureOr<void> _onLoadBalanceEvent(
LoadBalanceEvent event,
Emitter<BalanceState> emit,
Expand Down
21 changes: 17 additions & 4 deletions lib/widget/geth_balance_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GethBalanceTile extends StatelessWidget {

@override
Widget build(BuildContext context) => BlocBuilder<BalanceBloc, BalanceState>(
builder: (context, state) => switch (state) {
builder: (context, state) => switch (state) {
LoadingBalanceState() => const CircularProgressIndicator(),
BalanceStateData balanceState => ListTile(
title: Text(AppLocalizations.of(context)!.userTokenBalanceMessage(
Expand All @@ -36,9 +36,22 @@ class GethBalanceTile extends StatelessWidget {
],
),
),
UnavailableBalanceState() => Text(
AppLocalizations.of(context)!.userTokenBalanceUnavailable,
),
UnavailableBalanceState() => Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
AppLocalizations.of(context)!.userTokenBalanceUnavailable,
),
TextButton(
onPressed: () {
context.read<BalanceBloc>().refresh();
},
child: Text(
AppLocalizations.of(context)!.refreshButtonLabel,
),
),
],
)
},
);

Expand Down

0 comments on commit 92a21b6

Please sign in to comment.