mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Fixes for update fiat rate after change of current wallet type. Fixes for change amount for btc transactions. Changed displaying of balance for btc wallet. General fixes.
This commit is contained in:
@@ -15,31 +15,34 @@ part 'balance_view_model.g.dart';
|
||||
class BalanceViewModel = BalanceViewModelBase with _$BalanceViewModel;
|
||||
|
||||
abstract class BalanceViewModelBase with Store {
|
||||
BalanceViewModelBase({
|
||||
@required this.appStore,
|
||||
@required this.settingsStore,
|
||||
@required this.fiatConvertationStore
|
||||
}) : isReversing = false;
|
||||
BalanceViewModelBase(
|
||||
{@required this.appStore,
|
||||
@required this.settingsStore,
|
||||
@required this.fiatConvertationStore})
|
||||
: isReversing = false;
|
||||
|
||||
final AppStore appStore;
|
||||
final SettingsStore settingsStore;
|
||||
final FiatConversionStore fiatConvertationStore;
|
||||
|
||||
bool get canReverse =>
|
||||
(appStore.wallet.balance.availableModes as List).length > 1;
|
||||
|
||||
@observable
|
||||
bool isReversing;
|
||||
|
||||
@computed
|
||||
double get price => fiatConvertationStore.prices[appStore.wallet.currency];
|
||||
|
||||
@computed
|
||||
BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode;
|
||||
|
||||
@computed
|
||||
BalanceDisplayMode get displayMode => isReversing
|
||||
? (savedDisplayMode == BalanceDisplayMode.availableBalance
|
||||
? BalanceDisplayMode.fullBalance
|
||||
: BalanceDisplayMode.availableBalance)
|
||||
: savedDisplayMode;
|
||||
|
||||
@computed
|
||||
double get price => fiatConvertationStore.price;
|
||||
? (savedDisplayMode == BalanceDisplayMode.availableBalance
|
||||
? BalanceDisplayMode.fullBalance
|
||||
: BalanceDisplayMode.availableBalance)
|
||||
: savedDisplayMode;
|
||||
|
||||
@computed
|
||||
String get cryptoBalance {
|
||||
@@ -63,15 +66,11 @@ abstract class BalanceViewModelBase with Store {
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
var balance = '---';
|
||||
|
||||
final totalBalance = _getFiatBalance(
|
||||
price: price,
|
||||
cryptoAmount: walletBalance.totalBalance
|
||||
);
|
||||
final totalBalance =
|
||||
_getFiatBalance(price: price, cryptoAmount: walletBalance.totalBalance);
|
||||
|
||||
final unlockedBalance = _getFiatBalance(
|
||||
price: price,
|
||||
cryptoAmount: walletBalance.unlockedBalance
|
||||
);
|
||||
price: price, cryptoAmount: walletBalance.unlockedBalance);
|
||||
|
||||
if (displayMode == BalanceDisplayMode.availableBalance) {
|
||||
balance = fiatCurrency.toString() + ' ' + unlockedBalance ?? '0.00';
|
||||
@@ -89,7 +88,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
final _wallet = appStore.wallet;
|
||||
|
||||
if (_wallet is MoneroWallet) {
|
||||
return WalletBalance(
|
||||
return WalletBalance(
|
||||
unlockedBalance: _wallet.balance.formattedUnlockedBalance,
|
||||
totalBalance: _wallet.balance.formattedFullBalance);
|
||||
}
|
||||
@@ -113,4 +112,4 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
return calculateFiatAmount(price: price, cryptoAmount: cryptoAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user