update
This commit is contained in:
@@ -424,6 +424,9 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
|
|||||||
Radius.circular(50),
|
Radius.circular(50),
|
||||||
)),
|
)),
|
||||||
hintText: 'Contraseña',
|
hintText: 'Contraseña',
|
||||||
|
hintStyle: const TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
fillColor:
|
fillColor:
|
||||||
const Color.fromARGB(255, 239, 239, 239),
|
const Color.fromARGB(255, 239, 239, 239),
|
||||||
filled: true,
|
filled: true,
|
||||||
@@ -444,6 +447,20 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
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(
|
PaddingButtomBottom(
|
||||||
formKey: _formKey, controller: controller),
|
formKey: _formKey, controller: controller),
|
||||||
const RichTxtBottom()
|
const RichTxtBottom()
|
||||||
|
|||||||
@@ -302,6 +302,80 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
|||||||
return citys;
|
return citys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _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: <Widget>[
|
||||||
|
TextFormField(
|
||||||
|
controller: emailController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Nuevo Correo Electrónico',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -354,11 +428,7 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
|||||||
_email != null
|
_email != null
|
||||||
? TextFormField(
|
? TextFormField(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(context, CupertinoPageRoute(
|
_showEmailUpdateDialog(context);
|
||||||
builder: (BuildContext context) {
|
|
||||||
return NewPasswordScreen();
|
|
||||||
},
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
controller: _emailController,
|
controller: _emailController,
|
||||||
@@ -479,36 +549,69 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
|||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
margin: const EdgeInsets.only(top: 30),
|
margin: const EdgeInsets.only(top: 30),
|
||||||
padding: const EdgeInsets.only(bottom: 30),
|
padding: const EdgeInsets.only(bottom: 30),
|
||||||
child: ElevatedButton(
|
child: Column(
|
||||||
onPressed: () async {
|
children: [
|
||||||
if (_formKey.currentState!.validate()) {
|
ElevatedButton(
|
||||||
await updateInfo().whenComplete(() {
|
onPressed: () {
|
||||||
html.window.location.reload();
|
Navigator.push(
|
||||||
|
context,
|
||||||
Get.snackbar(
|
CupertinoPageRoute(
|
||||||
'Perfil',
|
builder: (BuildContext context) {
|
||||||
'Información actualizada correctamente.',
|
return NewPasswordScreen();
|
||||||
snackPosition: SnackPosition.TOP,
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
}
|
style: ElevatedButton.styleFrom(
|
||||||
},
|
backgroundColor: const Color(0xFF2BA4EC),
|
||||||
style: ElevatedButton.styleFrom(
|
shape: RoundedRectangleBorder(
|
||||||
backgroundColor: const Color(0xFF2BA4EC),
|
borderRadius: BorderRadius.circular(50),
|
||||||
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,
|
const SizedBox(height: 40),
|
||||||
minimumSize: const Size(200, 50),
|
ElevatedButton(
|
||||||
),
|
onPressed: () async {
|
||||||
child: const Text(
|
if (_formKey.currentState!.validate()) {
|
||||||
'Guardar',
|
await updateInfo().whenComplete(() {
|
||||||
style: TextStyle(
|
html.window.location.reload();
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
Get.snackbar(
|
||||||
fontSize: 17,
|
'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,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user