Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion app/lib/main/app.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import 'package:app/presentation/resources/resources.dart';
import 'package:app/presentation/ui/custom/app_theme_switch.dart';
import 'package:flutter/material.dart';
import 'package:domain/bloc/app/app_cubit.dart';
import 'package:domain/bloc/app/app_state.dart';
import 'package:domain/bloc/auth/auth_cubit.dart';
import 'package:domain/models/app_lang.dart';
import 'package:app/presentation/navigation/routers.dart';
import 'package:app/presentation/resources/locale/generated/l10n.dart';
import 'package:app/presentation/themes/app_themes.dart';
import 'package:app/presentation/utils/lang_extensions.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb;
import 'package:app_links/app_links.dart';
import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'init.dart';

Expand Down Expand Up @@ -74,6 +78,7 @@ class _AppState extends State<App> {
: BlocBuilder<AppCubit, AppState>(
builder: (context, state) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
theme: AppThemes.getAppTheme(state.themeType).data,
locale: LangExtensions.langLocale[state.appLang],
supportedLocales: LangExtensions.supportedLang,
Expand Down
11 changes: 9 additions & 2 deletions app/lib/presentation/navigation/routers.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:app/main/init.dart';
import 'package:app/presentation/ui/pages/debug_banner.dart';
import 'package:app/presentation/ui/pages/main/home/home_page.dart';
import 'package:app/presentation/ui/pages/auth/login/login_page.dart';
import 'package:app/presentation/ui/pages/auth/sign_up/sign_up_page.dart';
import 'package:app/presentation/ui/pages/splash/splash_page.dart';
import 'package:common/core/resource.dart';
import 'package:domain/bloc/auth/auth_cubit.dart';
import 'package:domain/bloc/auth/auth_state.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -36,12 +38,15 @@ extension ContextOnRouter on BuildContext {
GoRouter get router => GoRouter.of(this);
}

final rootNavigatorKey = GlobalKey<NavigatorState>();

class Routers {
static GoRouter appRouter(
BuildContext context, {
String? initialLocation,
}) =>
GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: initialLocation ??
(getIt<AuthCubit>().isLoggedIn()
? Routes.app.path
Expand Down Expand Up @@ -85,7 +90,8 @@ class Routers {
},
routes: [
ShellRoute(
builder: (context, state, child) => child,
builder: (context, state, child) =>
kDebugMode ? DebugBanner(child: child) : child,
routes: [
GoRoute(
name: Routes.auth.name,
Expand All @@ -108,7 +114,8 @@ class Routers {
],
),
ShellRoute(
builder: (context, state, child) => child,
builder: (context, state, child) =>
kDebugMode ? DebugBanner(child: child) : child,
routes: [
GoRoute(
name: Routes.app.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class MessageLookup extends MessageLookupByLibrary {
),
"ctaLogin": MessageLookupByLibrary.simpleMessage("Login"),
"ctaSignUp": MessageLookupByLibrary.simpleMessage("Sign Up"),
"debugModeCancel": MessageLookupByLibrary.simpleMessage("Cancel"),
"debugModeConfirm": MessageLookupByLibrary.simpleMessage("Confirm"),
"debugModeLabel": MessageLookupByLibrary.simpleMessage("DEV MODE"),
"debugModeResetApp": MessageLookupByLibrary.simpleMessage("RESET APP"),
"debugModeResetAppMessage": MessageLookupByLibrary.simpleMessage(
"Are you sure you want to reset the app?",
),
"debugModeResetAppTitle": MessageLookupByLibrary.simpleMessage("Reset App"),
"errorEmailInvalid": MessageLookupByLibrary.simpleMessage(
"Please enter a valid email address.",
),
Expand Down
50 changes: 50 additions & 0 deletions app/lib/presentation/resources/locale/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion app/lib/presentation/resources/locale/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@
"errorEmailInvalid": "Please enter a valid email address.",
"errorPasswordWeak": "Password is too weak.",
"loginErrorInvalidCredentials": "Invalid email or password.",
"hintTermsAndConditions": "This should open the terms and conditions URL."
"hintTermsAndConditions": "This should open the terms and conditions URL.",
"debugModeLabel": "DEV MODE",
"debugModeResetApp": "RESET APP",
"debugModeResetAppTitle": "Reset App",
"debugModeResetAppMessage": "Are you sure you want to reset the app?",
"debugModeCancel": "Cancel",
"debugModeConfirm": "Confirm"
}
24 changes: 18 additions & 6 deletions app/lib/presentation/resources/locale/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@
"appName": "Flutter Target",
"cookiesTitle": "Este sitio web utiliza cookies",
"cookiesAcceptCTA": "Aceptar",
"cookiesBody": "Usamos cookies para personalizar el contenido y los anuncios, ofrecer funciones de redes sociales y analizar nuestro tráfico. También compartimos información sobre el uso de nuestro sitio con nuestros socios de redes sociales, publicidad y análisis, quienes pueden combinarla con otra información que les hayas proporcionado o que hayan recopilado a partir del uso de sus servicios.",
"cookiesBody": "Usamos cookies para personalizar el contenido y los anuncios, proporcionar funciones de redes sociales y analizar nuestro tráfico. También compartimos información sobre el uso que haces de nuestro sitio con nuestros socios de redes sociales, publicidad y análisis, quienes pueden combinarla con otra información que les hayas proporcionado o que hayan recopilado a partir del uso que haces de sus servicios.",
"noConnection": "Sin conexión",
"retry": "Reintentar",
"pleaseTryAgainLaterWeArenworkingToFixTheIssue": "Por favor, inténtalo más tarde,\nestamos trabajando para resolver el problema.",
"sorryWeDidntFindAnyProduct": "Lo sentimos, no hemos encontrado ningún producto",
"pleaseTryAgainLaterWeArenworkingToFixTheIssue": "Por favor intenta nuevamente más tarde,\nestamos trabajando para solucionar el problema.",
"sorryWeDidntFindAnyProduct": "Lo sentimos, no encontramos ningún producto",
"ctaLogin": "Iniciar sesión",
"ctaSignUp": "Registrarse",
"labelEmail": "Correo electrónico",
"labelPassword": "Contraseña",
"labelConfirmPassword": "Confirmar contraseña",
"errorPasswordsDoNotMatch": "Las contraseñas no coinciden.",
"passwordInstructions": "Mínimo 8 caracteres: 1 mayúscula, 1 minúscula, 1 número y 1 carácter especial.",
"labelAgreeToTerms": "Acepto los Términos y Condiciones",
"errorEmailRequired": "El correo electrónico es obligatorio.",
"errorPasswordRequired": "La contraseña es obligatoria.",
"titleLogin": "Iniciar sesión",
"titleLoginSubtitle": "Usa tu correo y contraseña para iniciar sesión en tu cuenta.",
"errorEmailInvalid": "Por favor ingresa una dirección de correo válida.",
"titleSignUp": "Registrarse",
"titleLoginSubtitle": "Usa tu correo electrónico y contraseña para iniciar sesión en tu cuenta.",
"titleSignUpSubtitle": "Crea una cuenta usando tu correo electrónico y contraseña.",
"errorEmailInvalid": "Por favor ingresa un correo electrónico válido.",
"errorPasswordWeak": "La contraseña es demasiado débil.",
"loginErrorInvalidCredentials": "Correo o contraseña inválidos."
"loginErrorInvalidCredentials": "Correo electrónico o contraseña incorrectos.",
"hintTermsAndConditions": "Esto debería abrir la URL de términos y condiciones.",
"debugModeLabel": "MODO DEV",
"debugModeResetApp": "RESETEAR APP",
"debugModeResetAppTitle": "Resetear App",
"debugModeResetAppMessage": "¿Estás seguro de que deseas resetear la aplicación?",
"debugModeCancel": "Cancelar",
"debugModeConfirm": "Confirmar"
}
9 changes: 9 additions & 0 deletions app/lib/presentation/themes/local_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ abstract class LocalTheme {
),
elevation: 10,
),
dialogTheme: DialogThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(themeData.borderRadius),
),
),
titleTextStyle: titleM.copyWith(color: colors.onSurface),
contentTextStyle: subtitleM.copyWith(color: colors.onSurface),
),
);

final primaryFont = 'Roboto Regular';
Expand Down
6 changes: 4 additions & 2 deletions app/lib/presentation/ui/custom/app_theme_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class AppThemeSwitch extends StatelessWidget {

return Switch(
value: theme == ThemeType.dark,
activeTrackColor: Colors.grey,
thumbIcon: const WidgetStatePropertyAll(Icon(Icons.brightness_6)),
onChanged: (value) {
context.read<AppCubit>().updateTheme(value ? ThemeType.dark : ThemeType.light);
context
.read<AppCubit>()
.updateTheme(value ? ThemeType.dark : ThemeType.light);
},
);
}
Expand Down
60 changes: 60 additions & 0 deletions app/lib/presentation/ui/custom/terms_services_check.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'package:app/presentation/resources/locale/generated/l10n.dart';
import 'package:app/presentation/resources/resources.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';

class TermsServicesCheck extends StatelessWidget {
final bool agreeToTerms;
final void Function(bool)? onChanged;

const TermsServicesCheck({
super.key,
this.agreeToTerms = false,
this.onChanged,
});

@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: TextButton(
style: Theme.of(context).textButtonTheme.style?.copyWith(
alignment: Alignment.centerLeft, // <-- important
padding: WidgetStateProperty.all(
EdgeInsets.zero,
), // optional, but helps
),
onPressed: () => onChanged?.call(!agreeToTerms),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Checkbox(
value: agreeToTerms,
onChanged: (value) => onChanged?.call(!agreeToTerms),
),
Expanded(
child: Text(
S.of(context).labelAgreeToTerms,
style: Theme.of(context).textTheme.titleSmall,
maxLines: 2,
textAlign: TextAlign.start,
),
),
const Gap(Dimen.spacingS),
IconButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).hintTermsAndConditions),
),
);
},
icon: const Icon(Icons.info),
),
],
),
),
);
}
}
37 changes: 8 additions & 29 deletions app/lib/presentation/ui/pages/auth/login/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:app/presentation/navigation/routers.dart';
import 'package:app/presentation/resources/locale/generated/l10n.dart';
import 'package:app/presentation/resources/resources.dart';
import 'package:app/presentation/ui/components/primary_button.dart';
import 'package:app/presentation/ui/custom/terms_services_check.dart';
import 'package:common/core/resource.dart';
import 'package:domain/bloc/auth/auth_cubit.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -83,35 +84,13 @@ class _LoginFormState extends State<LoginForm> {
style: Theme.of(context).textTheme.bodySmall,
),
const Gap(Dimen.spacingM),
TextButton(
onPressed: () => setState(() {
agreeToTerms = !agreeToTerms;
}),
child: Row(
children: [
Checkbox(
value: agreeToTerms,
onChanged: (value) => setState(() {
agreeToTerms = value ?? false;
}),
),
Text(
S.of(context).labelAgreeToTerms,
style: Theme.of(context).textTheme.titleSmall,
),
const Gap(Dimen.spacingS),
IconButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).hintTermsAndConditions),
),
);
},
icon: const Icon(Icons.info),
)
],
),
TermsServicesCheck(
agreeToTerms: agreeToTerms,
onChanged: (value) {
setState(() {
agreeToTerms = value;
});
},
),
const Gap(Dimen.spacingM),
BlocBuilder<AuthCubit, Resource>(
Expand Down
37 changes: 8 additions & 29 deletions app/lib/presentation/ui/pages/auth/sign_up/sign_up_form.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:app/presentation/resources/locale/generated/l10n.dart';
import 'package:app/presentation/resources/resources.dart';
import 'package:app/presentation/ui/components/primary_button.dart';
import 'package:app/presentation/ui/custom/terms_services_check.dart';
import 'package:common/core/resource.dart';
import 'package:common/validators/form_validator.dart';
import 'package:domain/bloc/auth/auth_cubit.dart';
Expand Down Expand Up @@ -98,35 +99,13 @@ class _SignUpFormState extends State<SignUpForm> {
},
),
const Gap(Dimen.spacingM),
TextButton(
onPressed: () => setState(() {
agreeToTerms = !agreeToTerms;
}),
child: Row(
children: [
Checkbox(
value: agreeToTerms,
onChanged: (value) => setState(() {
agreeToTerms = value ?? false;
}),
),
Text(
S.of(context).labelAgreeToTerms,
style: Theme.of(context).textTheme.titleSmall,
),
const Gap(Dimen.spacingS),
IconButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).hintTermsAndConditions),
),
);
},
icon: const Icon(Icons.info),
)
],
),
TermsServicesCheck(
agreeToTerms: agreeToTerms,
onChanged: (value) {
setState(() {
agreeToTerms = value;
});
},
),
const Gap(Dimen.spacingM),
BlocBuilder<AuthCubit, Resource>(
Expand Down
Loading