Skip to content

Commit

Permalink
update balance toggle logic
Browse files Browse the repository at this point in the history
see #904
  • Loading branch information
sneurlax committed Aug 26, 2024
1 parent 2145334 commit 90aaf5d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ class WalletSummaryInfo extends ConsumerWidget {
final Amount balanceToShow;
final String title;

final bool toggleBalance;
final bool useSimpleToggle;
final bool hasMultipleBalances;

if (coin is Firo) {
toggleBalance = false;
useSimpleToggle = false;
hasMultipleBalances = true; // Firo always has multiple balance types.
final type = ref.watch(publicPrivateBalanceStateProvider.state).state;
title =
"${_showAvailable ? "Available" : "Full"} ${type.name.capitalize()} balance";
Expand All @@ -111,7 +113,9 @@ class WalletSummaryInfo extends ConsumerWidget {
break;
}
} else {
toggleBalance = true;
useSimpleToggle = true;
// Update hasMultipleBalances based on if all of the balances are equal.
hasMultipleBalances = balance.spendable != balance.total;
balanceToShow = _showAvailable ? balance.spendable : balance.total;
title = _showAvailable ? "Available balance" : "Full balance";
}
Expand Down Expand Up @@ -144,7 +148,7 @@ class WalletSummaryInfo extends ConsumerWidget {
children: [
GestureDetector(
onTap: () {
if (toggleBalance) {
if (useSimpleToggle) {
if (ref.read(walletBalanceToggleStateProvider) ==
WalletBalanceToggleState.available) {
ref
Expand All @@ -169,7 +173,7 @@ class WalletSummaryInfo extends ConsumerWidget {
.textFavoriteCard,
),
),
if (!toggleBalance) ...[
if (hasMultipleBalances) ...[
const SizedBox(
width: 4,
),
Expand Down

0 comments on commit 90aaf5d

Please sign in to comment.