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)),
);
final _showAvailable =
ref.watch(walletBalanceToggleStateProvider.state).state ==
WalletBalanceToggleState.available;
final _showAvailable = ref.watch(walletBalanceToggleStateProvider) ==
WalletBalanceToggleState.available;
final Amount balanceToShow;
final String title;
final bool toggleBalance;
if (coin is Firo) {
toggleBalance = false;
final type = ref.watch(publicPrivateBalanceStateProvider.state).state;
title =
"${_showAvailable ? "Available" : "Full"} ${type.name.capitalize()} balance";
@ -109,6 +111,7 @@ class WalletSummaryInfo extends ConsumerWidget {
break;
}
} else {
toggleBalance = true;
balanceToShow = _showAvailable ? balance.spendable : balance.total;
title = _showAvailable ? "Available balance" : "Full balance";
}
@ -141,7 +144,20 @@ class WalletSummaryInfo extends ConsumerWidget {
children: [
GestureDetector(
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(
children: [
@ -153,17 +169,19 @@ class WalletSummaryInfo extends ConsumerWidget {
.textFavoriteCard,
),
),
const SizedBox(
width: 4,
),
SvgPicture.asset(
Assets.svg.chevronDown,
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
width: 8,
height: 4,
),
if (!toggleBalance) ...[
const SizedBox(
width: 4,
),
SvgPicture.asset(
Assets.svg.chevronDown,
color: Theme.of(context)
.extension<StackColors>()!
.textFavoriteCard,
width: 8,
height: 4,
),
],
],
),
),