From 861a2840ce4fdc031931392fd1b4075a4ce3d27f Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Fri, 31 Jul 2020 21:47:42 +0300 Subject: [PATCH] CAKE-20 | fixed address validators of the base exchange widget --- lib/src/screens/dashboard/dashboard_page.dart | 4 +--- .../exchange/widgets/base_exchange_widget.dart | 14 ++++++++++---- lib/view_model/exchange/exchange_view_model.dart | 16 ---------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 9ca629c4d..7623891f4 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -20,9 +20,7 @@ class DashboardPage extends BasePage { DashboardPage({ @required this.walletViewModel, @required this.addressListViewModel, - }) { - walletViewModel.pageViewStore.setCurrentPage(1); - } + }); @override Color get backgroundLightColor => PaletteDark.backgroundColor; diff --git a/lib/src/screens/exchange/widgets/base_exchange_widget.dart b/lib/src/screens/exchange/widgets/base_exchange_widget.dart index 57a24a162..cde58e226 100644 --- a/lib/src/screens/exchange/widgets/base_exchange_widget.dart +++ b/lib/src/screens/exchange/widgets/base_exchange_widget.dart @@ -20,6 +20,8 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/top_panel.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; +import 'package:cake_wallet/core/address_validator.dart'; +import 'package:cake_wallet/core/amount_validator.dart'; class BaseExchangeWidget extends StatefulWidget { BaseExchangeWidget({ @@ -112,8 +114,10 @@ class BaseExchangeWidgetState extends State { imageArrow: arrowBottomPurple, currencyButtonColor: PaletteDark.wildVioletBlue, addressButtonsColor: PaletteDark.moderateBlue, - currencyValueValidator: exchangeViewModel.amountValidator, - addressTextFieldValidator: exchangeViewModel.addressValidator, + currencyValueValidator: AmountValidator( + type: exchangeViewModel.wallet.type), + addressTextFieldValidator: AddressValidator( + type: exchangeViewModel.depositCurrency), ), ) ), @@ -138,8 +142,10 @@ class BaseExchangeWidgetState extends State { imageArrow: arrowBottomCakeGreen, currencyButtonColor: PaletteDark.darkNightBlue, addressButtonsColor: PaletteDark.moderateBlue, - currencyValueValidator: exchangeViewModel.amountValidator, - addressTextFieldValidator: exchangeViewModel.addressValidator, + currencyValueValidator: AmountValidator( + type: exchangeViewModel.wallet.type), + addressTextFieldValidator: AddressValidator( + type: exchangeViewModel.receiveCurrency), )), ) ], diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 0383338e8..4fb5a1dbf 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -1,7 +1,3 @@ -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/src/domain/common/crypto_currency.dart'; import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart'; @@ -91,22 +87,10 @@ abstract class ExchangeViewModelBase with Store { @observable bool isReceiveAddressEnabled; - @observable - bool isValid; - - @observable - String errorMessage; - Limits limits; NumberFormat _cryptoNumberFormat; - Validator get amountValidator => AmountValidator(type: wallet.type); - - Validator get addressValidator => AddressValidator(type: wallet.currency); - - Validator get templateValidator => TemplateValidator(); - @computed ObservableList get templates => exchangeTemplateStore.templates;