1
1
import 'package:books_app/constants/colors.dart' ;
2
2
import 'package:books_app/constants/routes.dart' ;
3
+ import 'package:books_app/services/auth.dart' ;
3
4
import 'package:books_app/widgets/auth/auth_navigation.dart' ;
4
5
import 'package:books_app/widgets/auth/auth_page_title.dart' ;
5
6
import 'package:books_app/widgets/button.dart' ;
@@ -16,6 +17,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
16
17
TextEditingController _emailController = TextEditingController ();
17
18
// final BackendService authService = BackendService();
18
19
20
+ String ? _message;
19
21
@override
20
22
Widget build (BuildContext context) {
21
23
return Scaffold (
@@ -25,6 +27,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
25
27
child: Column (
26
28
crossAxisAlignment: CrossAxisAlignment .stretch,
27
29
children: < Widget > [
30
+ showAlert () ,
28
31
const AuthPageTitle (name: 'Reset password' ),
29
32
// AuthErrorMessage(errorMessage: error.toString()),
30
33
Form (
@@ -38,29 +41,62 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
38
41
Button (
39
42
name: 'Continue' ,
40
43
color: blackButton,
41
- myFunction: () {
44
+ myFunction: () async {
45
+ await FirebaseAuthService ()
46
+ .ResetPassword (_emailController.text);
47
+ setState (() {
48
+ _message =
49
+ 'Password reset link has been sent to you on email ${_emailController .text }.You will be redirected to signIn page' ;
50
+ });
51
+
52
+ print (_message);
53
+ await Future <dynamic >.delayed (const Duration (seconds: 4 ), () {});
42
54
Navigator .pushReplacementNamed (context, Routes .INITIAL_PAGE );
43
55
},
44
56
)
45
- // AuthButton(
46
- // text: 'Continue',
47
- // formKey: formKey,
48
- // onClick: onSubmit,
49
- // onSuccess: onSuccess,
50
- // onError: onError,
51
- // )
52
57
],
53
58
),
54
59
),
55
60
);
56
61
}
57
62
58
- // Future<String> onSubmit() async {
59
- // return authService.forgotPassword(email).toString();
60
- // }
61
-
62
- // void onSuccess() {
63
- // Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
64
- // builder: (BuildContext context) => ResetPasswordScreen(email: email)));
65
- // }
63
+ Widget showAlert () {
64
+ if (_message != null ) {
65
+ return Align (
66
+ alignment: Alignment .topCenter,
67
+ child: Container (
68
+ color: Colors .amberAccent,
69
+ width: double .infinity,
70
+ padding: const EdgeInsets .all (8.0 ),
71
+ child: Row (
72
+ children: < Widget > [
73
+ const Padding (
74
+ padding: EdgeInsets .only (right: 8.0 ),
75
+ child: Icon (Icons .error_outline),
76
+ ),
77
+ Expanded (
78
+ child: Text (
79
+ _message! ,
80
+ maxLines: 3 ,
81
+ ),
82
+ ),
83
+ Padding (
84
+ padding: const EdgeInsets .only (left: 8.0 ),
85
+ child: IconButton (
86
+ icon: const Icon (Icons .close),
87
+ onPressed: () {
88
+ setState (() {
89
+ _message = '' ;
90
+ });
91
+ },
92
+ ),
93
+ )
94
+ ],
95
+ ),
96
+ ),
97
+ );
98
+ }
99
+ else
100
+ return Container ();
101
+ }
66
102
}
0 commit comments