-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
329 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib/utilities/dialogs/password_reset_email_sent_dialog.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mynotes/utilities/dialogs/generic_dialog.dart'; | ||
|
||
Future<void> showPasswordResetSentDialog(BuildContext context) { | ||
return showGenericDialog<void>( | ||
context: context, | ||
title: 'Password Reset', | ||
content: | ||
'We have now sent you a password reset link. Please check your email for more information.', | ||
optionsBuilder: () => { | ||
'OK': null, | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:mynotes/services/auth/bloc/auth_bloc.dart'; | ||
import 'package:mynotes/services/auth/bloc/auth_event.dart'; | ||
import 'package:mynotes/services/auth/bloc/auth_state.dart'; | ||
import 'package:mynotes/utilities/dialogs/error_dialog.dart'; | ||
import 'package:mynotes/utilities/dialogs/password_reset_email_sent_dialog.dart'; | ||
|
||
class ForgotPasswordView extends StatefulWidget { | ||
const ForgotPasswordView({Key? key}) : super(key: key); | ||
|
||
@override | ||
_ForgotPasswordViewState createState() => _ForgotPasswordViewState(); | ||
} | ||
|
||
class _ForgotPasswordViewState extends State<ForgotPasswordView> { | ||
late final TextEditingController _controller; | ||
|
||
@override | ||
void initState() { | ||
_controller = TextEditingController(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BlocListener<AuthBloc, AuthState>( | ||
listener: (context, state) async { | ||
if (state is AuthStateForgotPassword) { | ||
if (state.hasSentEmail) { | ||
_controller.clear(); | ||
await showPasswordResetSentDialog(context); | ||
} | ||
if (state.exception != null) { | ||
await showErrorDialog(context, | ||
'We could not process your request. Please make sure that you are a registered user, or if not, register a user now by going back one step.'); | ||
} | ||
} | ||
}, | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Forgot Password'), | ||
), | ||
body: Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Column( | ||
children: [ | ||
const Text( | ||
'If you forgot your password, simply enter your email and we will send you a password reset link.'), | ||
TextField( | ||
keyboardType: TextInputType.emailAddress, | ||
autocorrect: false, | ||
autofocus: true, | ||
controller: _controller, | ||
decoration: const InputDecoration( | ||
hintText: 'Your email address....', | ||
), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
final email = _controller.text; | ||
context | ||
.read<AuthBloc>() | ||
.add(AuthEventForgotPassword(email: email)); | ||
}, | ||
child: const Text('Send me password reset link'), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
context.read<AuthBloc>().add( | ||
const AuthEventLogOut(), | ||
); | ||
}, | ||
child: const Text('Back to login page'), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.