CAKE-171 | fixed fiat amount displaying bug on transaction list; moved calculating price, type of fiat currency and display mode to transaction list item

This commit is contained in:
OleksandrSobol 2020-11-12 11:32:57 +02:00
parent 65c2abdedc
commit 7bbc14d549
3 changed files with 19 additions and 15 deletions

View file

@ -13,6 +13,6 @@ void startCurrentFiatChangeReaction(AppStore appStore, SettingsStore settingsSto
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
final cryptoCurrency = appStore.wallet.currency;
fiatConversionStore.price = await FiatConversionService.fetchPrice(
cryptoCurrency, settingsStore.fiatCurrency);
cryptoCurrency, fiatCurrency);
});
}

View file

@ -78,9 +78,8 @@ abstract class DashboardViewModelBase with Store {
.transactionHistory.transactions.values
.map((transaction) => TransactionListItem(
transaction: transaction,
price: price,
fiatCurrency: appStore.settingsStore.fiatCurrency,
displayMode: balanceDisplayMode)));
balanceViewModel: balanceViewModel,
settingsStore: appStore.settingsStore)));
_reaction = reaction((_) => appStore.wallet, _onWalletChange);
// FIXME: fixme
@ -89,9 +88,8 @@ abstract class DashboardViewModelBase with Store {
transactions,
(TransactionInfo val) => TransactionListItem(
transaction: val,
price: price,
fiatCurrency: appStore.settingsStore.fiatCurrency,
displayMode: balanceDisplayMode));
balanceViewModel: balanceViewModel,
settingsStore: appStore.settingsStore));
final _wallet = wallet;
@ -185,8 +183,7 @@ abstract class DashboardViewModelBase with Store {
transactions.addAll(wallet.transactionHistory.transactions.values.map(
(transaction) => TransactionListItem(
transaction: transaction,
price: price,
fiatCurrency: appStore.settingsStore.fiatCurrency,
displayMode: balanceDisplayMode)));
balanceViewModel: balanceViewModel,
settingsStore: appStore.settingsStore)));
}
}

View file

@ -1,6 +1,7 @@
import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/entities/transaction_info.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/mobx.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
@ -8,15 +9,21 @@ import 'package:cake_wallet/monero/monero_transaction_info.dart';
import 'package:cake_wallet/monero/monero_amount_format.dart';
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
class TransactionListItem extends ActionListItem with Keyable {
TransactionListItem(
{this.transaction, this.price, this.fiatCurrency, this.displayMode});
{this.transaction, this.balanceViewModel, this.settingsStore});
final TransactionInfo transaction;
final double price;
final FiatCurrency fiatCurrency;
final BalanceDisplayMode displayMode;
final BalanceViewModel balanceViewModel;
final SettingsStore settingsStore;
double get price => balanceViewModel.price;
FiatCurrency get fiatCurrency => settingsStore.fiatCurrency;
BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
@override
dynamic get keyIndex => transaction.id;