Skip to content

Commit

Permalink
feat: ✨ translating auth screens
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusamelio committed Jul 5, 2024
1 parent cdadc93 commit ea2b822
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 21 deletions.
39 changes: 21 additions & 18 deletions lib/contexts/auth/presentation/screens/password_recovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
if (loading) {
ConfirmSnack(
leadingIcon: const Icon(HeroiconsMini.circleStack),
message: "Carregando",
message: translations.loading,
onConfirm: () {});
}

Expand All @@ -77,14 +77,14 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
children: [
_RecoveryPageTemplate(
loading: loading,
buttonText: "Próximo",
buttonText: translations.next,
onValidate: () => controller.sendEmail(
email: emailController.text,
),
formKey: formKey,
children: [
BaseInput(
label: "E-mail",
label: translations.email,
validator: (value) => email(value ?? ""),
controller: emailController,
type: TextInputType.emailAddress,
Expand All @@ -93,14 +93,14 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
),
_RecoveryPageTemplate(
loading: loading,
buttonText: "Próximo",
buttonText: translations.next,
onValidate: () => controller.checkCode(
code: code.text,
),
formKey: formKey,
children: [
BaseInput(
label: "Código",
label: translations.code,
validator: (value) => minLength(value ?? "", 6),
controller: code,
type: TextInputType.number,
Expand All @@ -109,14 +109,14 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
),
_RecoveryPageTemplate(
loading: loading,
buttonText: "Enviar",
buttonText: translations.send,
onValidate: () => controller.changePassword(
password: confirmPassword.text,
),
formKey: formKey,
children: [
BaseInput(
label: "Nova Senha",
label: translations.newPassword,
controller: password,
obscureText: true,
maxLines: 1,
Expand All @@ -125,18 +125,21 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
height: context.theme.spacingScheme.verticalSpacing,
),
BaseInput(
label: "Confirmar Nova Senha",
label: translations.confirmNewPassword,
controller: confirmPassword,
maxLines: 1,
obscureText: true,
validator: (value) {
if (value != password.text) {
return "As senhas não coincidem";
return translations.passwordsDoesntMatch;
}
return minLength(
value ?? "",
8,
message: "Senha deve ter no mínimo 8 caracteres",
message: translations.minValidation(
count: 8,
name: translations.password,
),
);
},
),
Expand All @@ -161,8 +164,8 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
);
},
onError: (left) {
const ErrorSnack(
message: "Deu ruim ao enviar o código",
ErrorSnack(
message: t.codeSendingError,
).show(context: context);
},
);
Expand All @@ -176,8 +179,8 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {
);
},
onError: (left) {
const ErrorSnack(
message: "Deu ruim ao confirmar o código",
ErrorSnack(
message: translations.codeConfirmingError,
).show(context: context);
},
);
Expand All @@ -187,14 +190,14 @@ class _PasswordRecoveryScreenState extends State<PasswordRecoveryScreen> {

Navigator.pushReplacementNamed(context, LoginScreen.routeName);
if (mounted) {
const SuccessSnack(
message: "Senha alterada",
SuccessSnack(
message: translations.passwordChangingSuccess,
).show(context: context);
}
},
onError: (left) {
const ErrorSnack(
message: "Deu ruim ao alterar sua senha",
ErrorSnack(
message: translations.passwordChangingError,
).show(context: context);
},
);
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import '../translations/locale_sync.dart';
import 'core.dart';

final translations = LocaleSync.of(navigatorKey.currentContext!);
final t = translations;
60 changes: 60 additions & 0 deletions lib/translations/base_localization.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,93 @@
// ignore_for_file: non_constant_identifier_names
abstract interface class BaseLocaleSyncLocalization {
const BaseLocaleSyncLocalization();

/// **Algo estranho aconteceu com o app** on pt language <br>
String get flutterInitErrorMessage;

/// **Reiniciar o app** on pt language <br>
String get flutterInitButton;

/// **Boas vindas ao #surpraise** on pt language <br>
String get welcome;

/// **Senha** on pt language <br>
String get password;

/// **E-mail** on pt language <br>
String get email;

/// **Esqueci minha senha** on pt language <br>
String get forgetPassword;

/// **Nome** on pt language <br>
String get name;

/// **Tag** on pt language <br>
String get tag;

/// **Seleciona sua foto de perfil** on pt language <br>
String get profilePictureLabel;

/// **Carregando...** on pt language <br>
String get signInLoading;

/// **Entrar** on pt language <br>
String get signIn;

/// **Ou entre com** on pt language <br>
String get orSignInWith;

/// **Não possui uma conta?** on pt language <br>
String get doesNotHaveAnAccount;

/// **Cadastre-se** on pt language <br>
String get signUp;

/// **Reset de senha** on pt language <br>
String get passwordReset;

/// **Carregando** on pt language <br>
String get loading;

/// **Próximo** on pt language <br>
String get next;

/// **Código** on pt language <br>
String get code;

/// **Enviar** on pt language <br>
String get send;

/// **Nova senha** on pt language <br>
String get newPassword;

/// **Confirmar nova senha** on pt language <br>
String get confirmNewPassword;

/// **As senhas não coincidem** on pt language <br>
String get passwordsDoesntMatch;

/// **{name} deve ter no mínimo 1 caracter** on pt language <br>
/// plural: **{name} deve ter no mínimo {count} caracteres** <br>
String minValidation({required int count, required String name});

/// **{name} deve ter no máximo um caracter** on pt language <br>
/// plural: **{name} deve ter no máximo {count} caracteres** <br>
String maxValidation({required int count, required String name});

/// **Deu ruim ao enviar o código** on pt language <br>
String get codeSendingError;

/// **Deu ruim ao confirmar o código** on pt language <br>
String get codeConfirmingError;

/// **Senha alterada** on pt language <br>
String get passwordChangingSuccess;

/// **Deu ruim ao alterar a senha** on pt language <br>
String get passwordChangingError;

/// **Crie sua conta** on pt language <br>
String get signupTitle;
}
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,10 @@ packages:
dependency: "direct main"
description:
name: locale_sync
sha256: "2eb70c15ff90d062a724ac139059c5b6b3d903637895775568e7ed4493d115d8"
sha256: e118c75c9a95ad7af98940e7c0a0e8f3688c789f1a241350e1e93821db557a85
url: "https://pub.dev"
source: hosted
version: "1.1.5"
version: "1.1.7"
logging:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dependencies:
animated_emoji: ^3.0.0
palette_generator: ^0.3.3+3
image_cropper: ^5.0.1
locale_sync: ^1.1.5
locale_sync: ^1.1.7

dev_dependencies:
faker: ^2.1.0
Expand Down

0 comments on commit ea2b822

Please sign in to comment.