diff --git a/lib/src/screens/ionia/auth/ionia_create_account_page.dart b/lib/src/screens/ionia/auth/ionia_create_account_page.dart index 30a58850e..7f45acb82 100644 --- a/lib/src/screens/ionia/auth/ionia_create_account_page.dart +++ b/lib/src/screens/ionia/auth/ionia_create_account_page.dart @@ -66,6 +66,7 @@ class IoniaCreateAccountPage extends BasePage { validator: EmailValidator(), keyboardType: TextInputType.emailAddress, controller: _emailController, + onSubmit: (_) => _createAccount(), ), ), bottomSectionPadding: EdgeInsets.symmetric(vertical: 36, horizontal: 24), @@ -77,12 +78,7 @@ class IoniaCreateAccountPage extends BasePage { Observer( builder: (_) => LoadingPrimaryButton( text: S.of(context).create_account, - onPressed: () async { - if (_formKey.currentState != null && !_formKey.currentState!.validate()) { - return; - } - await _authViewModel.createUser(_emailController.text); - }, + onPressed: _createAccount, isLoading: _authViewModel.createUserState is IoniaCreateStateLoading, color: Theme.of(context).accentTextTheme!.bodyText1!.color!, textColor: Colors.white, @@ -151,4 +147,11 @@ class IoniaCreateAccountPage extends BasePage { Routes.ioniaVerifyIoniaOtpPage, arguments: [authViewModel.email, false], ); + + void _createAccount() async { + if (_formKey.currentState != null && !_formKey.currentState!.validate()) { + return; + } + await _authViewModel.createUser(_emailController.text); + } } diff --git a/lib/src/screens/ionia/auth/ionia_login_page.dart b/lib/src/screens/ionia/auth/ionia_login_page.dart index 6dc4aa6e5..e6e8680f3 100644 --- a/lib/src/screens/ionia/auth/ionia_login_page.dart +++ b/lib/src/screens/ionia/auth/ionia_login_page.dart @@ -57,6 +57,7 @@ class IoniaLoginPage extends BasePage { keyboardType: TextInputType.emailAddress, validator: EmailValidator(), controller: _emailController, + onSubmit: (text) => _login(), ), ), bottomSectionPadding: EdgeInsets.symmetric(vertical: 36, horizontal: 24), @@ -68,12 +69,7 @@ class IoniaLoginPage extends BasePage { Observer( builder: (_) => LoadingPrimaryButton( text: S.of(context).login, - onPressed: () async { - if (_formKey.currentState != null && !_formKey.currentState!.validate()) { - return; - } - await _authViewModel.signIn(_emailController.text); - }, + onPressed: _login, isLoading: _authViewModel.signInState is IoniaCreateStateLoading, color: Theme.of(context).accentTextTheme!.bodyText1!.color!, textColor: Colors.white, @@ -106,4 +102,11 @@ class IoniaLoginPage extends BasePage { Routes.ioniaVerifyIoniaOtpPage, arguments: [authViewModel.email, true], ); + + void _login() async { + if (_formKey.currentState != null && !_formKey.currentState!.validate()) { + return; + } + await _authViewModel.signIn(_emailController.text); + } } diff --git a/lib/src/screens/ionia/auth/ionia_verify_otp_page.dart b/lib/src/screens/ionia/auth/ionia_verify_otp_page.dart index 625bd36b0..e2123e164 100644 --- a/lib/src/screens/ionia/auth/ionia_verify_otp_page.dart +++ b/lib/src/screens/ionia/auth/ionia_verify_otp_page.dart @@ -82,6 +82,7 @@ class IoniaVerifyIoniaOtp extends BasePage { keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true), focusNode: _codeFocus, controller: _codeController, + onSubmit: (_) => _verify(), ), SizedBox(height: 14), Text( @@ -116,7 +117,7 @@ class IoniaVerifyIoniaOtp extends BasePage { Observer( builder: (_) => LoadingPrimaryButton( text: S.of(context).continue_text, - onPressed: () async => await _authViewModel.verifyEmail(_codeController.text), + onPressed: _verify, isDisabled: _authViewModel.otpState is IoniaOtpSendDisabled, isLoading: _authViewModel.otpState is IoniaOtpValidating, color: Theme.of(context).accentTextTheme!.bodyText1!.color!, @@ -148,4 +149,6 @@ class IoniaVerifyIoniaOtp extends BasePage { void _onOtpSuccessful(BuildContext context) => Navigator.of(context) .pushNamedAndRemoveUntil(Routes.ioniaManageCardsPage, (route) => route.isFirst); + + void _verify() async => await _authViewModel.verifyEmail(_codeController.text); } diff --git a/lib/src/widgets/base_text_form_field.dart b/lib/src/widgets/base_text_form_field.dart index 19d43e9c2..6c29f79ea 100644 --- a/lib/src/widgets/base_text_form_field.dart +++ b/lib/src/widgets/base_text_form_field.dart @@ -27,6 +27,7 @@ class BaseTextFormField extends StatelessWidget { this.maxLength, this.focusNode, this.initialValue, + this.onSubmit, this.borderWidth = 1.0}); final TextEditingController? controller; @@ -54,6 +55,7 @@ class BaseTextFormField extends StatelessWidget { final bool? enableInteractiveSelection; final String? initialValue; final double borderWidth; + final void Function(String)? onSubmit; @override Widget build(BuildContext context) { @@ -71,6 +73,7 @@ class BaseTextFormField extends StatelessWidget { inputFormatters: inputFormatters, enabled: enabled, maxLength: maxLength, + onFieldSubmitted: onSubmit, style: textStyle ?? TextStyle( fontSize: 16.0,