mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-27 06:18:50 +01:00
* feat: migrate Trade data to SQLite with TradeLegacy for backward compatibility * feat: persist full currency snapshots in sql storage, not raw-only [WIP] * feat: persist full trade currency snapshots in sql storage * refactor trade and currency handling for migration * Minor fixes --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import "package:cake_wallet/entities/balance_display_mode.dart";
|
|
import "package:cake_wallet/exchange/trade.dart";
|
|
import "package:cake_wallet/store/app_store.dart";
|
|
import "package:cake_wallet/view_model/dashboard/action_list_item.dart";
|
|
|
|
class TradeListItem extends ActionListItem {
|
|
TradeListItem({
|
|
required this.trade,
|
|
required this.appStore,
|
|
required super.key,
|
|
});
|
|
|
|
final Trade trade;
|
|
final AppStore appStore;
|
|
|
|
BalanceDisplayMode get displayMode => appStore.settingsStore.balanceDisplayMode;
|
|
|
|
String get tradeFormattedAmount {
|
|
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
|
return '---';
|
|
}
|
|
final from = trade.from;
|
|
if (from == null) return trade.amountFormatted();
|
|
return appStore.amountParsingProxy.getDisplayCryptoAmount(trade.amountFormatted(), from);
|
|
}
|
|
|
|
String get tradeFormattedReceiveAmount {
|
|
if (displayMode == BalanceDisplayMode.hiddenBalance) {
|
|
return '---';
|
|
}
|
|
final to = trade.to;
|
|
if (to == null) return trade.receiveAmountFormatted();
|
|
return appStore.amountParsingProxy.getDisplayCryptoAmount(trade.receiveAmountFormatted(), to);
|
|
}
|
|
|
|
@override
|
|
DateTime get date => trade.createdAt ?? DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
|
|
}
|