Skip to content

Commit

Permalink
Added Forget Password Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimrehman1 committed Jul 26, 2021
1 parent d36e546 commit 088e042
Show file tree
Hide file tree
Showing 31 changed files with 311 additions and 88 deletions.
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
package="com.example.app">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="app"
android:icon="@mipmap/ic_launcher">
android:label="Plastify"
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 assets/icon/recycle_logo.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 ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/widgets/admin_dashboard_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _AdminDashboardWidgetState extends State<AdminDashboardWidget> {

Future getAllDeals(managerEmail) async {
var dealUrl = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals.json");

var allEmailsResult = await http.get(dealUrl);
Map body = json.decode(allEmailsResult.body);
Expand All @@ -36,7 +36,7 @@ class _AdminDashboardWidgetState extends State<AdminDashboardWidget> {

void addManager() async {
var url = Uri.parse(
"https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyD6FVCXVR7SqRD2rjavBUAantQxi8Qpz-4");
"https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyDpgSXCIPigSzmvciQnauTbvLfQVOjrH94");
var result = await http.post(url,
body: json.encode({
"email": managerEmail,
Expand Down
20 changes: 12 additions & 8 deletions lib/widgets/dashboard_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {

Future getAllDeals() async {
var dealUrl = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals.json");

var allEmailsResult = await http.get(dealUrl);
Map body = json.decode(allEmailsResult.body);
Expand Down Expand Up @@ -62,7 +62,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
var dataId = preference.getString('dataId');

var url2 = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/usersdata/$dataId.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/usersdata/$dataId.json");

var result2 = await http.get(url2);

Expand All @@ -79,7 +79,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
var dataId = preference.getString('dataId');
print(dataId);
var url3 = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/usersdata/$dataId.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/usersdata/$dataId.json");

var result3 = await http.patch(url3,
headers: {"Content-Type": "application/json"},
Expand All @@ -97,7 +97,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
void changeEmail() async {
final SharedPreferences preference = await SharedPreferences.getInstance();
var urlForEmail = Uri.parse(
"https://identitytoolkit.googleapis.com/v1/accounts:update?key=AIzaSyD6FVCXVR7SqRD2rjavBUAantQxi8Qpz-4");
"https://identitytoolkit.googleapis.com/v1/accounts:update?key=AIzaSyDpgSXCIPigSzmvciQnauTbvLfQVOjrH94");
var result4 = await http.post(urlForEmail,
body: json.encode({
"idToken": preference.getString("idToken").toString(),
Expand All @@ -113,7 +113,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
var dataId = preference.getString('dataId');

var url2 = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/usersdata/$dataId.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/usersdata/$dataId.json");

var data = await http.get(url2);
var redeem = json.decode(data.body)['previousRedeems'];
Expand All @@ -126,7 +126,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {

void updateRedeem(Map deal) async {
var urlForRedeem = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals/manager.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals/manager.json");
allDeals = allDeals.map((e) {
if (e['dealName'] == deal['dealName']) {
e['redeems'] += 1;
Expand All @@ -146,7 +146,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
var dataId = preference.getString('dataId');

var url2 = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/usersdata/$dataId.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/usersdata/$dataId.json");

var data = await http.get(url2);
var decodedRedeem = json.decode(data.body);
Expand Down Expand Up @@ -250,7 +250,11 @@ class _DashboardWidgetState extends State<DashboardWidget> {
print(location);
var arr = allDeals.where((val) {
print(val['address']);
if (val['address'].toString().toLowerCase().contains(location) == true) {
if (val['address']
.toString()
.toLowerCase()
.contains(location.toLowerCase()) ==
true) {
return true;
}
return false;
Expand Down
105 changes: 105 additions & 0 deletions lib/widgets/forgotPassword_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import "package:flutter/material.dart";
import "package:flutter_icons/flutter_icons.dart";
import "package:shared_preferences/shared_preferences.dart";

import "package:http/http.dart" as http;
import "dart:convert";
import "package:fluttertoast/fluttertoast.dart";

class ForgotPasswordWidget extends StatefulWidget {
const ForgotPasswordWidget({Key? key}) : super(key: key);

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

class _ForgotPasswordWidgetState extends State<ForgotPasswordWidget> {
String emailAddress = "";
String password = "";

void updatePassword() async {
final SharedPreferences preference = await SharedPreferences.getInstance();
var changePasswordURI = Uri.parse(
"https://identitytoolkit.googleapis.com/v1/accounts:update?key=AIzaSyDpgSXCIPigSzmvciQnauTbvLfQVOjrH94");

var result4 = await http.post(changePasswordURI,
body: json.encode({
"idToken": preference.getString("idToken").toString(),
"password": password,
"returnSecureToken": false
}));

print(json.decode(result4.body));

Fluttertoast.showToast(
msg: "Password has been Updated!!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
Navigator.of(context).pop();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Set New Password",
),
backgroundColor: Color.fromRGBO(0, 200, 0, 1),
),
body: Container(
width: double.infinity,
padding: EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image(
image: AssetImage('assets/images/petbottle_logo.png'),
width: 200,
height: 200,
),
Container(margin: EdgeInsets.only(top: 20.0)),
TextFormField(
decoration: InputDecoration(
labelText: "Current Email Address",
prefixIcon: Icon(FlutterIcons.email_check_outline_mco,
color: Color.fromRGBO(0, 200, 0, 1)),
),
keyboardType: TextInputType.emailAddress,
onChanged: (v) {
emailAddress = v;
},
maxLength: 50,
),
TextField(
decoration: InputDecoration(
labelText: "New Password",
prefixIcon: Icon(FlutterIcons.lock_outline_mdi,
color: Color.fromRGBO(0, 200, 0, 1)),
),
obscureText: true,
onChanged: (v) {
password = v;
},
maxLength: 30,
),
Container(
margin: EdgeInsets.only(top: 30.0),
child: ElevatedButton(
child: Text("Update Password"),
onPressed: () => updatePassword(),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Colors.lightGreen.shade800),
fixedSize: MaterialStateProperty.all(
Size.fromWidth(320))))),
],
))));
}
}
21 changes: 18 additions & 3 deletions lib/widgets/login_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "package:shared_preferences/shared_preferences.dart";
import "./dashboard_widget.dart";
import "./manager_dashboard_widget.dart";
import "./admin_dashboard_widget.dart";
import "./forgotPassword_widget.dart";

class LoginWidget extends StatefulWidget {
@override
Expand All @@ -24,7 +25,7 @@ class _LoginWidgetState extends State<LoginWidget> {

void loginUser(ctx) async {
final url = Uri.parse(
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyD6FVCXVR7SqRD2rjavBUAantQxi8Qpz-4");
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyDpgSXCIPigSzmvciQnauTbvLfQVOjrH94");

emailAddress = emailController.text;
password = passwordController.text;
Expand Down Expand Up @@ -92,7 +93,7 @@ class _LoginWidgetState extends State<LoginWidget> {
),
body: Container(
width: double.infinity,
padding: EdgeInsets.all(16.0),
padding: EdgeInsets.only(right: 15.0, left: 15.0, top: 0.0),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -103,7 +104,7 @@ class _LoginWidgetState extends State<LoginWidget> {
width: 200,
height: 200,
),
Container(margin: EdgeInsets.only(top: 20.0)),
Container(margin: EdgeInsets.only(top: 10.0)),
TextFormField(
controller: emailController,
decoration: InputDecoration(
Expand Down Expand Up @@ -142,6 +143,20 @@ class _LoginWidgetState extends State<LoginWidget> {
Size.fromWidth(320))))),
Container(
padding: EdgeInsets.only(top: 10.0, bottom: 20.0),
child: Material(
child: InkWell(
child: Text(
"Forgot Password?",
style: TextStyle(decoration: TextDecoration.underline),
),
onTap: () => Navigator.of(context)
.push(MaterialPageRoute(builder: (_) {
return ForgotPasswordWidget();
})),
hoverColor: Color.fromRGBO(0, 255, 0, 1),
))),
Container(
padding: EdgeInsets.only(bottom: 20.0),
child: Material(
child: InkWell(
child: Text(
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/manager_dashboard_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class _ManagerDashboardWidgetState extends State<ManagerDashboardWidget> {

Future getAllDeals(managerEmail) async {
var dealUrl = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");

var allEmailsResult = await http.get(dealUrl);
var body = json.decode(allEmailsResult.body);
Expand Down Expand Up @@ -73,7 +73,7 @@ class _ManagerDashboardWidgetState extends State<ManagerDashboardWidget> {
final SharedPreferences preference = await SharedPreferences.getInstance();
var managerEmail = preference.getString('email')?.split("@")[0];
var dealUrl = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");

getAllDeals(managerEmail).whenComplete(() async {
print(allDeals);
Expand Down Expand Up @@ -124,7 +124,7 @@ class _ManagerDashboardWidgetState extends State<ManagerDashboardWidget> {
final SharedPreferences preference = await SharedPreferences.getInstance();
var managerEmail = preference.getString('email')?.split("@")[0];
var dealUrl = Uri.parse(
"https://petbottle-project-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");
"https://petbottle-project-ae85a-default-rtdb.firebaseio.com/managerdeals/$managerEmail.json");

var result2 = await http.patch(dealUrl,
headers: {"Content-Type": "application/json"},
Expand Down
Loading

0 comments on commit 088e042

Please sign in to comment.