move logic to viewmodels

This commit is contained in:
Serhii 2022-11-22 19:33:24 +02:00
parent 9ce8a1944b
commit 92328c4102
4 changed files with 28 additions and 14 deletions

View file

@ -381,14 +381,10 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
});
},
actionLeftButton: () => Navigator.of(context).pop(),
feeFiatAmount: widget.disableFiat ? ''
: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
+ ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title,
fiatAmountValue: widget.disableFiat ? ''
: widget.exchangeTradeViewModel.sendViewModel
.pendingTransactionFiatAmount +
' ' +
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
feeFiatAmount: widget.exchangeTradeViewModel
.pendingTransactionFeeFiatAmountFormatted,
fiatAmountValue: widget.exchangeTradeViewModel
.pendingTransactionFiatAmountValueFormatted,
outputs: widget.exchangeTradeViewModel.sendViewModel
.outputs);
});

View file

@ -386,14 +386,10 @@ class SendPage extends BasePage {
amount: S.of(context).send_amount,
amountValue:
sendViewModel.pendingTransaction!.amountFormatted,
fiatAmountValue: sendViewModel.balanceViewModel.disableFiat
? '' : sendViewModel.pendingTransactionFiatAmount +
' ' + sendViewModel.fiat.title,
fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
fee: S.of(context).send_fee,
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
feeFiatAmount: sendViewModel.balanceViewModel.disableFiat
? '' : sendViewModel.pendingTransactionFeeFiatAmount +
' ' + sendViewModel.fiat.title,
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
outputs: sendViewModel.outputs,
rightButtonText: S.of(context).ok,
leftButtonText: S.of(context).cancel,

View file

@ -72,6 +72,18 @@ abstract class ExchangeTradeViewModelBase with Store {
? '\n\n' + S.current.xrp_extra_info
: '';
@computed
String get pendingTransactionFiatAmountValueFormatted =>
sendViewModel.balanceViewModel.disableFiat
? '' : sendViewModel.pendingTransactionFiatAmount
+ ' ' + sendViewModel.fiat.title;
@computed
String get pendingTransactionFeeFiatAmountFormatted =>
sendViewModel.balanceViewModel.disableFiat
? '' : sendViewModel.pendingTransactionFeeFiatAmount
+ ' ' + sendViewModel.fiat.title;
@observable
ObservableList<ExchangeTradeItem> items;

View file

@ -139,6 +139,16 @@ abstract class SendViewModelBase with Store {
@computed
String get balance => balanceViewModel.availableBalance ?? '0.0';
@computed
String get pendingTransactionFiatAmountFormatted =>
balanceViewModel.disableFiat ? '' : pendingTransactionFiatAmount +
' ' + fiat.title;
@computed
String get pendingTransactionFeeFiatAmountFormatted =>
balanceViewModel.disableFiat ? '' : pendingTransactionFeeFiatAmount +
' ' + fiat.title;
@computed
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;