Skip to content

Commit

Permalink
Merge branch 'authenticator/fix-confirm-password-hint' of github.com:…
Browse files Browse the repository at this point in the history
…Jordan-Nelson/amplify-flutter into authenticator/fix-confirm-password-hint
  • Loading branch information
Jordan-Nelson committed Nov 20, 2021
2 parents 60b0cae + b0a6db7 commit 357d22e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ abstract class AuthenticatorInputLocalizations {
/// **'New Password'**
String get newPassword;

/// Confirmation of user's chosen password.
///
/// In en, this message translates to:
/// **'Confirm Password'**
String get passwordConfirmation;

/// User's preferred e-mail address.
///
/// In en, this message translates to:
Expand Down Expand Up @@ -240,6 +234,12 @@ abstract class AuthenticatorInputLocalizations {
/// **'Re-enter your {attribute}'**
String promptRefill(String attribute);

/// Title to re-enter an optional or required input field, used as the label for text fields.
///
/// In en, this message translates to:
/// **'Confirm {attribute}'**
String confirmAttribute(String attribute);

/// Preamble to list of unment password requirements.
///
/// In en, this message translates to:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class AuthenticatorInputLocalizationsEn
@override
String get newPassword => 'New Password';

@override
String get passwordConfirmation => 'Confirm Password';

@override
String get email => 'Email';

Expand Down Expand Up @@ -103,6 +100,11 @@ class AuthenticatorInputLocalizationsEn
return 'Re-enter your $attribute';
}

@override
String confirmAttribute(String attribute) {
return 'Confirm $attribute';
}

@override
String get passwordRequirementsPreamble => 'Password must include:';

Expand Down
20 changes: 14 additions & 6 deletions packages/amplify_authenticator/lib/src/l10n/input_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum InputField {
enum InputResolverKeyType {
title,
hint,
confirmHint,
empty,
passwordRequirements,
format,
Expand Down Expand Up @@ -99,7 +100,7 @@ class InputResolverKey {
field: InputField.passwordConfirmation,
);
static const passwordConfirmationHint = InputResolverKey._(
InputResolverKeyType.hint,
InputResolverKeyType.confirmHint,
field: InputField.passwordConfirmation,
);
static const passwordConfirmationEmpty = InputResolverKey._(
Expand Down Expand Up @@ -371,8 +372,10 @@ class InputResolver extends Resolver<InputResolverKey> {
case InputField.newPassword:
return AuthenticatorLocalizations.inputsOf(context).newPassword;
case InputField.passwordConfirmation:
final attributeName =
AuthenticatorLocalizations.inputsOf(context).password;
return AuthenticatorLocalizations.inputsOf(context)
.passwordConfirmation;
.confirmAttribute(attributeName);
case InputField.verificationCode:
return AuthenticatorLocalizations.inputsOf(context).verificationCode;
case InputField.address:
Expand Down Expand Up @@ -419,14 +422,17 @@ class InputResolver extends Resolver<InputResolverKey> {
String hint(BuildContext context, InputField field) {
final fieldName = title(context, field);
final lowercasedFieldName = fieldName.toLowerCase();
if (field == InputField.passwordConfirmation) {
return AuthenticatorLocalizations.inputsOf(context)
.promptRefill(lowercasedFieldName);
}
return AuthenticatorLocalizations.inputsOf(context)
.promptFill(lowercasedFieldName);
}

String confirmHint(BuildContext context, InputField field) {
final fieldName = AuthenticatorLocalizations.inputsOf(context).password;
final lowercasedFieldName = fieldName.toLowerCase();
return AuthenticatorLocalizations.inputsOf(context)
.promptRefill(lowercasedFieldName);
}

String empty(BuildContext context, InputField field) {
return AuthenticatorLocalizations.inputsOf(context)
.warnEmpty(title(context, field));
Expand Down Expand Up @@ -478,6 +484,8 @@ class InputResolver extends Resolver<InputResolverKey> {
return title(context, key.field);
case InputResolverKeyType.hint:
return hint(context, key.field);
case InputResolverKeyType.confirmHint:
return confirmHint(context, key.field);
case InputResolverKeyType.empty:
return empty(context, key.field);
case InputResolverKeyType.passwordRequirements:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
"@newPassword": {
"description": "User's chosen new password."
},
"passwordConfirmation": "Confirm Password",
"@passwordConfirmation": {
"description": "Confirmation of user's chosen password."
},
"email": "Email",
"@email": {
"description": "User's preferred e-mail address.",
Expand Down Expand Up @@ -140,6 +136,17 @@
}
}
},
"confirmAttribute": "Confirm {attribute}",
"@confirmAttribute": {
"description": "Title to re-enter an optional or required input field, used as the label for text fields.",
"placeholders": {
"attribute": {
"type": "String",
"example": "username",
"description": "The field which can be filled."
}
}
},
"passwordRequirementsPreamble": "Password must include:",
"@passwordRequirementsPreamble": {
"description": "Preamble to list of unment password requirements."
Expand Down

0 comments on commit 357d22e

Please sign in to comment.