feat(984): enable Enter key submission on desktop wallet unlock (#3137)

This commit is contained in:
Manuel Reschke
2026-03-27 16:57:46 +01:00
committed by GitHub
parent ba9e8d7b7f
commit fa0acbf749
2 changed files with 28 additions and 15 deletions
@@ -84,6 +84,8 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
_passwordController.removeListener(_passwordControllerListener!);
}
_passwordController.dispose();
super.dispose();
}
@@ -105,6 +107,26 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
});
}
Future<void> _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<void> close({String? route, arguments}) async {
if (_key.currentContext == null) {
@@ -176,6 +198,9 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
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<WalletUnlockPage> {
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<WalletUnlockPage> {
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,
+1 -1
View File
@@ -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),