CAKE-20 | fixed address validators of the base exchange widget

This commit is contained in:
Oleksandr Sobol 2020-07-31 21:47:42 +03:00
parent b2f590ee4b
commit 861a2840ce
3 changed files with 11 additions and 23 deletions

View file

@ -20,9 +20,7 @@ class DashboardPage extends BasePage {
DashboardPage({ DashboardPage({
@required this.walletViewModel, @required this.walletViewModel,
@required this.addressListViewModel, @required this.addressListViewModel,
}) { });
walletViewModel.pageViewStore.setCurrentPage(1);
}
@override @override
Color get backgroundLightColor => PaletteDark.backgroundColor; Color get backgroundLightColor => PaletteDark.backgroundColor;

View file

@ -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/top_panel.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.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/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 { class BaseExchangeWidget extends StatefulWidget {
BaseExchangeWidget({ BaseExchangeWidget({
@ -112,8 +114,10 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
imageArrow: arrowBottomPurple, imageArrow: arrowBottomPurple,
currencyButtonColor: PaletteDark.wildVioletBlue, currencyButtonColor: PaletteDark.wildVioletBlue,
addressButtonsColor: PaletteDark.moderateBlue, addressButtonsColor: PaletteDark.moderateBlue,
currencyValueValidator: exchangeViewModel.amountValidator, currencyValueValidator: AmountValidator(
addressTextFieldValidator: exchangeViewModel.addressValidator, type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator(
type: exchangeViewModel.depositCurrency),
), ),
) )
), ),
@ -138,8 +142,10 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
imageArrow: arrowBottomCakeGreen, imageArrow: arrowBottomCakeGreen,
currencyButtonColor: PaletteDark.darkNightBlue, currencyButtonColor: PaletteDark.darkNightBlue,
addressButtonsColor: PaletteDark.moderateBlue, addressButtonsColor: PaletteDark.moderateBlue,
currencyValueValidator: exchangeViewModel.amountValidator, currencyValueValidator: AmountValidator(
addressTextFieldValidator: exchangeViewModel.addressValidator, type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator(
type: exchangeViewModel.receiveCurrency),
)), )),
) )
], ],

View file

@ -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/core/wallet_base.dart';
import 'package:cake_wallet/src/domain/common/crypto_currency.dart'; import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart'; import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
@ -91,22 +87,10 @@ abstract class ExchangeViewModelBase with Store {
@observable @observable
bool isReceiveAddressEnabled; bool isReceiveAddressEnabled;
@observable
bool isValid;
@observable
String errorMessage;
Limits limits; Limits limits;
NumberFormat _cryptoNumberFormat; NumberFormat _cryptoNumberFormat;
Validator get amountValidator => AmountValidator(type: wallet.type);
Validator get addressValidator => AddressValidator(type: wallet.currency);
Validator get templateValidator => TemplateValidator();
@computed @computed
ObservableList<ExchangeTemplate> get templates => ObservableList<ExchangeTemplate> get templates =>
exchangeTemplateStore.templates; exchangeTemplateStore.templates;