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

Manuel Reschke committed Mar 27, 2026 at 16:57 UTC fa0acbf749e730139217351e05f3416914ab4580
2 files changed +28 -15
lib/src/screens/wallet_unlock/wallet_unlock_page.dart
+27 -14
@@ -84,6 +84,8 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
84 _passwordController.removeListener(_passwordControllerListener!);
85 }
86
87 + _passwordController.dispose();
88 +
89 super.dispose();
90 }
91
@@ -105,6 +107,26 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
107 });
108 }
109
110 + Future<void> _unlockWallet() async {
111 + if (widget.walletUnlockViewModel.state is IsExecutingState) {
112 + return;
113 + }
114 +
115 + FocusScope.of(context).unfocus();
116 +
117 + if (widget.authPasswordHandler != null) {
118 + try {
119 + await widget.authPasswordHandler!(widget.walletUnlockViewModel.password);
120 + widget.walletUnlockViewModel.success();
121 + } catch (e) {
122 + widget.walletUnlockViewModel.failure(e);
123 + }
124 + return;
125 + }
126 +
127 + await widget.walletUnlockViewModel.unlock();
128 + }
129 +
130 @override
131 Future<void> close({String? route, arguments}) async {
132 if (_key.currentContext == null) {
@@ -176,6 +198,9 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
198 child: BaseTextFormField(
199 key: ValueKey('enter_wallet_password'),
200 onChanged: (value) => null,
201 + onSubmit: (_) async {
202 + await _unlockWallet();
203 + },
204 controller: _passwordController,
205 textAlign: TextAlign.center,
206 obscureText: true,
@@ -187,7 +212,7 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
212 fontSize: 18.0,
213 fontWeight: FontWeight.w500,
214 color: Theme.of(context).colorScheme.onSurfaceVariant,
190 - ),
215 + ),
216 hintText: S.of(context).enter_wallet_password,
217 ),
218 ),
@@ -199,19 +224,7 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
224 padding: EdgeInsets.only(bottom: 24),
225 child: Observer(
226 builder: (_) => LoadingPrimaryButton(
202 - onPressed: () async {
203 - if (widget.authPasswordHandler != null) {
204 - try {
205 - await widget.authPasswordHandler!(widget.walletUnlockViewModel.password);
206 - widget.walletUnlockViewModel.success();
207 - } catch (e) {
208 - widget.walletUnlockViewModel.failure(e);
209 - }
210 - return;
211 - }
212 -
213 - widget.walletUnlockViewModel.unlock();
214 - },
227 + onPressed: _unlockWallet,
228 text: S.of(context).unlock,
229 color: Theme.of(context).colorScheme.primary,
230 textColor: Theme.of(context).colorScheme.onPrimary,
lib/src/widgets/base_text_form_field.dart
+1 -1
@@ -121,7 +121,7 @@ class BaseTextFormField extends StatelessWidget {
121 inputFormatters: inputFormatters,
122 enabled: enabled,
123 maxLength: maxLength,
124 - onFieldSubmitted: onSubmit,
124 + onFieldSubmitted: onFieldSubmitted ?? onSubmit,
125 style: textStyle ??
126 Theme.of(context).textTheme.bodyMedium!.copyWith(
127 fontSize: 16.0, color: textColor ?? Theme.of(context).colorScheme.onSurface),