filter templates by current wallet type
Godwin Asuquo committed
Jan 25, 2022 at 15:43 UTC
1d3e4f4331e16f8f83ca89ed87427d3d5cb4abbb
2 files changed
+18
-15
lib/src/screens/send/send_page.dart
+1
-1
@@ -197,7 +197,7 @@ class SendPage extends BasePage {
197
itemCount: itemCount,
198
itemBuilder: (context, index) {
199
final template = templates[index];
200
-
200
+ print(template.cryptoCurrency);
201
return TemplateTile(
202
key: UniqueKey(),
203
to: template.name,
lib/view_model/send/send_view_model.dart
+17
-14
@@ -29,8 +29,11 @@ part 'send_view_model.g.dart';
29
class SendViewModel = SendViewModelBase with _$SendViewModel;
30
31
abstract class SendViewModelBase with Store {
32
- SendViewModelBase(this._wallet, this._settingsStore,
33
- this.sendTemplateViewModel, this._fiatConversationStore,
32
+ SendViewModelBase(
33
+ this._wallet,
34
+ this._settingsStore,
35
+ this.sendTemplateViewModel,
36
+ this._fiatConversationStore,
37
this.transactionDescriptionBox)
38
: state = InitialExecutionState() {
39
final priority = _settingsStore.priority[_wallet.type];
@@ -127,15 +130,18 @@ abstract class SendViewModelBase with Store {
130
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
131
132
@computed
130
- ObservableList<Template> get templates => sendTemplateViewModel.templates;
133
+ ObservableList<Template> get templates => sendTemplateViewModel.templates
134
+ .where((template) => template.cryptoCurrency == _wallet.currency.title)
135
+ .toList()
136
+ .asObservable();
137
138
@computed
133
- bool get isElectrumWallet => _wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
139
+ bool get isElectrumWallet =>
140
+ _wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
141
135
- bool get hasYat
136
- => outputs.any((out) => out.isParsedAddress
137
- && out.parsedAddress.parseFrom == ParseFrom.yatRecord);
138
-
142
+ bool get hasYat => outputs.any((out) =>
143
+ out.isParsedAddress &&
144
+ out.parsedAddress.parseFrom == ParseFrom.yatRecord);
145
146
WalletType get walletType => _wallet.type;
147
final WalletBase _wallet;
@@ -200,19 +206,16 @@ abstract class SendViewModelBase with Store {
206
case WalletType.bitcoin:
207
final priority = _settingsStore.priority[_wallet.type];
208
203
- return bitcoin.createBitcoinTransactionCredentials(
204
- outputs, priority);
209
+ return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
210
case WalletType.litecoin:
211
final priority = _settingsStore.priority[_wallet.type];
212
208
- return bitcoin.createBitcoinTransactionCredentials(
209
- outputs, priority);
213
+ return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
214
case WalletType.monero:
215
final priority = _settingsStore.priority[_wallet.type];
216
217
return monero.createMoneroTransactionCreationCredentials(
214
- outputs: outputs,
215
- priority: priority);
218
+ outputs: outputs, priority: priority);
219
default:
220
return null;
221
}