mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Merge branch '4.1.0' into CAKE-208-bug-after-balance-changing
# Conflicts: # lib/store/settings_store.dart # lib/view_model/dashboard/balance_view_model.dart
This commit is contained in:
@@ -17,11 +17,11 @@ 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
|
||||
}) {
|
||||
BalanceViewModelBase(
|
||||
{@required this.appStore,
|
||||
@required this.settingsStore,
|
||||
@required this.fiatConvertationStore}){
|
||||
|
||||
isReversing = false;
|
||||
|
||||
wallet ??= appStore.wallet;
|
||||
@@ -42,6 +42,9 @@ abstract class BalanceViewModelBase with Store {
|
||||
final SettingsStore settingsStore;
|
||||
final FiatConversionStore fiatConvertationStore;
|
||||
|
||||
bool get canReverse =>
|
||||
(appStore.wallet.balance.availableModes as List).length > 1;
|
||||
|
||||
@observable
|
||||
bool isReversing;
|
||||
|
||||
@@ -51,18 +54,18 @@ abstract class BalanceViewModelBase with Store {
|
||||
@observable
|
||||
WalletBase wallet;
|
||||
|
||||
@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 {
|
||||
@@ -86,15 +89,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';
|
||||
@@ -119,7 +118,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
if (_wallet is BitcoinWallet) {
|
||||
return WalletBalance(
|
||||
unlockedBalance: _wallet.balance.totalFormatted,
|
||||
unlockedBalance: _wallet.balance.availableBalanceFormatted,
|
||||
totalBalance: _wallet.balance.totalFormatted);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
@observable
|
||||
WalletBase wallet;
|
||||
|
||||
bool get hasRescan => wallet.type == WalletType.monero;
|
||||
|
||||
BalanceViewModel balanceViewModel;
|
||||
|
||||
AppStore appStore;
|
||||
@@ -212,6 +214,7 @@ abstract class DashboardViewModelBase with Store {
|
||||
@action
|
||||
void _onWalletChange(WalletBase wallet) {
|
||||
this.wallet = wallet;
|
||||
type = wallet.type;
|
||||
name = wallet.name;
|
||||
|
||||
if (wallet is MoneroWallet) {
|
||||
@@ -236,6 +239,21 @@ abstract class DashboardViewModelBase with Store {
|
||||
balanceViewModel: balanceViewModel,
|
||||
settingsStore: appStore.settingsStore)));
|
||||
}
|
||||
|
||||
connectMapToListWithTransform(
|
||||
appStore.wallet.transactionHistory.transactions,
|
||||
transactions,
|
||||
(TransactionInfo val) => TransactionListItem(
|
||||
transaction: val,
|
||||
balanceViewModel: balanceViewModel,
|
||||
settingsStore: appStore.settingsStore),
|
||||
filter: (TransactionInfo tx) {
|
||||
if (tx is MoneroTransactionInfo && wallet is MoneroWallet) {
|
||||
return tx.accountIndex == wallet.account.id;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
Reference in New Issue
Block a user