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(), actionLeftButton: () => Navigator.of(context).pop(),
feeFiatAmount: widget.disableFiat ? '' feeFiatAmount: widget.exchangeTradeViewModel
: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount .pendingTransactionFeeFiatAmountFormatted,
+ ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title, fiatAmountValue: widget.exchangeTradeViewModel
fiatAmountValue: widget.disableFiat ? '' .pendingTransactionFiatAmountValueFormatted,
: widget.exchangeTradeViewModel.sendViewModel
.pendingTransactionFiatAmount +
' ' +
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
outputs: widget.exchangeTradeViewModel.sendViewModel outputs: widget.exchangeTradeViewModel.sendViewModel
.outputs); .outputs);
}); });

View file

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

View file

@ -72,6 +72,18 @@ abstract class ExchangeTradeViewModelBase with Store {
? '\n\n' + S.current.xrp_extra_info ? '\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 @observable
ObservableList<ExchangeTradeItem> items; ObservableList<ExchangeTradeItem> items;

View file

@ -139,6 +139,16 @@ abstract class SendViewModelBase with Store {
@computed @computed
String get balance => balanceViewModel.availableBalance ?? '0.0'; 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 @computed
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus; bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;