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: () {
showSheet(context); 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);
}
}, },
child: Row( child: Row(
children: [ children: [
@ -153,17 +169,19 @@ class WalletSummaryInfo extends ConsumerWidget {
.textFavoriteCard, .textFavoriteCard,
), ),
), ),
const SizedBox( if (!toggleBalance) ...[
width: 4, const SizedBox(
), width: 4,
SvgPicture.asset( ),
Assets.svg.chevronDown, SvgPicture.asset(
color: Theme.of(context) Assets.svg.chevronDown,
.extension<StackColors>()! color: Theme.of(context)
.textFavoriteCard, .extension<StackColors>()!
width: 8, .textFavoriteCard,
height: 4, width: 8,
), height: 4,
),
],
], ],
), ),
), ),