import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/core/amount_validator.dart'; import 'package:cake_wallet/core/template_validator.dart'; import 'package:cake_wallet/core/validator.dart'; import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/src/domain/common/balance.dart'; import 'package:cake_wallet/src/domain/common/balance_display_mode.dart'; import 'package:cake_wallet/src/domain/common/calculate_estimated_fee.dart'; import 'package:cake_wallet/src/domain/common/crypto_currency.dart'; import 'package:cake_wallet/src/domain/common/fiat_currency.dart'; import 'package:cake_wallet/src/domain/common/sync_status.dart'; import 'package:cake_wallet/src/domain/common/transaction_priority.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/templates/send_template_store.dart'; import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/monero/monero_wallet_service.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart'; import 'package:cake_wallet/core/wallet_creation_service.dart'; import 'package:cake_wallet/core/wallet_credentials.dart'; import 'package:cake_wallet/src/domain/common/wallet_type.dart'; import 'package:cake_wallet/view_model/wallet_creation_vm.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/domain/common/openalias_record.dart'; import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart'; import 'package:cake_wallet/src/domain/common/template.dart'; part 'send_view_model.g.dart'; abstract class SendViewModelState {} class InitialSendViewModelState extends SendViewModelState {} class TransactionIsCreating extends SendViewModelState {} class TransactionCreatedSuccessfully extends SendViewModelState {} class TransactionCommitting extends SendViewModelState {} class TransactionCommitted extends SendViewModelState {} class SendingFailed extends SendViewModelState { SendingFailed({@required this.error}); String error; } class SendViewModel = SendViewModelBase with _$SendViewModel; abstract class SendViewModelBase with Store { SendViewModelBase( this._wallet, this._settingsStore, this._fiatConvertationStore, this.sendTemplateStore) { state = InitialSendViewModelState(); _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12; _fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2; } NumberFormat _cryptoNumberFormat; NumberFormat _fiatNumberFormat; @observable SendViewModelState state; @observable String fiatAmount; @observable String cryptoAmount; @observable String address; String get cryptoCurrencyTitle { var _currencyTitle = ''; if (_wallet is MoneroWallet) { _currencyTitle = 'Monero'; } if (_wallet is BitcoinWallet) { _currencyTitle = 'Bitcoin'; } return _currencyTitle; } String get pageTitle => S.current.send_title + ' ' + cryptoCurrencyTitle; FiatCurrency get fiat => _settingsStore.fiatCurrency; TransactionPriority get transactionPriority => _settingsStore.transactionPriority; double get estimatedFee => calculateEstimatedFee(priority: transactionPriority); String get name => _wallet.name; CryptoCurrency get currency => _wallet.currency; Validator get amountValidator => AmountValidator(type: _wallet.type); Validator get addressValidator => AddressValidator(type: _wallet.currency); Validator get templateValidator => TemplateValidator(); @computed double get price => _fiatConvertationStore.price; @computed ObservableList