filter templates by current wallet type

This commit is contained in:
Godwin Asuquo 2022-01-25 15:43:19 +01:00
parent 860e904816
commit 1d3e4f4331
2 changed files with 18 additions and 15 deletions

View file

@ -197,7 +197,7 @@ class SendPage extends BasePage {
itemCount: itemCount, itemCount: itemCount,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final template = templates[index]; final template = templates[index];
print(template.cryptoCurrency);
return TemplateTile( return TemplateTile(
key: UniqueKey(), key: UniqueKey(),
to: template.name, to: template.name,

View file

@ -29,8 +29,11 @@ part 'send_view_model.g.dart';
class SendViewModel = SendViewModelBase with _$SendViewModel; class SendViewModel = SendViewModelBase with _$SendViewModel;
abstract class SendViewModelBase with Store { abstract class SendViewModelBase with Store {
SendViewModelBase(this._wallet, this._settingsStore, SendViewModelBase(
this.sendTemplateViewModel, this._fiatConversationStore, this._wallet,
this._settingsStore,
this.sendTemplateViewModel,
this._fiatConversationStore,
this.transactionDescriptionBox) this.transactionDescriptionBox)
: state = InitialExecutionState() { : state = InitialExecutionState() {
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
@ -127,15 +130,18 @@ abstract class SendViewModelBase with Store {
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus; bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
@computed @computed
ObservableList<Template> get templates => sendTemplateViewModel.templates; ObservableList<Template> get templates => sendTemplateViewModel.templates
.where((template) => template.cryptoCurrency == _wallet.currency.title)
.toList()
.asObservable();
@computed @computed
bool get isElectrumWallet => _wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin; bool get isElectrumWallet =>
_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
bool get hasYat bool get hasYat => outputs.any((out) =>
=> outputs.any((out) => out.isParsedAddress out.isParsedAddress &&
&& out.parsedAddress.parseFrom == ParseFrom.yatRecord); out.parsedAddress.parseFrom == ParseFrom.yatRecord);
WalletType get walletType => _wallet.type; WalletType get walletType => _wallet.type;
final WalletBase _wallet; final WalletBase _wallet;
@ -200,19 +206,16 @@ abstract class SendViewModelBase with Store {
case WalletType.bitcoin: case WalletType.bitcoin:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return bitcoin.createBitcoinTransactionCredentials( return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
outputs, priority);
case WalletType.litecoin: case WalletType.litecoin:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return bitcoin.createBitcoinTransactionCredentials( return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
outputs, priority);
case WalletType.monero: case WalletType.monero:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return monero.createMoneroTransactionCreationCredentials( return monero.createMoneroTransactionCreationCredentials(
outputs: outputs, outputs: outputs, priority: priority);
priority: priority);
default: default:
return null; return null;
} }