Files
hash-wallet/lib/view_model/dashboard/trade_list_item.dart
T
9f6396f5d8 feat: migrate Trade data to SQLite with TradeLegacy for backward compatibility (#3106)
* 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>
2026-05-07 00:02:04 +02:00

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);
}