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 3 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'
6 changes: 4 additions & 2 deletions lib/common/myflutter_alert.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:gezamycar/utils/constants.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import '../screens/login_screen.dart';

class MyFlutterAlert {
MyFlutterAlert._internal();
Expand All @@ -15,7 +16,8 @@ class MyFlutterAlert {
{BuildContext context,
AlertType alertType,
String description,
String buttonText}) {
String buttonText,
Function onPressed}) {
Alert(
context: context,
type: alertType,
Expand All @@ -29,7 +31,7 @@ class MyFlutterAlert {
fontSize: 20.0,
),
),
onPressed: () => Navigator.pop(context),
onPressed: onPressed,
width: 120,
)
],
Expand Down
3 changes: 1 addition & 2 deletions lib/models/contact.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:email_validator/email_validator.dart';
import 'package:gezamycar/exceptions/my_exception.dart';
import 'package:gezamycar/utils/constants.dart';
import 'package:gezamycar/utils/form_validators.dart';

import 'file:///C:/Users/mogokong/AndroidStudioProjects/geza_my_car/lib/exceptions/my_exception.dart';

class Contact extends FormValidator {
String _id;
String _phoneNumber;
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 @@ -34,4 +34,9 @@ class UserManager {
}

void registerUser(Person user) {}

// reset password
Future<void> resetPassword(String emailAddress) async {
return await _auth.resetPassword(emailAddress);
}
}
131 changes: 129 additions & 2 deletions lib/screens/forgot_password_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,136 @@

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.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';

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;

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

if (form.validate()) {
print(_email);
_manager.resetPassword(_email);
Joesta marked this conversation as resolved.
Show resolved Hide resolved
//show alert
resetAlert.showAlert(
// shows alert
buttonText: 'OK',
onPressed: () => Navigator.popAndPushNamed(context, LoginScreen.id),
context: context,
alertType: AlertType.success,
description: 'Reset link sent!');
}
}

@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',
),
],
),
),
),
),
),
],
),
// ),
),
),
),
),
);
}
}
4 changes: 1 addition & 3 deletions lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:gezamycar/screens/forgot_password_screen.dart';
import 'package:gezamycar/screens/signup_screen.dart';
import 'package:gezamycar/services/auth_services.dart';
import 'package:gezamycar/utils/constants.dart';
import 'package:gezamycar/utils/form_validators.dart';
import 'package:gezamycar/widgets/custom_flat_button.dart';
import 'package:gezamycar/widgets/custom_material_button.dart';
import 'package:gezamycar/widgets/custom_text_form.dart';
import 'package:gezamycar/widgets/login_text_anim.dart';

import 'file:///C:/Users/mogokong/AndroidStudioProjects/geza_my_car/lib/services/auth_services.dart';

class LoginScreen extends StatefulWidget {
static const String id = '/';

Expand Down
80 changes: 26 additions & 54 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.4.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
charcode:
characters:
dependency: transitive
description:
name: charcode
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
version: "1.0.0"
charcode:
dependency: transitive
description:
name: collection
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
version: "1.1.3"
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.0.1"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.14.13"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -78,6 +64,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
firebase:
dependency: transitive
description:
Expand Down Expand Up @@ -156,13 +149,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
intl:
dependency: transitive
description:
Expand All @@ -183,7 +169,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.8"
meta:
dependency: transitive
description:
Expand All @@ -204,21 +190,14 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -258,7 +237,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -286,28 +265,21 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.2.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.7.0 <3.0.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"