mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +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
|
@override
|
||||||
String get formattedAvailableBalance {
|
String get formattedAvailableBalance {
|
||||||
bool isOutgoingTx = unconfirmed.isNegative;
|
bool isOutgoingTx = unconfirmed.isNegative;
|
||||||
final availableBalance = isOutgoingTx ? (confirmed + unconfirmed) : (confirmed);
|
final availableBalance =
|
||||||
|
isOutgoingTx ? ((confirmed + unconfirmed) - frozen) : (confirmed - frozen);
|
||||||
return bitcoinAmountToString(amount: availableBalance);
|
return bitcoinAmountToString(amount: availableBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +43,8 @@ class ElectrumBalance extends Balance {
|
||||||
@override
|
@override
|
||||||
String get formattedFullBalance {
|
String get formattedFullBalance {
|
||||||
bool isOutgoingTx = unconfirmed.isNegative;
|
bool isOutgoingTx = unconfirmed.isNegative;
|
||||||
final fullBalance = isOutgoingTx
|
final fullBalance =
|
||||||
? (confirmed + frozen)
|
isOutgoingTx ? (confirmed + frozen) : (confirmed + (unconfirmed.abs()) + frozen);
|
||||||
: (confirmed + (unconfirmed.abs()) + frozen);
|
|
||||||
final result = bitcoinAmountToString(amount: fullBalance);
|
final result = bitcoinAmountToString(amount: fullBalance);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -230,6 +230,7 @@ class CryptoBalanceWidget extends StatelessWidget {
|
||||||
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel}',
|
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel}',
|
||||||
additionalBalance: balance.additionalBalance,
|
additionalBalance: balance.additionalBalance,
|
||||||
additionalFiatBalance: balance.fiatAdditionalBalance,
|
additionalFiatBalance: balance.fiatAdditionalBalance,
|
||||||
|
hasFullBalance: dashboardViewModel.balanceViewModel.hasFullBalance,
|
||||||
fullBalanceLabel: '${dashboardViewModel.balanceViewModel.fullBalanceLabel}',
|
fullBalanceLabel: '${dashboardViewModel.balanceViewModel.fullBalanceLabel}',
|
||||||
fullBalance: balance.fullBalance,
|
fullBalance: balance.fullBalance,
|
||||||
fullFiatBalance: balance.fiatFullBalance,
|
fullFiatBalance: balance.fiatFullBalance,
|
||||||
|
@ -265,6 +266,7 @@ class BalanceRowWidget extends StatelessWidget {
|
||||||
required this.fullFiatBalance,
|
required this.fullFiatBalance,
|
||||||
required this.currency,
|
required this.currency,
|
||||||
required this.hasAdditionalBalance,
|
required this.hasAdditionalBalance,
|
||||||
|
required this.hasFullBalance,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -281,6 +283,7 @@ class BalanceRowWidget extends StatelessWidget {
|
||||||
final String fullFiatBalance;
|
final String fullFiatBalance;
|
||||||
final CryptoCurrency currency;
|
final CryptoCurrency currency;
|
||||||
final bool hasAdditionalBalance;
|
final bool hasAdditionalBalance;
|
||||||
|
final bool hasFullBalance;
|
||||||
|
|
||||||
// void _showBalanceDescription(BuildContext context) {
|
// void _showBalanceDescription(BuildContext context) {
|
||||||
// showPopUp<void>(
|
// showPopUp<void>(
|
||||||
|
@ -515,7 +518,7 @@ class BalanceRowWidget extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (hasAdditionalBalance)
|
if (hasFullBalance)
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -326,6 +326,10 @@ abstract class BalanceViewModelBase with Store {
|
||||||
@computed
|
@computed
|
||||||
bool get hasAdditionalBalance => _hasAdditionBalanceForWalletType(wallet.type);
|
bool get hasAdditionalBalance => _hasAdditionBalanceForWalletType(wallet.type);
|
||||||
|
|
||||||
|
@computed
|
||||||
|
bool get hasFullBalance =>
|
||||||
|
wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin;
|
||||||
|
|
||||||
bool _hasAdditionBalanceForWalletType(WalletType type) {
|
bool _hasAdditionBalanceForWalletType(WalletType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WalletType.ethereum:
|
case WalletType.ethereum:
|
||||||
|
|
Loading…
Reference in a new issue