Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ abstract class AuthenticatorInputLocalizations {
/// In en, this message translates to:
/// **'Please enter the code from your registered Authenticator app'**
String get totpCodePrompt;

/// Tooltip for the button to show the password when it is currently hidden.
///
/// In en, this message translates to:
/// **'Show password'**
String get showPassword;

/// Tooltip for the button to hide the password when it is currently visible.
///
/// In en, this message translates to:
/// **'Hide password'**
String get hidePassword;
}

class _AuthenticatorInputLocalizationsDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,10 @@ class AuthenticatorInputLocalizationsEn
@override
String get totpCodePrompt =>
'Please enter the code from your registered Authenticator app';

@override
String get showPassword => 'Show password';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be generated from the ARB file inputs_en.arb, which should be checked in


@override
String get hidePassword => 'Hide password';
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enum InputResolverKeyType {
passwordRequirements,
format,
mismatch,
showPasswordTooltip,
hidePasswordTooltip,
}

class InputResolverKey {
Expand Down Expand Up @@ -388,6 +390,16 @@ class InputResolverKey {
field: InputField.usernameType,
);

static const showPasswordTooltip = InputResolverKey._(
InputResolverKeyType.showPasswordTooltip,
field: InputField.password,
);

static const hidePasswordTooltip = InputResolverKey._(
InputResolverKeyType.hidePasswordTooltip,
field: InputField.password,
);

String resolve(BuildContext context, InputResolver inputResolver) =>
inputResolver.resolve(context, this);
}
Expand Down Expand Up @@ -552,6 +564,16 @@ class InputResolver extends Resolver<InputResolverKey> {
return AuthenticatorLocalizations.inputsOf(context).optional(title);
}

/// Returns the tooltip text for showing a hidden password.
String showPasswordTooltip(BuildContext context) {
return AuthenticatorLocalizations.inputsOf(context).showPassword;
}

/// Returns the tooltip text for hiding a visible password.
String hidePasswordTooltip(BuildContext context) {
return AuthenticatorLocalizations.inputsOf(context).hidePassword;
}

@override
String resolve(BuildContext context, InputResolverKey key) {
switch (key.type) {
Expand All @@ -571,6 +593,10 @@ class InputResolver extends Resolver<InputResolverKey> {
return AuthenticatorLocalizations.inputsOf(context).passwordsDoNotMatch;
case InputResolverKeyType.format:
return format(context, key.field);
case InputResolverKeyType.showPasswordTooltip:
return showPasswordTooltip(context);
case InputResolverKeyType.hidePasswordTooltip:
return hidePasswordTooltip(context);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ mixin AuthenticatorTextField<
suffixIcon: suffix,
errorMaxLines: errorMaxLines,
hintText: hintText,
// Workaround for Flutter issue where validation errors are not
// announced by screen readers on web unless helperText is set.
// See: https://github.com/flutter/flutter/issues/99715
helperText: ' ',
),
maxLength: maxLength,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ MaterialBanner createMaterialBanner(
key: keyAuthenticatorBanner,
backgroundColor: colorsChoices.background,
leading: Icon(type.icon, color: colorsChoices.foreground),
content: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
message.trim(),
style: TextStyle(color: colorsChoices.foreground),
content: Semantics(
liveRegion: true,
child: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
message.trim(),
style: TextStyle(color: colorsChoices.foreground),
),
),
),
],
],
),
),
),
actions: [
Expand Down Expand Up @@ -70,18 +73,21 @@ SnackBar createSnackBar(
return SnackBar(
key: keyAuthenticatorBanner,
backgroundColor: colorsChoices.background,
content: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(type.icon, color: fallbackIconColor),
const SizedBox(width: 16),
Expanded(
child: Text(
message.trim(),
style: TextStyle(color: colorsChoices.foreground),
content: Semantics(
liveRegion: true,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(type.icon, color: fallbackIconColor),
const SizedBox(width: 16),
Expanded(
child: Text(
message.trim(),
style: TextStyle(color: colorsChoices.foreground),
),
),
),
],
],
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ class AuthenticatorFormState<T extends AuthenticatorForm>
return ValueListenableBuilder<bool>(
valueListenable: obscureTextToggleValue,
builder: (BuildContext context, bool toggleObscureText, Widget? _) {
final inputResolver = stringResolver.inputs;
return IconButton(
onPressed: () {
obscureTextToggleValue.value = !toggleObscureText;
},
icon: Icon(
toggleObscureText ? Icons.visibility : Icons.visibility_off,
),
tooltip: toggleObscureText
? inputResolver.showPasswordTooltip(context)
: inputResolver.hidePasswordTooltip(context),
);
},
);
Expand Down
Loading