mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
fix: Add frozen balance into consideration when taking available balance and add field to make full balance display only on bitcoin and litecoin wallets
This commit is contained in:
parent
ef04ec518b
commit
48e29e39a4
3 changed files with 12 additions and 5 deletions
|
@ -26,7 +26,8 @@ class ElectrumBalance extends Balance {
|
|||
@override
|
||||
String get formattedAvailableBalance {
|
||||
bool isOutgoingTx = unconfirmed.isNegative;
|
||||
final availableBalance = isOutgoingTx ? (confirmed + unconfirmed) : (confirmed);
|
||||
final availableBalance =
|
||||
isOutgoingTx ? ((confirmed + unconfirmed) - frozen) : (confirmed - frozen);
|
||||
return bitcoinAmountToString(amount: availableBalance);
|
||||
}
|
||||
|
||||
|
@ -42,9 +43,8 @@ class ElectrumBalance extends Balance {
|
|||
@override
|
||||
String get formattedFullBalance {
|
||||
bool isOutgoingTx = unconfirmed.isNegative;
|
||||
final fullBalance = isOutgoingTx
|
||||
? (confirmed + frozen)
|
||||
: (confirmed + (unconfirmed.abs()) + frozen);
|
||||
final fullBalance =
|
||||
isOutgoingTx ? (confirmed + frozen) : (confirmed + (unconfirmed.abs()) + frozen);
|
||||
final result = bitcoinAmountToString(amount: fullBalance);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -230,6 +230,7 @@ class CryptoBalanceWidget extends StatelessWidget {
|
|||
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel}',
|
||||
additionalBalance: balance.additionalBalance,
|
||||
additionalFiatBalance: balance.fiatAdditionalBalance,
|
||||
hasFullBalance: dashboardViewModel.balanceViewModel.hasFullBalance,
|
||||
fullBalanceLabel: '${dashboardViewModel.balanceViewModel.fullBalanceLabel}',
|
||||
fullBalance: balance.fullBalance,
|
||||
fullFiatBalance: balance.fiatFullBalance,
|
||||
|
@ -265,6 +266,7 @@ class BalanceRowWidget extends StatelessWidget {
|
|||
required this.fullFiatBalance,
|
||||
required this.currency,
|
||||
required this.hasAdditionalBalance,
|
||||
required this.hasFullBalance,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
@ -281,6 +283,7 @@ class BalanceRowWidget extends StatelessWidget {
|
|||
final String fullFiatBalance;
|
||||
final CryptoCurrency currency;
|
||||
final bool hasAdditionalBalance;
|
||||
final bool hasFullBalance;
|
||||
|
||||
// void _showBalanceDescription(BuildContext context) {
|
||||
// showPopUp<void>(
|
||||
|
@ -515,7 +518,7 @@ class BalanceRowWidget extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
if (hasAdditionalBalance)
|
||||
if (hasFullBalance)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
|
|
@ -326,6 +326,10 @@ abstract class BalanceViewModelBase with Store {
|
|||
@computed
|
||||
bool get hasAdditionalBalance => _hasAdditionBalanceForWalletType(wallet.type);
|
||||
|
||||
@computed
|
||||
bool get hasFullBalance =>
|
||||
wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin;
|
||||
|
||||
bool _hasAdditionBalanceForWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.ethereum:
|
||||
|
|
Loading…
Reference in a new issue