From d50cd6b61476fd2c9db83ee988b53b4f549a16e1 Mon Sep 17 00:00:00 2001 From: Ryszard Schossler <51096731+LynxLynxx@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:27:12 +0100 Subject: [PATCH] refactor(cat-voices): submit text on enter key (#1122) * feat: add unlock functionality to password input in unlock keychain dialog * feat: integrate onUnlock callback for password submission * fix: change order of the params --------- Co-authored-by: Dominik Toton <166132265+dtscalac@users.noreply.github.com> --- .../voices/lib/pages/account/unlock_keychain_dialog.dart | 4 ++++ .../lib/widgets/text_field/voices_password_text_field.dart | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/catalyst_voices/apps/voices/lib/pages/account/unlock_keychain_dialog.dart b/catalyst_voices/apps/voices/lib/pages/account/unlock_keychain_dialog.dart index 8812248be0c..2c3b3385e45 100644 --- a/catalyst_voices/apps/voices/lib/pages/account/unlock_keychain_dialog.dart +++ b/catalyst_voices/apps/voices/lib/pages/account/unlock_keychain_dialog.dart @@ -128,6 +128,7 @@ class _UnlockPasswordPanel extends StatelessWidget { _UnlockPassword( controller: controller, error: error, + onUnlock: onUnlock, ), const Spacer(), _Navigation( @@ -142,10 +143,12 @@ class _UnlockPasswordPanel extends StatelessWidget { class _UnlockPassword extends StatelessWidget { final TextEditingController controller; final LocalizedException? error; + final VoidCallback onUnlock; const _UnlockPassword({ required this.controller, required this.error, + required this.onUnlock, }); @override @@ -157,6 +160,7 @@ class _UnlockPassword extends StatelessWidget { errorText: error?.message(context), hintText: context.l10n.passwordLabelText, ), + onSubmitted: (val) => onUnlock(), ); } } diff --git a/catalyst_voices/apps/voices/lib/widgets/text_field/voices_password_text_field.dart b/catalyst_voices/apps/voices/lib/widgets/text_field/voices_password_text_field.dart index e2313703226..e7c20a7810b 100644 --- a/catalyst_voices/apps/voices/lib/widgets/text_field/voices_password_text_field.dart +++ b/catalyst_voices/apps/voices/lib/widgets/text_field/voices_password_text_field.dart @@ -13,6 +13,9 @@ final class VoicesPasswordTextField extends StatelessWidget { /// Emits new value when widget input changes. final ValueChanged? onChanged; + /// Calls event to end some actions using for example enter key + final ValueChanged? onSubmitted; + /// Optional decoration. See [VoicesTextField] for more details. final VoicesTextFieldDecoration? decoration; @@ -21,6 +24,7 @@ final class VoicesPasswordTextField extends StatelessWidget { this.controller, this.textInputAction = TextInputAction.done, this.onChanged, + this.onSubmitted, this.decoration, }); @@ -32,6 +36,7 @@ final class VoicesPasswordTextField extends StatelessWidget { obscureText: true, textInputAction: textInputAction, onChanged: onChanged, + onFieldSubmitted: onSubmitted, decoration: decoration, inputFormatters: [ FilteringTextInputFormatter.singleLineFormatter,