From 323e944152aaba499d344e4d31ad40b0a17d12a2 Mon Sep 17 00:00:00 2001 From: AlcalaJulian Date: Wed, 3 Dec 2025 13:57:08 +0100 Subject: [PATCH] clean console problems --- .../src/device_sign_up/add_kid_screen.dart | 2 +- .../src/login/presentation/login_screen.dart | 70 +++--- .../presentation/new_password_screen.dart | 165 +++++++------- .../auth/lib/src/sign_up/signup_screen.dart | 132 ++++++----- .../lib/src/presentation/deposit_screen.dart | 157 +++++++------ .../lib/src/presentation/home_screen.dart | 2 +- .../lib/src/presentation/wage_screen.dart | 211 +++++++++--------- .../lib/src/core/activity_list.dart | 50 +++-- modules/profile/lib/src/profile_builder.dart | 1 - 9 files changed, 420 insertions(+), 370 deletions(-) diff --git a/modules/auth/lib/src/device_sign_up/add_kid_screen.dart b/modules/auth/lib/src/device_sign_up/add_kid_screen.dart index 37531a5c..476e77bb 100644 --- a/modules/auth/lib/src/device_sign_up/add_kid_screen.dart +++ b/modules/auth/lib/src/device_sign_up/add_kid_screen.dart @@ -38,7 +38,7 @@ class AddKidScreen extends StatelessWidget { "Si aún no lo tienes, puedes conseguirlo a través de nuestra web", ), Spacer(flex: 8), - Container( + SizedBox( width: double.infinity, child: FilledButton( onPressed: () => Navigator.push( diff --git a/modules/auth/lib/src/login/presentation/login_screen.dart b/modules/auth/lib/src/login/presentation/login_screen.dart index 6c79b547..d169799f 100644 --- a/modules/auth/lib/src/login/presentation/login_screen.dart +++ b/modules/auth/lib/src/login/presentation/login_screen.dart @@ -5,88 +5,98 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:navigation/navigation.dart'; import 'package:sf_localizations/sf_localizations.dart'; -class LoginScreen extends ConsumerWidget { +class LoginScreen extends ConsumerStatefulWidget { final NavigationContract navigationContract; const LoginScreen({super.key, required this.navigationContract}); @override - Widget build(BuildContext context, WidgetRef ref) { - bool passwordVisible = true; + ConsumerState createState() => _LoginScreenState(); +} + +class _LoginScreenState extends ConsumerState { + bool passwordVisible = false; + + @override + Widget build(BuildContext context) { + // final l10n = SfLocalizations.of(context); + return Scaffold( body: Center( child: Container( - margin: EdgeInsets.all(30), + margin: const EdgeInsets.all(30), child: Column( spacing: 10, children: [ - Icon(Icons.check, color: Color(0xFF329e95), size: 50), - Text( - // context.translate(I18n.example) // example to use Intl package - "¡Te damos la bienvenida!", + const Icon(Icons.check, color: Color(0xFF329e95), size: 50), + const Text( + // context.translate(I18n.example) + '¡Te damos la bienvenida!', style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold), ), - TextField( + const TextField( decoration: InputDecoration( - hintText: "Nombre de usuario", - labelText: "Nombre de usuario", + hintText: 'Nombre de usuario', + labelText: 'Nombre de usuario', border: OutlineInputBorder(), ), ), TextField( - obscureText: passwordVisible, + obscureText: !passwordVisible, enableSuggestions: false, autocorrect: false, decoration: InputDecoration( - labelText: "Contraseña", - hintText: "********", - border: OutlineInputBorder(), + labelText: 'Contraseña', + hintText: '********', + border: const OutlineInputBorder(), suffixIcon: IconButton( icon: Icon( passwordVisible ? Icons.visibility : Icons.visibility_off, ), onPressed: () { - // setState(() { - // passwordVisible = !passwordVisible; - // }); + setState(() { + passwordVisible = !passwordVisible; + }); }, ), ), ), TextButton( onPressed: () => - navigationContract.pushTo(AppRoutes.recoverPassword), - child: Text("¿Has olvidado la contraseña?"), + widget.navigationContract.pushTo(AppRoutes.recoverPassword), + child: const Text('¿Has olvidado la contraseña?'), ), FilledButton( onPressed: () => - navigationContract.pushTo(AppRoutes.dashboardHome), - child: Text("Iniciar sesión"), + widget.navigationContract.pushTo(AppRoutes.dashboardHome), + child: const Text('Iniciar sesión'), ), - Stack(children: [Divider(), Text("o continúa con")]), + const Stack(children: [Divider(), Text('o continúa con')]), Row( spacing: 20, children: [ OutlinedButton( onPressed: () => Navigator.push( context, - MaterialPageRoute(builder: (_) => LoadingGoogleScreen()), + MaterialPageRoute( + builder: (_) => const LoadingGoogleScreen(), + ), ), - child: Text("Google", semanticsLabel: "Google"), + child: const Text('Google', semanticsLabel: 'Google'), ), OutlinedButton( - onPressed: () => {}, - child: Icon(Icons.apple, semanticLabel: "Apple"), + onPressed: () {}, + child: const Icon(Icons.apple, semanticLabel: 'Apple'), ), ], ), - Text("¿No tienes cuenta?"), + const Text('¿No tienes cuenta?'), TextButton( onPressed: () => Navigator.push( context, - MaterialPageRoute(builder: (_) => SignupScreen()), + MaterialPageRoute(builder: (_) => const SignupScreen()), ), - child: Text("Crear una ahora"), + child: const Text('Crear una ahora'), ), ], ), diff --git a/modules/auth/lib/src/recover_password/presentation/new_password_screen.dart b/modules/auth/lib/src/recover_password/presentation/new_password_screen.dart index 35abf19d..53893d67 100644 --- a/modules/auth/lib/src/recover_password/presentation/new_password_screen.dart +++ b/modules/auth/lib/src/recover_password/presentation/new_password_screen.dart @@ -12,26 +12,27 @@ class NewPasswordScreen extends ConsumerStatefulWidget { class NewPasswordScreenState extends ConsumerState { bool passwordVisible = false; bool equalPasswords = false; - String password = ""; - var securityChecks = { - "min": false, - "capital": false, - "number": false, - "special": false, + String password = ''; + + Map securityChecks = { + 'min': false, + 'capital': false, + 'number': false, + 'special': false, }; @override void initState() { + super.initState(); passwordVisible = false; equalPasswords = false; - String password = ""; + password = ''; securityChecks = { - "min": false, - "capital": false, - "number": false, - "special": false, + 'min': false, + 'capital': false, + 'number': false, + 'special': false, }; - super.initState(); } @override @@ -40,24 +41,24 @@ class NewPasswordScreenState extends ConsumerState { return Scaffold( body: Container( - margin: EdgeInsets.all(30), + margin: const EdgeInsets.all(30), child: Center( child: Column( spacing: 10, children: [ - Spacer(flex: 4), - Text( - "Recuperar contraseña", + const Spacer(flex: 4), + const Text( + 'Recuperar contraseña', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), ), TextField( - obscureText: passwordVisible, + obscureText: !passwordVisible, enableSuggestions: false, autocorrect: false, decoration: InputDecoration( - labelText: "Nueva contraseña", - hintText: "********", - border: OutlineInputBorder(), + labelText: 'Nueva contraseña', + hintText: '********', + border: const OutlineInputBorder(), suffixIcon: IconButton( icon: Icon( passwordVisible ? Icons.visibility : Icons.visibility_off, @@ -69,21 +70,21 @@ class NewPasswordScreenState extends ConsumerState { }, ), ), - onChanged: (value) => { + onChanged: (value) { setState(() { password = value; securityChecks = checkSecurity(value); - }), + }); }, ), TextField( - obscureText: passwordVisible, + obscureText: !passwordVisible, enableSuggestions: false, autocorrect: false, decoration: InputDecoration( - labelText: "Repetir contraseña", - hintText: "********", - border: OutlineInputBorder(), + labelText: 'Repetir contraseña', + hintText: '********', + border: const OutlineInputBorder(), suffixIcon: IconButton( icon: Icon( passwordVisible ? Icons.visibility : Icons.visibility_off, @@ -95,78 +96,82 @@ class NewPasswordScreenState extends ConsumerState { }, ), ), - onChanged: (value) => { + onChanged: (value) { setState(() { equalPasswords = password == value; - }), + }); }, ), Row( children: [ - securityChecks["min"]! - ? Icon( - Icons.check, - color: theme.getColorFor(ThemeCode.buttonPrimary), - ) - : Icon( - Icons.cancel_outlined, - color: theme.getColorFor(ThemeCode.buttonSecondary), - ), - Text("Al menos 8 caracteres"), + Icon( + securityChecks['min']! + ? Icons.check + : Icons.cancel_outlined, + color: securityChecks['min']! + ? theme.getColorFor(ThemeCode.buttonPrimary) + : theme.getColorFor(ThemeCode.buttonSecondary), + ), + const SizedBox(width: 8), + const Text('Al menos 8 caracteres'), ], ), Row( children: [ - securityChecks["capital"]! - ? Icon( - Icons.check, - color: theme.getColorFor(ThemeCode.buttonPrimary), - ) - : Icon( - Icons.cancel_outlined, - color: theme.getColorFor(ThemeCode.buttonSecondary), - ), - Text("Una mayúscula"), + Icon( + securityChecks['capital']! + ? Icons.check + : Icons.cancel_outlined, + color: securityChecks['capital']! + ? theme.getColorFor(ThemeCode.buttonPrimary) + : theme.getColorFor(ThemeCode.buttonSecondary), + ), + const SizedBox(width: 8), + const Text('Una mayúscula'), ], ), Row( children: [ - securityChecks["number"]! - ? Icon( - Icons.check, - color: theme.getColorFor(ThemeCode.buttonPrimary), - ) - : Icon( - Icons.cancel_outlined, - color: theme.getColorFor(ThemeCode.buttonSecondary), - ), - Text("Un número"), + Icon( + securityChecks['number']! + ? Icons.check + : Icons.cancel_outlined, + color: securityChecks['number']! + ? theme.getColorFor(ThemeCode.buttonPrimary) + : theme.getColorFor(ThemeCode.buttonSecondary), + ), + const SizedBox(width: 8), + const Text('Un número'), ], ), Row( children: [ - securityChecks["special"]! - ? Icon( - Icons.check, - color: theme.getColorFor(ThemeCode.buttonPrimary), - ) - : Icon( - Icons.cancel_outlined, - color: theme.getColorFor(ThemeCode.buttonSecondary), - ), - Text("Un carácter especial"), + Icon( + securityChecks['special']! + ? Icons.check + : Icons.cancel_outlined, + color: securityChecks['special']! + ? theme.getColorFor(ThemeCode.buttonPrimary) + : theme.getColorFor(ThemeCode.buttonSecondary), + ), + const SizedBox(width: 8), + const Text('Un carácter especial'), ], ), - Spacer(flex: 1), + const Spacer(flex: 1), FilledButton( - onPressed: () => {}, + onPressed: + equalPasswords && + securityChecks.values.every((check) => check) + ? () {} + : null, child: Container( width: double.infinity, - padding: EdgeInsets.all(20), - child: Text("Aceptar"), + padding: const EdgeInsets.all(20), + child: const Center(child: Text('Aceptar')), ), ), - Spacer(flex: 4), + const Spacer(flex: 4), ], ), ), @@ -176,13 +181,11 @@ class NewPasswordScreenState extends ConsumerState { //TODO: Extraer de la vista Map checkSecurity(String value) { - Map checks = {}; - - checks["min"] = value.length >= 8; - checks["capital"] = RegExp(r'[A-Z]').hasMatch(value); - checks["number"] = RegExp(r'[0-9]').hasMatch(value); - checks["special"] = RegExp(r'[^A-Za-z0-9]').hasMatch(value); - - return checks; + return { + 'min': value.length >= 8, + 'capital': RegExp(r'[A-Z]').hasMatch(value), + 'number': RegExp(r'[0-9]').hasMatch(value), + 'special': RegExp(r'[^A-Za-z0-9]').hasMatch(value), + }; } } diff --git a/modules/auth/lib/src/sign_up/signup_screen.dart b/modules/auth/lib/src/sign_up/signup_screen.dart index a6432de6..e662c053 100644 --- a/modules/auth/lib/src/sign_up/signup_screen.dart +++ b/modules/auth/lib/src/sign_up/signup_screen.dart @@ -6,69 +6,79 @@ import 'package:auth/src/sign_up/signup_personal_screen.dart'; import 'package:auth/src/sign_up/signup_user_screen.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -class SignupScreen extends ConsumerWidget { - SignupScreen({super.key}); +class SignupScreen extends ConsumerStatefulWidget { + const SignupScreen({super.key}); + @override + ConsumerState createState() => _SignupScreenState(); +} + +class _SignupScreenState extends ConsumerState { int currentStep = 0; @override - Widget build(BuildContext context, WidgetRef ref) { + Widget build(BuildContext context) { final theme = ref.watch(themePortProvider); - return MaterialApp( - home: Scaffold( - body: Center( - child: Container( - color: theme.getColorFor(ThemeCode.backgroundPrimary), - padding: const EdgeInsets.all(20), - child: SizedBox( - child: Stepper( - controlsBuilder: - (BuildContext context, ControlsDetails controls) { - return Row( - children: [ - Expanded( - child: OutlinedButton( - onPressed: controls.onStepCancel, - child: const Text('Atrás'), - ), + return Scaffold( + body: Center( + child: Container( + color: theme.getColorFor(ThemeCode.backgroundPrimary), + padding: const EdgeInsets.all(20), + child: SizedBox( + child: Stepper( + type: StepperType.horizontal, + currentStep: currentStep, + steps: getSteps(), + controlsBuilder: + (BuildContext context, ControlsDetails controls) { + final canGoBack = currentStep > 0; + + return Row( + children: [ + Expanded( + child: OutlinedButton( + onPressed: canGoBack ? controls.onStepCancel : null, + child: const Text('Atrás'), ), - Expanded( - child: FilledButton( - style: ButtonStyle( - backgroundColor: WidgetStatePropertyAll( - theme.getColorFor(ThemeCode.buttonSecondary), - ), + ), + Expanded( + child: FilledButton( + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll( + theme.getColorFor(ThemeCode.buttonSecondary), ), - onPressed: controls.onStepContinue, - child: const Text('Siguiente'), ), + onPressed: controls.onStepContinue, + child: const Text('Siguiente'), ), - ], - ); - }, - type: StepperType.horizontal, - currentStep: currentStep, - onStepCancel: () => currentStep == 0, - // ? null - // : setState(() { - // currentStep -= 1; - // }), - onStepContinue: () { - bool isLastStep = (currentStep == getSteps().length - 1); - if (isLastStep) { - Navigator.pushReplacement( - context, - MaterialPageRoute(builder: (_) => AccountCreatedScreen()), + ), + ], ); - } else { - // setState(() { - // currentStep += 1; - // }); - } - }, - steps: getSteps(), - ), + }, + onStepCancel: () { + if (currentStep > 0) { + setState(() { + currentStep -= 1; + }); + } + }, + onStepContinue: () { + final isLastStep = currentStep == getSteps().length - 1; + + if (isLastStep) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => const AccountCreatedScreen(), + ), + ); + } else { + setState(() { + currentStep += 1; + }); + } + }, ), ), ), @@ -82,55 +92,55 @@ class SignupScreen extends ConsumerWidget { state: currentStep > 0 ? StepState.complete : StepState.indexed, isActive: currentStep >= 0, stepStyle: currentStep >= 0 - ? StepStyle( + ? const StepStyle( connectorThickness: 0, color: Color(0xFF329e95), indexStyle: TextStyle(color: Colors.transparent), ) - : StepStyle( + : const StepStyle( connectorThickness: 0, color: Colors.transparent, boxShadow: BoxShadow(spreadRadius: 5), indexStyle: TextStyle(color: Colors.transparent), ), title: const Text(""), - content: SignupPersonalScreen(), + content: const SignupPersonalScreen(), ), Step( state: currentStep > 1 ? StepState.complete : StepState.indexed, isActive: currentStep >= 1, stepStyle: currentStep >= 1 - ? StepStyle( + ? const StepStyle( connectorThickness: 0, color: Color(0xFF329e95), indexStyle: TextStyle(color: Colors.transparent), ) - : StepStyle( + : const StepStyle( connectorThickness: 0, color: Colors.white, boxShadow: BoxShadow(spreadRadius: 1), indexStyle: TextStyle(color: Colors.transparent), ), title: const Text(""), - content: SignupAddressScreen(), + content: const SignupAddressScreen(), ), Step( state: currentStep > 2 ? StepState.complete : StepState.indexed, isActive: currentStep >= 2, stepStyle: currentStep >= 2 - ? StepStyle( + ? const StepStyle( connectorThickness: 0, color: Color(0xFF329e95), indexStyle: TextStyle(color: Colors.transparent), ) - : StepStyle( + : const StepStyle( connectorThickness: 0, color: Colors.white, boxShadow: BoxShadow(spreadRadius: 1), indexStyle: TextStyle(color: Colors.transparent), ), title: const Text(""), - content: SignupUserScreen(), + content: const SignupUserScreen(), ), ]; } diff --git a/modules/home/lib/src/presentation/deposit_screen.dart b/modules/home/lib/src/presentation/deposit_screen.dart index cc6f80e0..4f16724a 100644 --- a/modules/home/lib/src/presentation/deposit_screen.dart +++ b/modules/home/lib/src/presentation/deposit_screen.dart @@ -5,39 +5,44 @@ import 'package:home/src/presentation/wallet_management_layout.dart'; import 'package:sf_shared/sf_shared.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -class DepositScreen extends ConsumerWidget { +class DepositScreen extends ConsumerStatefulWidget { final Kid kid; - DepositScreen({super.key, required this.kid}); + const DepositScreen({super.key, required this.kid}); - String reason = "other"; + @override + ConsumerState createState() => _DepositScreenState(); +} + +class _DepositScreenState extends ConsumerState { + String reason = 'other'; bool program = false; @override - Widget build(BuildContext context, WidgetRef ref) { + Widget build(BuildContext context) { final theme = ref.watch(themePortProvider); return WalletManagementLayout( - kid: kid, + kid: widget.kid, footer: Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( children: [ FilledButton( - onPressed: () => {}, + onPressed: () {}, child: Container( width: double.infinity, - padding: EdgeInsets.all(20), - child: Center(child: Text("Añadir dinero")), + padding: const EdgeInsets.all(20), + child: const Center(child: Text('Añadir dinero')), ), ), TextButton( onPressed: () => Navigator.pop(context), - child: Text("Cancelar"), + child: const Text('Cancelar'), ), ], ), @@ -46,87 +51,88 @@ class DepositScreen extends ConsumerWidget { Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Ingresar dinero en el wallet", + const Text( + 'Ingresar dinero en el wallet', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), TextField( - decoration: InputDecoration( - labelText: "Cantidad", - hintText: "0€", + decoration: const InputDecoration( + labelText: 'Cantidad', + hintText: '0€', border: OutlineInputBorder(), ), keyboardType: TextInputType.number, inputFormatters: [FilteringTextInputFormatter.digitsOnly], ), - Align( + const Align( alignment: Alignment.topLeft, - child: Text("Saldo total disponible después: 30 €"), + child: Text('Saldo total disponible después: 30 €'), ), ], ), ), + Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Motivo", + const Text( + 'Motivo', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), - Text("Este dato aparecerá en el reloj del peque"), + const Text('Este dato aparecerá en el reloj del peque'), CheckboxListTile( - title: Text('Paga semanal'), + title: const Text('Paga semanal'), controlAffinity: ListTileControlAffinity.leading, - value: reason == "weekly", - onChanged: (value) { - // setState(() { - // reason = "weekly"; - // }); + value: reason == 'weekly', + onChanged: (_) { + setState(() { + reason = 'weekly'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Objetivo semanal cumplido'), + title: const Text('Objetivo semanal cumplido'), controlAffinity: ListTileControlAffinity.leading, - value: reason == "goal", - onChanged: (value) { - // setState(() { - // reason = "goal"; - // }); + value: reason == 'goal', + onChanged: (_) { + setState(() { + reason = 'goal'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Gastos extraordinarios'), + title: const Text('Gastos extraordinarios'), controlAffinity: ListTileControlAffinity.leading, - value: reason == "extraordinary", - onChanged: (value) { - // setState(() { - // reason = "extraordinary"; - // }); + value: reason == 'extraordinary', + onChanged: (_) { + setState(() { + reason = 'extraordinary'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Otro'), + title: const Text('Otro'), controlAffinity: ListTileControlAffinity.leading, - value: reason == "other", - onChanged: (value) { - // setState(() { - // reason = "other"; - // }); + value: reason == 'other', + onChanged: (_) { + setState(() { + reason = 'other'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), @@ -136,55 +142,62 @@ class DepositScreen extends ConsumerWidget { maxLength: 150, decoration: InputDecoration( labelText: - "Escribir mensaje a ${kid.name} del motivo del ingreso", - hintText: "Escribe tu mensaje", - border: OutlineInputBorder(), + 'Escribir mensaje a ${widget.kid.name} del motivo del ingreso', + hintText: 'Escribe tu mensaje', + border: const OutlineInputBorder(), ), ), - Align( + const Align( alignment: Alignment.topLeft, - child: Text("Máximo 150 caracteres"), + child: Text('Máximo 150 caracteres'), ), ], ), ), + Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Cuándo se envía el dinero", + const Text( + 'Cuándo se envía el dinero', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), - Text("Este dato aparecerá en el reloj del peque"), + const Text('Este dato aparecerá en el reloj del peque'), CheckboxListTile( - title: Text('Ahora'), + title: const Text('Ahora'), controlAffinity: ListTileControlAffinity.leading, - value: program == false, - onChanged: (value) { - // setState(() { - // program = false; - // }); + value: !program, + onChanged: (_) { + setState(() { + program = false; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Programar'), + title: const Text('Programar'), controlAffinity: ListTileControlAffinity.leading, - value: program == true, - onChanged: (value) { - // setState(() { - // program = true; - // }); + value: program, + onChanged: (_) { + setState(() { + program = true; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), - if (program) TextField(), + if (program) + const TextField( + decoration: InputDecoration( + labelText: 'Fecha / hora (placeholder)', + border: OutlineInputBorder(), + ), + ), ], ), ), diff --git a/modules/home/lib/src/presentation/home_screen.dart b/modules/home/lib/src/presentation/home_screen.dart index 8047b036..c16f67dc 100644 --- a/modules/home/lib/src/presentation/home_screen.dart +++ b/modules/home/lib/src/presentation/home_screen.dart @@ -204,7 +204,7 @@ class HomeScreen extends ConsumerWidget { onPressed: () => showDialog( context: context, builder: (BuildContext context) => Dialog( - child: Container( + child: SizedBox( height: 100, width: double.infinity, child: Column( diff --git a/modules/home/lib/src/presentation/wage_screen.dart b/modules/home/lib/src/presentation/wage_screen.dart index eff4788f..27895f44 100644 --- a/modules/home/lib/src/presentation/wage_screen.dart +++ b/modules/home/lib/src/presentation/wage_screen.dart @@ -5,29 +5,35 @@ import 'package:home/src/presentation/wallet_management_layout.dart'; import 'package:sf_shared/sf_shared.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -class WageScreen extends ConsumerWidget { +class WageScreen extends ConsumerStatefulWidget { final Kid kid; - WageScreen({super.key, required this.kid}); + const WageScreen({super.key, required this.kid}); - String frequence = "weekly"; - var conditions = { - "weeklyLimits": false, - "incidences": false, - "holidays": false, + @override + ConsumerState createState() => _WageScreenState(); +} + +class _WageScreenState extends ConsumerState { + String frequence = 'weekly'; + + final Map conditions = { + 'weeklyLimits': false, + 'incidences': false, + 'holidays': false, }; @override - Widget build(BuildContext context, WidgetRef ref) { + Widget build(BuildContext context) { final theme = ref.watch(themePortProvider); return WalletManagementLayout( - kid: kid, + kid: widget.kid, footer: Container( - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.only( + borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), @@ -36,14 +42,14 @@ class WageScreen extends ConsumerWidget { spacing: 10, children: [ FilledButton( - onPressed: () => {}, + onPressed: () {}, child: Container( width: double.infinity, - padding: EdgeInsets.all(20), - child: Center(child: Text("Activar paga automática")), + padding: const EdgeInsets.all(20), + child: const Center(child: Text('Activar paga automática')), ), ), - TextButton(onPressed: () => {}, child: Text("Cancelar")), + TextButton(onPressed: () {}, child: const Text('Cancelar')), ], ), ), @@ -51,108 +57,110 @@ class WageScreen extends ConsumerWidget { Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Paga automática", + const Text( + 'Paga automática', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), TextField( - decoration: InputDecoration( - labelText: "Cantidad", - hintText: "0€", + decoration: const InputDecoration( + labelText: 'Cantidad', + hintText: '0€', border: OutlineInputBorder(), ), keyboardType: TextInputType.number, inputFormatters: [FilteringTextInputFormatter.digitsOnly], ), - Text("Saldo total disponible después: 30 €"), + const Text('Saldo total disponible después: 30 €'), ], ), ), + Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Frecuencia", + const Text( + 'Frecuencia', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), - Text("Cuándo se envía el dinero"), + const Text('Cuándo se envía el dinero'), CheckboxListTile( - title: Text('Semanal'), + title: const Text('Semanal'), controlAffinity: ListTileControlAffinity.leading, - value: frequence == "weekly", - onChanged: (value) { - // setState(() { - // frequence = "weekly"; - // }); + value: frequence == 'weekly', + onChanged: (_) { + setState(() { + frequence = 'weekly'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Cada dos semanas'), + title: const Text('Cada dos semanas'), controlAffinity: ListTileControlAffinity.leading, - value: frequence == "biweekly", - onChanged: (value) { - // setState(() { - // frequence = "biweekly"; - // }); + value: frequence == 'biweekly', + onChanged: (_) { + setState(() { + frequence = 'biweekly'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Mensual'), + title: const Text('Mensual'), controlAffinity: ListTileControlAffinity.leading, - value: frequence == "monthly", - onChanged: (value) { - // setState(() { - // frequence = "monthly"; - // }); + value: frequence == 'monthly', + onChanged: (_) { + setState(() { + frequence = 'monthly'; + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), - Container( + SizedBox( width: double.infinity, - child: DropdownMenu( - label: Text("Día de la semana"), - initialSelection: "Domingo", - dropdownMenuEntries: List.generate(7, ( - int index, - ) { - final days = [ - "Lunes", - "Martes", - "Miércoles", - "Jueves", - "Viernes", - "Sábado", - "Domingo", + child: DropdownMenu( + label: const Text('Día de la semana'), + initialSelection: 'Domingo', + dropdownMenuEntries: () { + const days = [ + 'Lunes', + 'Martes', + 'Miércoles', + 'Jueves', + 'Viernes', + 'Sábado', + 'Domingo', ]; - return DropdownMenuEntry( - value: days[index], - label: days[index], + return List>.generate( + days.length, + (index) => DropdownMenuEntry( + value: days[index], + label: days[index], + ), ); - }), + }(), ), ), - DropdownMenu( - label: Text("Hora del día"), + DropdownMenu( + label: const Text('Hora del día'), initialSelection: 9, - dropdownMenuEntries: List.generate(24, ( - int index, - ) { - return DropdownMenuEntry(value: index, label: "$index:00"); - }), + dropdownMenuEntries: List>.generate( + 24, + (index) => + DropdownMenuEntry(value: index, label: '$index:00'), + ), ), TextField( minLines: 3, @@ -160,62 +168,65 @@ class WageScreen extends ConsumerWidget { maxLength: 150, decoration: InputDecoration( labelText: - "Escribir mensaje a ${kid.name} del motivo del ingreso", - hintText: "Escribe tu mensaje", - border: OutlineInputBorder(), + 'Escribir mensaje a ${widget.kid.name} del motivo del ingreso', + hintText: 'Escribe tu mensaje', + border: const OutlineInputBorder(), ), ), - Align( + const Align( alignment: Alignment.topLeft, - child: Text("Máximo 150 caracteres"), + child: Text('Máximo 150 caracteres'), ), ], ), ), + Container( decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), + borderRadius: const BorderRadius.all(Radius.circular(20)), ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( spacing: 10, children: [ - Text( - "Condiciones", + const Text( + 'Condiciones', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), - Text("Este dato aparecerá en el reloj del peque"), + const Text('Este dato aparecerá en el reloj del peque'), CheckboxListTile( - title: Text('Sólo si cumple límites semanales'), + title: const Text('Sólo si cumple límites semanales'), controlAffinity: ListTileControlAffinity.leading, - value: conditions["weeklyLimits"], - onChanged: (value) { - // setState(() { - // conditions["weeklyLimits"] = !conditions["weeklyLimits"]!; - // }); + value: conditions['weeklyLimits'], + onChanged: (_) { + setState(() { + conditions['weeklyLimits'] = + !(conditions['weeklyLimits'] ?? false); + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Sólo si no ha tenido incidencias'), + title: const Text('Sólo si no ha tenido incidencias'), controlAffinity: ListTileControlAffinity.leading, - value: conditions["incidences"], - onChanged: (value) { - // setState(() { - // conditions["incidences"] = !conditions["incidences"]!; - // }); + value: conditions['incidences'], + onChanged: (_) { + setState(() { + conditions['incidences'] = + !(conditions['incidences'] ?? false); + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), CheckboxListTile( - title: Text('Pausar durante vacaciones'), + title: const Text('Pausar durante vacaciones'), controlAffinity: ListTileControlAffinity.leading, - value: conditions["holidays"], - onChanged: (value) { - // setState(() { - // conditions["holidays"] = !conditions["holidays"]!; - // }); + value: conditions['holidays'], + onChanged: (_) { + setState(() { + conditions['holidays'] = !(conditions['holidays'] ?? false); + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), ), diff --git a/modules/notifications/lib/src/core/activity_list.dart b/modules/notifications/lib/src/core/activity_list.dart index 686a86b5..3a680af5 100644 --- a/modules/notifications/lib/src/core/activity_list.dart +++ b/modules/notifications/lib/src/core/activity_list.dart @@ -4,9 +4,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; class ActivityList extends ConsumerStatefulWidget { final List activity; - bool edit = false; + final bool edit; - ActivityList({super.key, required this.activity, required this.edit}); + const ActivityList({super.key, required this.activity, this.edit = false}); @override ConsumerState createState() => ActivityListState(); @@ -17,27 +17,29 @@ class ActivityListState extends ConsumerState { @override void initState() { - values = List.generate(widget.activity.length, (_) => false); super.initState(); + values = List.generate(widget.activity.length, (_) => false); } @override Widget build(BuildContext context) { final theme = ref.watch(themePortProvider); - final colors = [ + const colors = [ Colors.cyan, Colors.pinkAccent, Colors.deepOrangeAccent, Colors.red, ]; - final icons = { + + const icons = { "wage": Icons.wallet, "goal": Icons.emoji_events_outlined, "lock": Icons.lock_outline, "reload": Icons.attach_money_outlined, }; - final titles = { + + const titles = { "wage": "Entrega de paga", "goal": "¡Objetivo cumplido!", "lock": "Bloqueo de pago", @@ -47,33 +49,35 @@ class ActivityListState extends ConsumerState { return Column( spacing: 20, children: List.generate(widget.activity.length, (int index) { - var logItem = Container( - padding: EdgeInsets.all(20), + final color = colors[index % colors.length]; + final type = widget.activity[index]["type"] as String; + + final logItem = Container( + padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all(Radius.circular(20)), - border: BoxBorder.fromLTRB( - left: BorderSide(color: colors[index % colors.length], width: 5), - ), + borderRadius: const BorderRadius.all(Radius.circular(20)), + border: Border(left: BorderSide(color: color, width: 5)), ), child: Column( spacing: 15, children: [ Row( children: [ - Icon( - icons[widget.activity[index]["type"]], - color: colors[index % colors.length], - ), + Icon(icons[type], color: color), + const SizedBox(width: 8), Text( - titles[widget.activity[index]["type"]]!, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + titles[type]!, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), ), - Spacer(), - Text("14/01/2005"), + const Spacer(), + const Text("14/01/2005"), ], ), - Align( + const Align( alignment: Alignment.topLeft, child: Text("Ana ya tiene su paga de 5€ en el reloj"), ), @@ -86,10 +90,10 @@ class ActivityListState extends ConsumerState { children: [ Checkbox( value: values[index], - onChanged: (value) => { + onChanged: (_) { setState(() { values[index] = !values[index]; - }), + }); }, activeColor: theme.getColorFor(ThemeCode.buttonPrimary), semanticLabel: "Eliminar", diff --git a/modules/profile/lib/src/profile_builder.dart b/modules/profile/lib/src/profile_builder.dart index e314bd25..27308ff0 100644 --- a/modules/profile/lib/src/profile_builder.dart +++ b/modules/profile/lib/src/profile_builder.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:notifications/notifications.dart'; import 'package:profile/profile.dart'; class ProfileBuilder {