diff --git a/lib/src/screens/login_email.dart b/lib/src/screens/login_email.dart index 07cbb3f..48324ce 100644 --- a/lib/src/screens/login_email.dart +++ b/lib/src/screens/login_email.dart @@ -424,6 +424,9 @@ class _LoginEmailScreenState extends State { Radius.circular(50), )), hintText: 'Contraseña', + hintStyle: const TextStyle( + color: Colors.grey, + ), fillColor: const Color.fromARGB(255, 239, 239, 239), filled: true, @@ -444,6 +447,20 @@ class _LoginEmailScreenState extends State { ), ), ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 20), + child: TextButton( + onPressed: () { + // Agrega aquí la lógica para manejar la recuperación de contraseña + }, + child: const Text( + 'Olvidé la contraseña', + style: TextStyle( + color: Colors.blue, + ), + ), + ), + ), PaddingButtomBottom( formKey: _formKey, controller: controller), const RichTxtBottom() diff --git a/lib/src/screens/profile_web.dart b/lib/src/screens/profile_web.dart index 86841eb..38ae3fb 100644 --- a/lib/src/screens/profile_web.dart +++ b/lib/src/screens/profile_web.dart @@ -302,6 +302,80 @@ class _ProfileWebScreenState extends State { return citys; } + Future _showEmailUpdateDialog(BuildContext context) async { + TextEditingController emailController = TextEditingController(); + String currentEmail = FirebaseAuth.instance.currentUser?.email ?? ''; + + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Actualizar Correo Electrónico'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextFormField( + controller: emailController, + decoration: const InputDecoration( + labelText: 'Nuevo Correo Electrónico', + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Cancelar'), + ), + ElevatedButton( + onPressed: () async { + String newEmail = emailController.text.trim(); + if (newEmail.isNotEmpty && newEmail != currentEmail) { + // Actualiza el correo electrónico aquí + try { + await FirebaseAuth.instance.currentUser + ?.updateEmail(newEmail); + await FirebaseFirestore.instance + .collection('users') + .doc(FirebaseAuth.instance.currentUser?.uid) + .update({'email': newEmail}); + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: + Text('Correo Electrónico actualizado con éxito'), + ), + ); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: + Text('Error al actualizar el correo electrónico'), + ), + ); + } + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: + Text('Ingresa un nuevo correo electrónico válido'), + ), + ); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + ), + child: const Text('Guardar'), + ), + ], + ); + }, + ); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -354,11 +428,7 @@ class _ProfileWebScreenState extends State { _email != null ? TextFormField( onTap: () { - Navigator.push(context, CupertinoPageRoute( - builder: (BuildContext context) { - return NewPasswordScreen(); - }, - )); + _showEmailUpdateDialog(context); }, readOnly: true, controller: _emailController, @@ -479,36 +549,69 @@ class _ProfileWebScreenState extends State { alignment: Alignment.bottomCenter, margin: const EdgeInsets.only(top: 30), padding: const EdgeInsets.only(bottom: 30), - child: ElevatedButton( - onPressed: () async { - if (_formKey.currentState!.validate()) { - await updateInfo().whenComplete(() { - html.window.location.reload(); - - Get.snackbar( - 'Perfil', - 'Información actualizada correctamente.', - snackPosition: SnackPosition.TOP, + child: Column( + children: [ + ElevatedButton( + onPressed: () { + Navigator.push( + context, + CupertinoPageRoute( + builder: (BuildContext context) { + return NewPasswordScreen(); + }, + ), ); - }); - } - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF2BA4EC), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(50), + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF2BA4EC), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + ), + elevation: 0, + minimumSize: const Size(300, 45), + ), + child: const Text( + 'Cambiar Contraseña', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 17, + ), + ), ), - elevation: 0, - minimumSize: const Size(200, 50), - ), - child: const Text( - 'Guardar', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 17, + const SizedBox(height: 40), + ElevatedButton( + onPressed: () async { + if (_formKey.currentState!.validate()) { + await updateInfo().whenComplete(() { + html.window.location.reload(); + + Get.snackbar( + 'Perfil', + 'Información actualizada correctamente.', + snackPosition: SnackPosition.TOP, + ); + }); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF2BA4EC), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50), + ), + elevation: 0, + minimumSize: const Size(200, 50), + ), + child: const Text( + 'Guardar', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 17, + ), + ), ), - ), + ], ), ), ],