move logic to viewmodels
Serhii committed
Nov 22, 2022 at 19:33 UTC
92328c41029405800f9b18249debef54fbe404ef
4 files changed
+28
-14
lib/src/screens/exchange_trade/exchange_trade_page.dart
+4
-8
@@ -381,14 +381,10 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
381
});
382
},
383
actionLeftButton: () => Navigator.of(context).pop(),
384
- feeFiatAmount: widget.disableFiat ? ''
385
- : widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
386
- + ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title,
387
- fiatAmountValue: widget.disableFiat ? ''
388
- : widget.exchangeTradeViewModel.sendViewModel
389
- .pendingTransactionFiatAmount +
390
- ' ' +
391
- widget.exchangeTradeViewModel.sendViewModel.fiat.title,
384
+ feeFiatAmount: widget.exchangeTradeViewModel
385
+ .pendingTransactionFeeFiatAmountFormatted,
386
+ fiatAmountValue: widget.exchangeTradeViewModel
387
+ .pendingTransactionFiatAmountValueFormatted,
388
outputs: widget.exchangeTradeViewModel.sendViewModel
389
.outputs);
390
});
lib/src/screens/send/send_page.dart
+2
-6
@@ -386,14 +386,10 @@ class SendPage extends BasePage {
386
amount: S.of(context).send_amount,
387
amountValue:
388
sendViewModel.pendingTransaction!.amountFormatted,
389
- fiatAmountValue: sendViewModel.balanceViewModel.disableFiat
390
- ? '' : sendViewModel.pendingTransactionFiatAmount +
391
- ' ' + sendViewModel.fiat.title,
389
+ fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
390
fee: S.of(context).send_fee,
391
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
394
- feeFiatAmount: sendViewModel.balanceViewModel.disableFiat
395
- ? '' : sendViewModel.pendingTransactionFeeFiatAmount +
396
- ' ' + sendViewModel.fiat.title,
392
+ feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
393
outputs: sendViewModel.outputs,
394
rightButtonText: S.of(context).ok,
395
leftButtonText: S.of(context).cancel,
lib/view_model/exchange/exchange_trade_view_model.dart
+12
@@ -72,6 +72,18 @@ abstract class ExchangeTradeViewModelBase with Store {
72
? '\n\n' + S.current.xrp_extra_info
73
: '';
74
75
+ @computed
76
+ String get pendingTransactionFiatAmountValueFormatted =>
77
+ sendViewModel.balanceViewModel.disableFiat
78
+ ? '' : sendViewModel.pendingTransactionFiatAmount
79
+ + ' ' + sendViewModel.fiat.title;
80
+
81
+ @computed
82
+ String get pendingTransactionFeeFiatAmountFormatted =>
83
+ sendViewModel.balanceViewModel.disableFiat
84
+ ? '' : sendViewModel.pendingTransactionFeeFiatAmount
85
+ + ' ' + sendViewModel.fiat.title;
86
+
87
@observable
88
ObservableList<ExchangeTradeItem> items;
89
lib/view_model/send/send_view_model.dart
+10
@@ -139,6 +139,16 @@ abstract class SendViewModelBase with Store {
139
@computed
140
String get balance => balanceViewModel.availableBalance ?? '0.0';
141
142
+ @computed
143
+ String get pendingTransactionFiatAmountFormatted =>
144
+ balanceViewModel.disableFiat ? '' : pendingTransactionFiatAmount +
145
+ ' ' + fiat.title;
146
+
147
+ @computed
148
+ String get pendingTransactionFeeFiatAmountFormatted =>
149
+ balanceViewModel.disableFiat ? '' : pendingTransactionFeeFiatAmount +
150
+ ' ' + fiat.title;
151
+
152
@computed
153
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
154