Skip to content

Commit

Permalink
refactor(cat-voices): submit text on enter key (#1122)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
LynxLynxx and dtscalac authored Nov 5, 2024
1 parent ad8e75e commit d50cd6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class _UnlockPasswordPanel extends StatelessWidget {
_UnlockPassword(
controller: controller,
error: error,
onUnlock: onUnlock,
),
const Spacer(),
_Navigation(
Expand All @@ -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
Expand All @@ -157,6 +160,7 @@ class _UnlockPassword extends StatelessWidget {
errorText: error?.message(context),
hintText: context.l10n.passwordLabelText,
),
onSubmitted: (val) => onUnlock(),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ final class VoicesPasswordTextField extends StatelessWidget {
/// Emits new value when widget input changes.
final ValueChanged<String>? onChanged;

/// Calls event to end some actions using for example enter key
final ValueChanged<String>? onSubmitted;

/// Optional decoration. See [VoicesTextField] for more details.
final VoicesTextFieldDecoration? decoration;

Expand All @@ -21,6 +24,7 @@ final class VoicesPasswordTextField extends StatelessWidget {
this.controller,
this.textInputAction = TextInputAction.done,
this.onChanged,
this.onSubmitted,
this.decoration,
});

Expand All @@ -32,6 +36,7 @@ final class VoicesPasswordTextField extends StatelessWidget {
obscureText: true,
textInputAction: textInputAction,
onChanged: onChanged,
onFieldSubmitted: onSubmitted,
decoration: decoration,
inputFormatters: [
FilteringTextInputFormatter.singleLineFormatter,
Expand Down

0 comments on commit d50cd6b

Please sign in to comment.