import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:hive/hive.dart'; import 'package:intl/intl.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/entities/openalias_record.dart'; import 'package:cake_wallet/entities/template.dart'; import 'package:cake_wallet/store/templates/send_template_store.dart'; import 'package:cake_wallet/core/template_validator.dart'; import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/core/amount_validator.dart'; import 'package:cake_wallet/core/pending_transaction.dart'; import 'package:cake_wallet/core/validator.dart'; import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/core/execution_state.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; import 'package:cake_wallet/bitcoin/bitcoin_transaction_credentials.dart'; import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/monero/monero_transaction_creation_credentials.dart'; import 'package:cake_wallet/entities/sync_status.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/transaction_priority.dart'; import 'package:cake_wallet/entities/calculate_fiat_amount.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/send/send_view_model_state.dart'; import 'package:cake_wallet/generated/i18n.dart'; part 'send_view_model.g.dart'; class SendViewModel = SendViewModelBase with _$SendViewModel; abstract class SendViewModelBase with Store { SendViewModelBase(this._wallet, this._settingsStore, this._sendTemplateStore, this._fiatConversationStore, this.transactionDescriptionBox) : state = InitialExecutionState(), _cryptoNumberFormat = NumberFormat(), sendAll = false { _setCryptoNumMaximumFractionDigits(); } @observable ExecutionState state; @observable String fiatAmount; @observable String cryptoAmount; @observable String address; @observable bool sendAll; @computed double get estimatedFee => _wallet.calculateEstimatedFee(_settingsStore.transactionPriority); FiatCurrency get fiat => _settingsStore.fiatCurrency; TransactionPriority get transactionPriority => _settingsStore.transactionPriority; CryptoCurrency get currency => _wallet.currency; Validator get amountValidator => AmountValidator(type: _wallet.type); Validator get allAmountValidator => AllAmountValidator(); Validator get addressValidator => AddressValidator(type: _wallet.currency); Validator get templateValidator => TemplateValidator(); PendingTransaction pendingTransaction; @computed String get balance => _wallet.balance.formattedBalance(BalanceDisplayMode.availableBalance) as String ?? '0.0'; @computed bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus; @computed ObservableList