Merge pull request #141 from cake-tech/CAKE-171-fiat-amount-displaying-bug-on-transaction-list

CAKE-171 | fixed fiat amount displaying bug on transaction list; move…
This commit is contained in:
M 2020-11-12 22:25:38 +02:00
commit 3b4e6fc1bf
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 { (_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
final cryptoCurrency = appStore.wallet.currency; final cryptoCurrency = appStore.wallet.currency;
fiatConversionStore.price = await FiatConversionService.fetchPrice( fiatConversionStore.price = await FiatConversionService.fetchPrice(
cryptoCurrency, settingsStore.fiatCurrency); cryptoCurrency, fiatCurrency);
}); });
} }

View file

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

View file

@ -1,6 +1,7 @@
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/entities/transaction_info.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/utils/mobx.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.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/monero/monero_amount_format.dart';
import 'package:cake_wallet/bitcoin/bitcoin_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/entities/calculate_fiat_amount_raw.dart';
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
class TransactionListItem extends ActionListItem with Keyable { class TransactionListItem extends ActionListItem with Keyable {
TransactionListItem( TransactionListItem(
{this.transaction, this.price, this.fiatCurrency, this.displayMode}); {this.transaction, this.balanceViewModel, this.settingsStore});
final TransactionInfo transaction; final TransactionInfo transaction;
final double price; final BalanceViewModel balanceViewModel;
final FiatCurrency fiatCurrency; final SettingsStore settingsStore;
final BalanceDisplayMode displayMode;
double get price => balanceViewModel.price;
FiatCurrency get fiatCurrency => settingsStore.fiatCurrency;
BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
@override @override
dynamic get keyIndex => transaction.id; dynamic get keyIndex => transaction.id;
@ -49,4 +56,4 @@ class TransactionListItem extends ActionListItem with Keyable {
@override @override
DateTime get date => transaction.date; DateTime get date => transaction.date;
} }