Commit a39732a7 authored by Budi Prasetyo's avatar Budi Prasetyo

reset password

parent 0d71183e
...@@ -3,6 +3,7 @@ import 'dart:convert'; ...@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:form_field_validator/form_field_validator.dart'; import 'package:form_field_validator/form_field_validator.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:medapp_eksad/firebase/showSnackbar_Alertdialog.dart'; import 'package:medapp_eksad/firebase/showSnackbar_Alertdialog.dart';
import 'package:medapp_eksad/widget/button_color.dart'; import 'package:medapp_eksad/widget/button_color.dart';
...@@ -27,6 +28,7 @@ class _ForgotPasswordState extends State<ForgotPassword> { ...@@ -27,6 +28,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
return Stack( return Stack(
children: [ children: [
Container( Container(
...@@ -45,38 +47,64 @@ class _ForgotPasswordState extends State<ForgotPassword> { ...@@ -45,38 +47,64 @@ class _ForgotPasswordState extends State<ForgotPassword> {
), ),
Center( Center(
child: AlertDialog( child: AlertDialog(
title: Text('Receive an email \nto reset your password.',textAlign: TextAlign.center,), title: Text('Reset Password',textAlign: TextAlign.center,),
content: Form( content: Container(
key: formKey, width: screenSize.width*0.25,
child: TextFormField( height: screenSize.height*0.3,
textAlign: TextAlign.start, child: Column(
controller: emailController, mainAxisAlignment: MainAxisAlignment.spaceAround,
textInputAction: TextInputAction.done, children: [
autovalidateMode: AutovalidateMode.onUserInteraction, Form(
validator: (email) => email != null && EmailValidator(errorText: 'Enter a valid email').isValid(email) key: formKey,
? "Enter a valid email" child: TextFormField(
:null textAlign: TextAlign.start,
, controller: emailController,
decoration: InputDecoration( textInputAction: TextInputAction.done,
labelText: "Enter your email address", //autovalidateMode: AutovalidateMode.onUserInteraction,
hintStyle: const TextStyle(),
border: OutlineInputBorder( decoration: InputDecoration(
borderRadius: BorderRadius.circular(5.0)), labelText: "Enter your email address",
), hintStyle: const TextStyle(),
// onChanged: (value) => email = value, border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0)),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your email address';
}
return null;
},
// onChanged: (value) => email = value,
),
),
Container
(height: screenSize.height*0.1,
child: Text('We will send you an email with'
' a link to reset your password, please enter the email'
' associated with your account above.',style: GoogleFonts.poppins(fontSize: 12),),),
Container(
width: screenSize.width*0.31,
height: screenSize.height*0.065,
child: ElevatedButton(
onPressed: () async {
if (formKey.currentState!.validate()) {
await resetPassword();
return;
}
},
// resetPassword();
// //Navigator.pushNamed(context, 'dashboard');
// },
child: const Text('Send'),),
)
],
), ),
), ),
actions: <Widget>[
TextButton(
onPressed: () {
resetPassword();
//Navigator.pushNamed(context, 'dashboard');
},
child: const Text('Send'),
), ),
], ),
)),
], ],
); );
} }
...@@ -90,7 +118,7 @@ class _ForgotPasswordState extends State<ForgotPassword> { ...@@ -90,7 +118,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
} on FirebaseAuthException catch (e){ } on FirebaseAuthException catch (e){
print(e); print(e);
showSnackBar(context, e.message.toString()); showSnackBarError(context, e.message!);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment