diff --git a/lib/exchange/exchange_template.dart b/lib/exchange/exchange_template.dart index 26e1fa761..dcfd8d8e8 100644 --- a/lib/exchange/exchange_template.dart +++ b/lib/exchange/exchange_template.dart @@ -4,14 +4,15 @@ part 'exchange_template.g.dart'; @HiveType(typeId: ExchangeTemplate.typeId) class ExchangeTemplate extends HiveObject { - ExchangeTemplate({ - required this.amountRaw, - required this.depositCurrencyRaw, - required this.receiveCurrencyRaw, - required this.providerRaw, - required this.depositAddressRaw, - required this.receiveAddressRaw - }); + ExchangeTemplate( + {required this.amountRaw, + required this.depositCurrencyRaw, + required this.receiveCurrencyRaw, + required this.providerRaw, + required this.depositAddressRaw, + required this.receiveAddressRaw, + required this.depositCurrencyTitleRaw, + required this.receiveCurrencyTitleRaw}); static const typeId = 7; static const boxName = 'ExchangeTemplate'; @@ -34,6 +35,12 @@ class ExchangeTemplate extends HiveObject { @HiveField(5) String? receiveAddressRaw; + @HiveField(6) + String? depositCurrencyTitleRaw; + + @HiveField(7) + String? receiveCurrencyTitleRaw; + String get amount => amountRaw ?? ''; String get depositCurrency => depositCurrencyRaw ?? ''; @@ -45,4 +52,8 @@ class ExchangeTemplate extends HiveObject { String get depositAddress => depositAddressRaw ?? ''; String get receiveAddress => receiveAddressRaw ?? ''; -} \ No newline at end of file + + String get depositCurrencyTitle => depositCurrencyTitleRaw ?? ''; + + String get receiveCurrencyTitle => receiveCurrencyTitleRaw ?? ''; +} diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index fa3b3b825..0254ef0d4 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -280,8 +280,8 @@ class ExchangePage extends BasePage { return TemplateTile( key: UniqueKey(), amount: template.amount, - from: template.depositCurrency, - to: template.receiveCurrency, + from: template.depositCurrencyTitle, + to: template.receiveCurrencyTitle, onTap: () { applyTemplate(context, exchangeViewModel, template); }, diff --git a/lib/src/screens/exchange/exchange_template_page.dart b/lib/src/screens/exchange/exchange_template_page.dart index 50faf7eb2..00eee49c2 100644 --- a/lib/src/screens/exchange/exchange_template_page.dart +++ b/lib/src/screens/exchange/exchange_template_page.dart @@ -239,9 +239,13 @@ class ExchangeTemplatePage extends BasePage { exchangeViewModel.addTemplate( amount: exchangeViewModel.depositAmount, depositCurrency: - exchangeViewModel.depositCurrency.toString(), + exchangeViewModel.depositCurrency.name, + depositCurrencyTitle: exchangeViewModel + .depositCurrency.title + ' ${exchangeViewModel.depositCurrency.tag ?? ''}', receiveCurrency: - exchangeViewModel.receiveCurrency.toString(), + exchangeViewModel.receiveCurrency.name, + receiveCurrencyTitle: exchangeViewModel + .receiveCurrency.title + ' ${exchangeViewModel.receiveCurrency.tag ?? ''}', provider: exchangeViewModel.provider.toString(), depositAddress: exchangeViewModel.depositAddress, receiveAddress: exchangeViewModel.receiveAddress); diff --git a/lib/store/templates/exchange_template_store.dart b/lib/store/templates/exchange_template_store.dart index a63c2f56e..97e1f41dc 100644 --- a/lib/store/templates/exchange_template_store.dart +++ b/lib/store/templates/exchange_template_store.dart @@ -8,8 +8,8 @@ part 'exchange_template_store.g.dart'; class ExchangeTemplateStore = ExchangeTemplateBase with _$ExchangeTemplateStore; abstract class ExchangeTemplateBase with Store { - ExchangeTemplateBase({required this.templateSource}) - : templates = ObservableList() { + ExchangeTemplateBase({required this.templateSource}) + : templates = ObservableList() { templates = ObservableList(); update(); } @@ -20,27 +20,31 @@ abstract class ExchangeTemplateBase with Store { Box templateSource; @action - void update() => - templates.replaceRange(0, templates.length, templateSource.values.toList()); + void update() => templates.replaceRange(0, templates.length, templateSource.values.toList()); @action Future addTemplate({ - required String amount, - required String depositCurrency, - required String receiveCurrency, - required String provider, - required String depositAddress, - required String receiveAddress}) async { + required String amount, + required String depositCurrency, + required String receiveCurrency, + required String provider, + required String depositAddress, + required String receiveAddress, + required String depositCurrencyTitle, + required String receiveCurrencyTitle, + }) async { final template = ExchangeTemplate( amountRaw: amount, depositCurrencyRaw: depositCurrency, receiveCurrencyRaw: receiveCurrency, providerRaw: provider, depositAddressRaw: depositAddress, - receiveAddressRaw: receiveAddress); + receiveAddressRaw: receiveAddress, + depositCurrencyTitleRaw: depositCurrencyTitle, + receiveCurrencyTitleRaw: receiveCurrencyTitle); await templateSource.add(template); } @action - Future remove({required ExchangeTemplate template}) async => await template.delete(); -} \ No newline at end of file + Future remove({required ExchangeTemplate template}) async => await template.delete(); +} diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 1e25f1353..3c016d4b0 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -578,14 +578,18 @@ abstract class ExchangeViewModelBase with Store { required String receiveCurrency, required String provider, required String depositAddress, - required String receiveAddress}) => + required String receiveAddress, + required String depositCurrencyTitle, + required String receiveCurrencyTitle}) => _exchangeTemplateStore.addTemplate( amount: amount, depositCurrency: depositCurrency, receiveCurrency: receiveCurrency, provider: provider, depositAddress: depositAddress, - receiveAddress: receiveAddress); + receiveAddress: receiveAddress, + depositCurrencyTitle: depositCurrencyTitle, + receiveCurrencyTitle: receiveCurrencyTitle); void removeTemplate({required ExchangeTemplate template}) => _exchangeTemplateStore.remove(template: template);