mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-22 07:08:49 +00:00
update transaction details screen
This commit is contained in:
parent
2f511dc2e7
commit
3eb297f953
1 changed files with 33 additions and 43 deletions
|
@ -32,10 +32,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
required this.settingsStore})
|
required this.settingsStore})
|
||||||
: items = ObservableList<TransactionDetailsListItem>(),
|
: items = ObservableList<TransactionDetailsListItem>(),
|
||||||
isRecipientAddressShown = false,
|
isRecipientAddressShown = false,
|
||||||
showRecipientAddress = settingsStore.shouldSaveRecipientAddress,
|
showRecipientAddress = settingsStore.shouldSaveRecipientAddress {
|
||||||
fiatRateListItem = StandartListItem(
|
|
||||||
title: S.current.historical_fiat_rate,
|
|
||||||
value: '${S.current.fetching.toLowerCase()} ...') {
|
|
||||||
final dateFormat = DateFormatter.withCurrentLocal();
|
final dateFormat = DateFormatter.withCurrentLocal();
|
||||||
final tx = transactionInfo;
|
final tx = transactionInfo;
|
||||||
|
|
||||||
|
@ -58,9 +55,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
if (feeFormatted != null)
|
if (feeFormatted != null)
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.transaction_details_fee, value: feeFormatted),
|
title: S.current.transaction_details_fee, value: feeFormatted),
|
||||||
if (settingsStore.fiatApiMode != FiatApiMode.disabled &&
|
|
||||||
settingsStore.showHistoricalFiatRate)
|
|
||||||
fiatRateListItem,
|
|
||||||
if (key?.isNotEmpty ?? false)
|
if (key?.isNotEmpty ?? false)
|
||||||
StandartListItem(title: S.current.transaction_key, value: key!)
|
StandartListItem(title: S.current.transaction_key, value: key!)
|
||||||
];
|
];
|
||||||
|
@ -114,10 +108,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
if (tx.feeFormatted()?.isNotEmpty ?? false)
|
if (tx.feeFormatted()?.isNotEmpty ?? false)
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.transaction_details_fee,
|
title: S.current.transaction_details_fee,
|
||||||
value: tx.feeFormatted()!),
|
value: tx.feeFormatted()!)
|
||||||
if (settingsStore.fiatApiMode != FiatApiMode.disabled &&
|
|
||||||
settingsStore.showHistoricalFiatRate)
|
|
||||||
fiatRateListItem,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
items.addAll(_items);
|
items.addAll(_items);
|
||||||
|
@ -137,10 +128,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
value: tx.amountFormatted()),
|
value: tx.amountFormatted()),
|
||||||
if (tx.feeFormatted()?.isNotEmpty ?? false)
|
if (tx.feeFormatted()?.isNotEmpty ?? false)
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.transaction_details_fee, value: tx.feeFormatted()!),
|
title: S.current.transaction_details_fee, value: tx.feeFormatted()!)
|
||||||
if (settingsStore.fiatApiMode != FiatApiMode.disabled &&
|
|
||||||
settingsStore.showHistoricalFiatRate)
|
|
||||||
fiatRateListItem,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +184,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
final Box<TransactionDescription> transactionDescriptionBox;
|
final Box<TransactionDescription> transactionDescriptionBox;
|
||||||
final SettingsStore settingsStore;
|
final SettingsStore settingsStore;
|
||||||
final WalletBase wallet;
|
final WalletBase wallet;
|
||||||
final StandartListItem fiatRateListItem;
|
|
||||||
|
|
||||||
final ObservableList<TransactionDetailsListItem> items;
|
final ObservableList<TransactionDetailsListItem> items;
|
||||||
bool showRecipientAddress;
|
bool showRecipientAddress;
|
||||||
|
@ -204,36 +191,39 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future<void> getHistoricalFiatRate() async {
|
Future<void> getHistoricalFiatRate() async {
|
||||||
final fiatRateItemIndex = items.indexWhere((element) => element == fiatRateListItem);
|
if (settingsStore.fiatApiMode != FiatApiMode.disabled && settingsStore.showHistoricalFiatRate) {
|
||||||
if (fiatRateItemIndex == -1) return;
|
var fiatRateItemIndex =
|
||||||
|
items.indexWhere((element) => element.title == S.current.transaction_details_fee);
|
||||||
|
fiatRateItemIndex = fiatRateItemIndex == -1 ? items.length - 3 : fiatRateItemIndex;
|
||||||
|
|
||||||
final fiat = settingsStore.fiatCurrency;
|
final fiat = settingsStore.fiatCurrency;
|
||||||
|
|
||||||
final historicalFiatRate = await FiatConversionService.fetchHistoricalPrice(
|
final historicalFiatRate = await FiatConversionService.fetchHistoricalPrice(
|
||||||
crypto: wallet.currency,
|
crypto: wallet.currency,
|
||||||
fiat: fiat,
|
fiat: fiat,
|
||||||
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
|
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
|
||||||
date: transactionInfo.date);
|
date: transactionInfo.date);
|
||||||
var formattedFiatAmount = 0.0;
|
var formattedFiatAmount = 0.0;
|
||||||
switch (wallet.type) {
|
switch (wallet.type) {
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
case WalletType.litecoin:
|
case WalletType.litecoin:
|
||||||
formattedFiatAmount = bitcoinAmountToDouble(amount: transactionInfo.amount);
|
formattedFiatAmount = bitcoinAmountToDouble(amount: transactionInfo.amount);
|
||||||
break;
|
break;
|
||||||
case WalletType.monero:
|
case WalletType.monero:
|
||||||
case WalletType.haven:
|
case WalletType.haven:
|
||||||
formattedFiatAmount = moneroAmountToDouble(amount: transactionInfo.amount);
|
formattedFiatAmount = moneroAmountToDouble(amount: transactionInfo.amount);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
formattedFiatAmount;
|
formattedFiatAmount;
|
||||||
|
}
|
||||||
|
final historicalFiatAmountFormatted = formattedFiatAmount * historicalFiatRate;
|
||||||
|
if (historicalFiatAmountFormatted > 0.0)
|
||||||
|
items.insert(
|
||||||
|
fiatRateItemIndex + 1,
|
||||||
|
StandartListItem(
|
||||||
|
title: S.current.historical_fiat_rate,
|
||||||
|
value: historicalFiatAmountFormatted.toStringAsFixed(2) + ' ${fiat}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
final historicalFiatAmountFormatted = formattedFiatAmount * historicalFiatRate;
|
|
||||||
items[fiatRateItemIndex] = StandartListItem(
|
|
||||||
title: S.current.historical_fiat_rate,
|
|
||||||
value: historicalFiatAmountFormatted > 0.0
|
|
||||||
? historicalFiatAmountFormatted.toStringAsFixed(2) + ' ${fiat}'
|
|
||||||
: 'no historical data');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String _explorerUrl(WalletType type, String txId) {
|
String _explorerUrl(WalletType type, String txId) {
|
||||||
|
|
Loading…
Reference in a new issue