Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update balance toggle logic #971

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading