Merge pull request #904 from cypherstack/togglebalance

Quick toggle balances as appropriate
This commit is contained in:
julian-CStack 2024-07-29 12:16:09 -06:00 committed by GitHub
commit b1a303ffdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,14 +81,16 @@ class WalletSummaryInfo extends ConsumerWidget {
priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin)), priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin)),
); );
final _showAvailable = final _showAvailable = ref.watch(walletBalanceToggleStateProvider) ==
ref.watch(walletBalanceToggleStateProvider.state).state ==
WalletBalanceToggleState.available; WalletBalanceToggleState.available;
final Amount balanceToShow; final Amount balanceToShow;
final String title; final String title;
final bool toggleBalance;
if (coin is Firo) { if (coin is Firo) {
toggleBalance = false;
final type = ref.watch(publicPrivateBalanceStateProvider.state).state; final type = ref.watch(publicPrivateBalanceStateProvider.state).state;
title = title =
"${_showAvailable ? "Available" : "Full"} ${type.name.capitalize()} balance"; "${_showAvailable ? "Available" : "Full"} ${type.name.capitalize()} balance";
@ -109,6 +111,7 @@ class WalletSummaryInfo extends ConsumerWidget {
break; break;
} }
} else { } else {
toggleBalance = true;
balanceToShow = _showAvailable ? balance.spendable : balance.total; balanceToShow = _showAvailable ? balance.spendable : balance.total;
title = _showAvailable ? "Available balance" : "Full balance"; title = _showAvailable ? "Available balance" : "Full balance";
} }
@ -141,7 +144,20 @@ class WalletSummaryInfo extends ConsumerWidget {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (toggleBalance) {
if (ref.read(walletBalanceToggleStateProvider) ==
WalletBalanceToggleState.available) {
ref
.read(walletBalanceToggleStateProvider.notifier)
.state = WalletBalanceToggleState.full;
} else {
ref
.read(walletBalanceToggleStateProvider.notifier)
.state = WalletBalanceToggleState.available;
}
} else {
showSheet(context); showSheet(context);
}
}, },
child: Row( child: Row(
children: [ children: [
@ -153,6 +169,7 @@ class WalletSummaryInfo extends ConsumerWidget {
.textFavoriteCard, .textFavoriteCard,
), ),
), ),
if (!toggleBalance) ...[
const SizedBox( const SizedBox(
width: 4, width: 4,
), ),
@ -165,6 +182,7 @@ class WalletSummaryInfo extends ConsumerWidget {
height: 4, height: 4,
), ),
], ],
],
), ),
), ),
const Spacer(), const Spacer(),