reset passord

This commit is contained in:
Felipe
2023-11-01 10:00:17 -05:00
parent a6c6552213
commit d37eb9b190
8 changed files with 141 additions and 9 deletions
@@ -0,0 +1,126 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/components/primary_btn.dart';
import 'package:prosappco/src/controllers/login_email_controller.dart';
class ResetPasswordScreen extends StatelessWidget {
const ResetPasswordScreen({super.key});
@override
Widget build(BuildContext context) {
final controller = Get.put(LoginEmailController());
return Scaffold(
appBar: PopAppbar(
onPressed: () {
Navigator.pop(context);
},
label: 'Restablecer Contraseña'),
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Center(
child: Container(
padding: const EdgeInsets.all(15),
color: Colors.transparent,
width: MediaQuery.of(context).size.width * 0.9,
child: Column(
children: [
const SizedBox(height: 20),
const Text(
'Restablecer contraseña',
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 25),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
const Text(
'Ingresa ingresa tu correo electrónico y te enviaremos un enlace para restablecer tu contraseña',
style: TextStyle(color: Colors.grey, fontSize: 12),
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
const Padding(
padding: EdgeInsets.only(bottom: 5),
child: Align(
alignment: Alignment.topLeft,
child: Text('Email',
style: TextStyle(
fontSize: 18.0, color: Color(0xFF65676B))),
),
),
TextFormField(
controller: controller.email,
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingresa un Email';
}
final RegExp emailRegExp =
RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegExp.hasMatch(value)) {
return 'Por favor, ingresa un Email válido';
}
return null;
},
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFECECEC)),
borderRadius: BorderRadius.all(
Radius.circular(50),
)),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFECECEC)),
borderRadius: BorderRadius.all(
Radius.circular(50),
)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFECECEC)),
borderRadius: BorderRadius.all(
Radius.circular(50),
)),
errorBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Color.fromARGB(255, 184, 0, 0)),
borderRadius: BorderRadius.all(
Radius.circular(50),
)),
hintText: 'Hello@gmail.com',
fillColor: Color.fromARGB(255, 239, 239, 239),
filled: true,
prefixIcon: Icon(Icons.email_outlined),
hintStyle: TextStyle(
color: Colors.grey,
),
),
),
const SizedBox(height: 80),
PrimaryButtom(
onPressed: () async {
try {
await FirebaseAuth.instance.sendPasswordResetEmail(
email: controller.email.text.trim());
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Se ha enviado un enlace de restablecimiento de contraseña a tu correo electrónico.'),
),
);
Navigator.pop(context);
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text(
'Hubo un error al enviar el enlace de restablecimiento de contraseña.'),
));
}
},
label: 'Enviar'),
],
),
),
),
)),
);
}
}