mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-19 00:54:33 +00:00
Merge pull request #904 from cypherstack/togglebalance
Quick toggle balances as appropriate
This commit is contained in:
commit
b1a303ffdc
1 changed files with 33 additions and 15 deletions
|
@ -81,14 +81,16 @@ class WalletSummaryInfo extends ConsumerWidget {
|
|||
priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin)),
|
||||
);
|
||||
|
||||
final _showAvailable =
|
||||
ref.watch(walletBalanceToggleStateProvider.state).state ==
|
||||
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: () {
|
||||
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,6 +169,7 @@ class WalletSummaryInfo extends ConsumerWidget {
|
|||
.textFavoriteCard,
|
||||
),
|
||||
),
|
||||
if (!toggleBalance) ...[
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
|
@ -165,6 +182,7 @@ class WalletSummaryInfo extends ConsumerWidget {
|
|||
height: 4,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
|
|
Loading…
Reference in a new issue