| 1 | import "package:cake_wallet/entities/balance_display_mode.dart"; |
| 2 | import "package:cake_wallet/exchange/trade.dart"; |
| 3 | import "package:cake_wallet/store/app_store.dart"; |
| 4 | import "package:cake_wallet/view_model/dashboard/action_list_item.dart"; |
| 5 | |
| 6 | class TradeListItem extends ActionListItem { |
| 7 | TradeListItem({ |
| 8 | required this.trade, |
| 9 | required this.appStore, |
| 10 | required super.key, |
| 11 | }); |
| 12 | |
| 13 | final Trade trade; |
| 14 | final AppStore appStore; |
| 15 | |
| 16 | BalanceDisplayMode get displayMode => appStore.settingsStore.balanceDisplayMode; |
| 17 | |
| 18 | String get tradeFormattedAmount { |
| 19 | if (displayMode == BalanceDisplayMode.hiddenBalance) { |
| 20 | return '---'; |
| 21 | } |
| 22 | final from = trade.from; |
| 23 | if (from == null) return trade.amountFormatted(); |
| 24 | return appStore.amountParsingProxy.getDisplayCryptoAmount(trade.amountFormatted(), from); |
| 25 | } |
| 26 | |
| 27 | String get tradeFormattedReceiveAmount { |
| 28 | if (displayMode == BalanceDisplayMode.hiddenBalance) { |
| 29 | return '---'; |
| 30 | } |
| 31 | final to = trade.to; |
| 32 | if (to == null) return trade.receiveAmountFormatted(); |
| 33 | return appStore.amountParsingProxy.getDisplayCryptoAmount(trade.receiveAmountFormatted(), to); |
| 34 | } |
| 35 | |
| 36 | @override |
| 37 | DateTime get date => trade.createdAt ?? DateTime.fromMillisecondsSinceEpoch(0, isUtc: true); |
| 38 | } |