mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-05 12:44:09 +01:00
Hidden balance (#1921)
* Change balance hiding behaviour * Update hiding behaviour and add strings * Add touch feedback to balance card * Remove color from TextButton * Add toast to balance card * Add missing string * minor code improvement [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
@@ -20,7 +20,8 @@ part 'balance_view_model.g.dart';
|
||||
|
||||
class BalanceRecord {
|
||||
const BalanceRecord(
|
||||
{required this.availableBalance,
|
||||
{
|
||||
required this.availableBalance,
|
||||
required this.additionalBalance,
|
||||
required this.secondAvailableBalance,
|
||||
required this.secondAdditionalBalance,
|
||||
@@ -148,26 +149,18 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
@computed
|
||||
String get availableBalanceLabel {
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.haven:
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.none:
|
||||
return S.current.xmr_available_balance;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return S.current.show_balance;
|
||||
}
|
||||
else {
|
||||
return S.current.xmr_available_balance;
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
String get additionalBalanceLabel {
|
||||
|
||||
switch (wallet.type) {
|
||||
case WalletType.haven:
|
||||
case WalletType.ethereum:
|
||||
@@ -203,98 +196,35 @@ abstract class BalanceViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
bool get hasMultiBalance => appStore.wallet!.type == WalletType.haven;
|
||||
|
||||
@computed
|
||||
String get availableBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
}
|
||||
|
||||
return walletBalance.formattedAvailableBalance;
|
||||
}
|
||||
|
||||
@computed
|
||||
String get frozenBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
}
|
||||
|
||||
return getFormattedFrozenBalance(walletBalance);
|
||||
}
|
||||
|
||||
@computed
|
||||
String get frozenFiatBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
}
|
||||
|
||||
return _getFiatBalance(price: price, cryptoAmount: getFormattedFrozenBalance(walletBalance)) +
|
||||
' ${fiatCurrency.toString()}';
|
||||
}
|
||||
|
||||
@computed
|
||||
String get additionalBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
return '0.0';
|
||||
}
|
||||
|
||||
return walletBalance.formattedAdditionalBalance;
|
||||
}
|
||||
|
||||
@computed
|
||||
String get availableFiatBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
}
|
||||
|
||||
return _getFiatBalance(price: price, cryptoAmount: walletBalance.formattedAvailableBalance) +
|
||||
' ${fiatCurrency.toString()}';
|
||||
}
|
||||
|
||||
@computed
|
||||
String get additionalFiatBalance {
|
||||
final walletBalance = _walletBalance;
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
return '---';
|
||||
}
|
||||
|
||||
return _getFiatBalance(price: price, cryptoAmount: walletBalance.formattedAdditionalBalance) +
|
||||
' ${fiatCurrency.toString()}';
|
||||
}
|
||||
|
||||
@computed
|
||||
Map<CryptoCurrency, BalanceRecord> get balances {
|
||||
return wallet.balance.map((key, value) {
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
return MapEntry(
|
||||
key,
|
||||
BalanceRecord(
|
||||
availableBalance: '---',
|
||||
additionalBalance: '---',
|
||||
availableBalance: '●●●●●●',
|
||||
additionalBalance: additionalBalance,
|
||||
frozenBalance: '',
|
||||
secondAvailableBalance: '---',
|
||||
secondAdditionalBalance: '---',
|
||||
fiatAdditionalBalance: isFiatDisabled ? '' : '---',
|
||||
fiatAvailableBalance: isFiatDisabled ? '' : '---',
|
||||
fiatFrozenBalance: isFiatDisabled ? '' : '---',
|
||||
fiatSecondAvailableBalance: isFiatDisabled ? '' : '---',
|
||||
fiatSecondAdditionalBalance: isFiatDisabled ? '' : '---',
|
||||
secondAvailableBalance: '',
|
||||
secondAdditionalBalance: '',
|
||||
fiatAdditionalBalance: isFiatDisabled ? '' : '',
|
||||
fiatAvailableBalance: isFiatDisabled ? '' : '${fiatCurrency.toString()} ●●●●●',
|
||||
fiatFrozenBalance: isFiatDisabled ? '' : '',
|
||||
fiatSecondAvailableBalance: isFiatDisabled ? '' : '',
|
||||
fiatSecondAdditionalBalance: isFiatDisabled ? '' : '',
|
||||
asset: key,
|
||||
formattedAssetTitle: _formatterAsset(key)));
|
||||
}
|
||||
@@ -374,16 +304,11 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
bool _hasAdditionalBalanceForWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.litecoin:
|
||||
return false;
|
||||
default:
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,8 +393,6 @@ abstract class BalanceViewModelBase with Store {
|
||||
return balance;
|
||||
}
|
||||
|
||||
@computed
|
||||
CryptoCurrency get currency => appStore.wallet!.currency;
|
||||
|
||||
@observable
|
||||
bool isShowCard;
|
||||
|
||||
Reference in New Issue
Block a user