diff --git a/lib/src/screens/wallet_unlock/wallet_unlock_page.dart b/lib/src/screens/wallet_unlock/wallet_unlock_page.dart index 958bdfcc3..abec4a42e 100644 --- a/lib/src/screens/wallet_unlock/wallet_unlock_page.dart +++ b/lib/src/screens/wallet_unlock/wallet_unlock_page.dart @@ -84,6 +84,8 @@ class WalletUnlockPageState extends AuthPageState { _passwordController.removeListener(_passwordControllerListener!); } + _passwordController.dispose(); + super.dispose(); } @@ -105,6 +107,26 @@ class WalletUnlockPageState extends AuthPageState { }); } + Future _unlockWallet() async { + if (widget.walletUnlockViewModel.state is IsExecutingState) { + return; + } + + FocusScope.of(context).unfocus(); + + if (widget.authPasswordHandler != null) { + try { + await widget.authPasswordHandler!(widget.walletUnlockViewModel.password); + widget.walletUnlockViewModel.success(); + } catch (e) { + widget.walletUnlockViewModel.failure(e); + } + return; + } + + await widget.walletUnlockViewModel.unlock(); + } + @override Future close({String? route, arguments}) async { if (_key.currentContext == null) { @@ -176,6 +198,9 @@ class WalletUnlockPageState extends AuthPageState { child: BaseTextFormField( key: ValueKey('enter_wallet_password'), onChanged: (value) => null, + onSubmit: (_) async { + await _unlockWallet(); + }, controller: _passwordController, textAlign: TextAlign.center, obscureText: true, @@ -187,7 +212,7 @@ class WalletUnlockPageState extends AuthPageState { fontSize: 18.0, fontWeight: FontWeight.w500, color: Theme.of(context).colorScheme.onSurfaceVariant, - ), + ), hintText: S.of(context).enter_wallet_password, ), ), @@ -199,19 +224,7 @@ class WalletUnlockPageState extends AuthPageState { padding: EdgeInsets.only(bottom: 24), child: Observer( builder: (_) => LoadingPrimaryButton( - onPressed: () async { - if (widget.authPasswordHandler != null) { - try { - await widget.authPasswordHandler!(widget.walletUnlockViewModel.password); - widget.walletUnlockViewModel.success(); - } catch (e) { - widget.walletUnlockViewModel.failure(e); - } - return; - } - - widget.walletUnlockViewModel.unlock(); - }, + onPressed: _unlockWallet, text: S.of(context).unlock, color: Theme.of(context).colorScheme.primary, textColor: Theme.of(context).colorScheme.onPrimary, diff --git a/lib/src/widgets/base_text_form_field.dart b/lib/src/widgets/base_text_form_field.dart index e605a83f2..f6402bea0 100644 --- a/lib/src/widgets/base_text_form_field.dart +++ b/lib/src/widgets/base_text_form_field.dart @@ -121,7 +121,7 @@ class BaseTextFormField extends StatelessWidget { inputFormatters: inputFormatters, enabled: enabled, maxLength: maxLength, - onFieldSubmitted: onSubmit, + onFieldSubmitted: onFieldSubmitted ?? onSubmit, style: textStyle ?? Theme.of(context).textTheme.bodyMedium!.copyWith( fontSize: 16.0, color: textColor ?? Theme.of(context).colorScheme.onSurface),