mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
show the balances when toggle switching
This commit is contained in:
parent
dd00e76623
commit
fd9b09d37a
1 changed files with 135 additions and 36 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
|
@ -8,6 +9,8 @@ import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
|||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
|
||||
class WalletBalanceToggleSheet extends ConsumerWidget {
|
||||
const WalletBalanceToggleSheet({
|
||||
Key? key,
|
||||
|
@ -23,6 +26,22 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
final coin = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId).coin));
|
||||
|
||||
Future<Decimal>? totalBalanceFuture;
|
||||
Future<Decimal>? availableBalanceFuture;
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
final firoWallet = ref
|
||||
.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId)))
|
||||
.wallet as FiroWallet;
|
||||
totalBalanceFuture = firoWallet.availablePublicBalance();
|
||||
availableBalanceFuture = firoWallet.availablePrivateBalance();
|
||||
} else {
|
||||
final wallet = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId)));
|
||||
totalBalanceFuture = wallet.totalBalance;
|
||||
availableBalanceFuture = wallet.availableBalance;
|
||||
}
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
|
@ -125,15 +144,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Text(
|
||||
"Current spendable (unlocked) balance",
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context).copyWith(
|
||||
FutureBuilder(
|
||||
future: availableBalanceFuture,
|
||||
builder: (fbContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.data != null) {
|
||||
return Text(
|
||||
"${snapshot.data!}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
"",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet)
|
||||
|
@ -147,15 +186,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Text(
|
||||
"Current private spendable (unlocked) balance",
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context).copyWith(
|
||||
FutureBuilder(
|
||||
future: availableBalanceFuture,
|
||||
builder: (fbContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.data != null) {
|
||||
return Text(
|
||||
"${snapshot.data!}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
"",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -219,15 +278,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Text(
|
||||
"Total wallet balance",
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context).copyWith(
|
||||
FutureBuilder(
|
||||
future: totalBalanceFuture,
|
||||
builder: (fbContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.data != null) {
|
||||
return Text(
|
||||
"${snapshot.data!}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
"",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet)
|
||||
|
@ -241,15 +320,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Text(
|
||||
"Current public spendable (unlocked) balance",
|
||||
style:
|
||||
STextStyles.itemSubtitle12(context).copyWith(
|
||||
FutureBuilder(
|
||||
future: totalBalanceFuture,
|
||||
builder: (fbContext,
|
||||
AsyncSnapshot<Decimal> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.data != null) {
|
||||
return Text(
|
||||
"${snapshot.data!}",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
"",
|
||||
style: STextStyles.itemSubtitle12(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue