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

Forget password page is created. #211

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Copy link
Contributor

@farukyld farukyld Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may put a dummy class named "EmailVerification" containing a method called "login" here to suppress the compile errors emerging from "app/mobile/lib/view/forgetpassword/forgetpassinitScreen.dart" file.

Empty file.
95 changes: 95 additions & 0 deletions app/mobile/lib/view/forgetpassword/forgetpassinitScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:flutter/material.dart';
import 'package:email_validator/email_validator.dart';
import 'package:mobile_app/services/emailVerification.dart';
import 'package:mobile_app/view/utils/customTextField.dart';
import 'package:http/http.dart' as http;

class ForgetPassInitScreen extends StatefulWidget {

const ForgetPassInitScreen({super.key});

@override
State<ForgetPassInitScreen> createState() => _ForgetPassInitScreenState();
}

class _ForgetPassInitScreenState extends State<ForgetPassInitScreen> {

bool isEmailValid = true; // Track email validation
bool emptyEmail = false;
bool emailFound = false;


final TextEditingController emailController = TextEditingController();

void validateEmail(String email) {
setState(() {
emptyEmail = false;
if (email.isEmpty) {
isEmailValid = true;
} else {
isEmailValid = EmailValidator.validate(email);
}
});
}

void resetPass() async {
String email = emailController.text;
if (email.isEmpty) {
setState(() {
emptyEmail = true;
});
}

if (emptyEmail) {
return;
}
// Perform email verification and navigate to the next screen if successful
EmailVerification emailVerification = EmailVerification();
http.Response response = await emailVerification.login(email);
print(response.body);

//NEW: there will be code that connects response to emailFound

if(emailFound == true){
//Navigator.pushNamed(context, "");
}



}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Forget Password'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Enter your email to reset your password',
style: TextStyle(fontSize: 15.0),
),
SizedBox(height: 20.0),
CustomTextField(
labelText: 'Email',
controller: emailController,
keyboardType: TextInputType.emailAddress,
onChanged: validateEmail,
errorText: isEmailValid ? "" : 'Enter a valid email',
),
SizedBox(height: 20.0),
ElevatedButton(
onPressed: isEmailValid ? resetPass : null,
child: Text('Reset Password'),
),

],
),
),
);
}
}
15 changes: 12 additions & 3 deletions app/mobile/lib/view/login/loginScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:email_validator/email_validator.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:mobile_app/services/authService.dart';
import 'customTextField.dart';
import 'package:mobile_app/view/utils/customTextField.dart';
import 'package:mobile_app/view/signup/signupScreen.dart';

class LoginScreen extends StatefulWidget {
Expand Down Expand Up @@ -78,10 +78,12 @@ class _LoginScreenState extends State<LoginScreen> {
}

void navigateToSignupPage() {

Navigator.push(
context, MaterialPageRoute(builder: (context) => const SignupScreen()));
}


@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -115,8 +117,15 @@ class _LoginScreenState extends State<LoginScreen> {
onPressed: isEmailValid && isPasswordValid ? login : null,
child: const Text('Login'),
),
TextButton(
onPressed: () {
// Continue as Guest
Navigator.pushNamed(context, "/fpassinit");
},
child: const Text('Forget Password?'),
),
Padding(
padding: const EdgeInsets.all(10),
padding: const EdgeInsets.all(8),
child: Column(
children: [
Text(
Expand All @@ -133,7 +142,7 @@ class _LoginScreenState extends State<LoginScreen> {
),
const SizedBox(height: 16),
GestureDetector(
onTap: navigateToSignupPage,
onTap: () {Navigator.pushNamed(context, "/sign");},
child: const Text(
'Don\'t have an account? Sign up here',
style: TextStyle(
Expand Down
2 changes: 1 addition & 1 deletion app/mobile/lib/view/signup/signupScreen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:email_validator/email_validator.dart';
import 'package:mobile_app/view/login/customTextField.dart';
import 'package:mobile_app/view/utils/customTextField.dart';
import 'package:mobile_app/services/signuser.dart';

class SignupScreen extends StatefulWidget {
Expand Down