mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
Merge pull request #249 from cake-tech/CW-6-filter-available-templates-on-send-screen
filter templates by current wallet type
This commit is contained in:
commit
ae390ecab2
2 changed files with 19 additions and 15 deletions
|
@ -197,7 +197,6 @@ class SendPage extends BasePage {
|
||||||
itemCount: itemCount,
|
itemCount: itemCount,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final template = templates[index];
|
final template = templates[index];
|
||||||
|
|
||||||
return TemplateTile(
|
return TemplateTile(
|
||||||
key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
to: template.name,
|
to: template.name,
|
||||||
|
|
|
@ -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,17 @@ 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;
|
List<Template> get templates => sendTemplateViewModel.templates
|
||||||
|
.where((template) => _isEqualCurrency(template.cryptoCurrency))
|
||||||
|
.toList();
|
||||||
|
|
||||||
@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 +205,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;
|
||||||
}
|
}
|
||||||
|
@ -229,4 +231,7 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
return priority.toString();
|
return priority.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isEqualCurrency(String currency) =>
|
||||||
|
currency.toLowerCase() == _wallet.currency.title.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue