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 5 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.
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);
}
}
149 changes: 147 additions & 2 deletions lib/screens/forgot_password_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,154 @@

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:gezamycar/enums/auth-result-status.dart';
import 'package:gezamycar/models/user_manager.dart';
import 'package:gezamycar/utils/constants.dart';
import 'package:gezamycar/widgets/custom_material_button.dart';
import 'package:gezamycar/widgets/custom_text_form.dart';
import '../widgets/custom_text_form.dart';
import '../widgets/login_text_anim.dart';
import 'package:gezamycar/utils/form_validators.dart';
import 'package:gezamycar/common/myflutter_alert.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'login_screen.dart';
import 'package:gezamycar/exceptions/my_exception.dart';

class ForgotPasswordScreen extends StatelessWidget {
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;

void _submitRestForm() async {
final form = _formKey0.currentState;
final _manager = UserManager.instance;

if (form.validate()) {
print(_email);
try {
_emailStatus = await _manager.resetPassword(_email);
}catch (e) {
print('---------------------------');
// print(e.toString());
// throw MyException(e.toString());
}
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: 'Invalid email address!');
}
}
}

@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: 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