Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/forgot password #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
Binary file added images/CarPolish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/FullBodyWash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/car-vacuum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/eng1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/engine-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/exceptions/auth-exception-handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AuthExceptionHandler {
case "ERROR_WRONG_PASSWORD":
status = AuthResultStatus.wrongPassword;
break;
case "ERROR_USER_NOT_FOUND":
case "user-not-found":
status = AuthResultStatus.userNotFound;
break;
case "ERROR_USER_DISABLED":
Expand Down
5 changes: 5 additions & 0 deletions lib/models/user_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ class UserManager {
}

void registerUser(Person user) {}

// reset password
Future<AuthResultStatus> resetPassword(String emailAddress) async {
return await _auth.resetPassword(emailAddress);
}
}
159 changes: 157 additions & 2 deletions lib/screens/forgot_password_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,164 @@
import 'package:flutter/material.dart';
import 'package:gezamycar/common/myflutter_alert.dart';
import 'package:gezamycar/enums/auth-result-status.dart';
import 'package:gezamycar/exceptions/auth-exception-handler.dart';
import 'package:gezamycar/models/user_manager.dart';
import 'package:gezamycar/utils/constants.dart';
import 'package:gezamycar/utils/form_validators.dart';
import 'package:gezamycar/widgets/custom_material_button.dart';
import 'package:gezamycar/widgets/custom_text_form.dart';
import 'package:modal_progress_hud/modal_progress_hud.dart';
import 'package:rflutter_alert/rflutter_alert.dart';

class ForgotPasswordScreen extends StatelessWidget {
import '../widgets/custom_text_form.dart';
import 'login_screen.dart';

class ForgotPasswordScreen extends StatefulWidget {
static const String id = 'ForgotPasswordScreen';

@override
_ForgotPasswordScreen createState() => _ForgotPasswordScreen();
}

class _ForgotPasswordScreen extends State<ForgotPasswordScreen> {
final _formKey0 = GlobalKey<FormState>();
final resetAlert = MyFlutterAlert.instance;
String _email;
AuthResultStatus _emailStatus;
bool _inAsyncCall = false;

void _submitRestForm() async {

final form = _formKey0.currentState;
final _manager = UserManager.instance;

if (form.validate()) {
print(_email);

setState(() {
_inAsyncCall = true;
});
_emailStatus = await _manager.resetPassword(_email);

if (_emailStatus == AuthResultStatus.successful) {
//show alert
resetAlert.showAlert(
buttonText: 'OK',
onPressed: () => Navigator.popAndPushNamed(context, LoginScreen.id),
context: context,
alertType: AlertType.success,
description: 'Reset link sent!');
} else {
//show alert
resetAlert.showAlert(
buttonText: 'OK',
onPressed: () =>
Navigator.popAndPushNamed(context, ForgotPasswordScreen.id),
context: context,
alertType: AlertType.error,
description: AuthExceptionHandler.generateExceptionMessage(_emailStatus));
}
}
setState(() {
_inAsyncCall = false;
});
}

@override
Widget build(BuildContext context) {
return Container();
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text(
'Rest Password',
style: TextStyle(letterSpacing: 2.0),
),
backgroundColor: Colors.teal,
elevation: 5.0,
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
),
body: ModalProgressHUD(
inAsyncCall: _inAsyncCall,
progressIndicator: CircularProgressIndicator(
backgroundColor: Colors.tealAccent,
),
child: Container(
color: kBackgroundColor,
child: Center(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
// child: Container(
child: Column(
children: <Widget>[
Container(
// child: LoginTextAnim(headingText: 'GEZA MY CAR', ),
child: Text(
'Rest Password',
style: TextStyle(
color: Colors.white,
fontSize: 25,
),
),
),
SizedBox(
height: 20.0,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
bottomRight: Radius.circular(30.0),
),
),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 10.0),
child: Form(
key: _formKey0,
child: Column(
children: <Widget>[
CustomTextFormField(
onChanged: (String email) {
_email = email.trim();
},
labelText: 'Email',
isText: false,
isEmail: true,
icon: Icons.email,
validator: (String _email) {
return FormValidator.validateEmail(
email: _email);
},
),
SizedBox(
height: 10.0,
),
CustomMaterialButton(
onPressed: _submitRestForm,
title: 'Reset',
),
],
),
),
),
),
),
],
),
// ),
),
),
),
),
),
);
}
}
Loading