Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ers- into main
  • Loading branch information
anishsreenivas82 committed Jul 30, 2021
2 parents 17a2bc6 + 23440c3 commit 22f48c9
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 28 deletions.
22 changes: 12 additions & 10 deletions lib/pages/donor_dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Donor extends StatefulWidget {
class _DonorState extends State<Donor> {
@override
Widget build(BuildContext context) {
print(uidDonor);
return Scaffold(
appBar: AppBar(
title: Text("Dashboard"),
Expand All @@ -37,14 +38,13 @@ class _DonorState extends State<Donor> {
leading: Icon(Icons.map_outlined),
),
ListTile(
title: Text('Logout'),
leading: Icon(Icons.logout),
onTap: (){ FirebaseAuth.instance.signOut();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SplashScreen()));}
)
title: Text('Logout'),
leading: Icon(Icons.logout),
onTap: () {
FirebaseAuth.instance.signOut();
Navigator.push(context,
MaterialPageRoute(builder: (context) => SplashScreen()));
})
],
),
),
Expand Down Expand Up @@ -109,8 +109,10 @@ class _DonorState extends State<Donor> {
TextButton(
child: const Text('View'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Verified()));
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Verified()));
},
),
const SizedBox(width: 8),
Expand Down
11 changes: 11 additions & 0 deletions lib/pages/item_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterlogindesign/pages/donor_dashboard.dart';
import 'package:flutterlogindesign/pages/qr.dart';
import 'package:fluttertoast/fluttertoast.dart';

String generatedID;

Expand Down Expand Up @@ -95,6 +96,16 @@ class _State extends State<Itempage> {

generatedID = querySnapshot.id.toString() +
uidDonor.toString(); // Here we call the ID of the document
Fluttertoast.showToast(
msg: "Item added.",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);


});

Expand Down
88 changes: 71 additions & 17 deletions lib/pages/signin_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutterlogindesign/widgets/btn_widget.dart';
import 'package:flutterlogindesign/widgets/Headdersignup.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fluttertoast/fluttertoast.dart';

import 'donor_dashboard.dart';

Expand Down Expand Up @@ -135,17 +136,28 @@ class _LoginPageState extends State<LoginPage> {
if (documentSnapshot.exists) {
check = documentSnapshot.get("choice");
} else {
check = '0';
check = '(0)';
}
});
if (check == "(1)") {
if (check == "(3)" ||
check == "(2)" ||
check == "(0)") {
FirebaseAuth.instance.signOut();
Fluttertoast.showToast(
msg: "No account found",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print("No account found");
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Donor()));
} else {
FirebaseAuth.instance.signOut();
print("No account found");
}
} else if (choice == "(2)") {
FirebaseFirestore.instance
Expand All @@ -156,17 +168,28 @@ class _LoginPageState extends State<LoginPage> {
if (documentSnapshot.exists) {
check = documentSnapshot.get("choice");
} else {
check = '0';
check = '(0)';
}
});
if (check == "(2)") {
if (check == "(3)" ||
check == "(1)" ||
check == "(0)") {
FirebaseAuth.instance.signOut();
Fluttertoast.showToast(
msg: "No account found",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print("No account found");
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Shelter_page ()));
} else {
FirebaseAuth.instance.signOut();
print("No account found");
builder: (context) => Shelter_page()));
}
} else if (choice == "(3)") {
FirebaseFirestore.instance
Expand All @@ -177,23 +200,52 @@ class _LoginPageState extends State<LoginPage> {
if (documentSnapshot.exists) {
check = documentSnapshot.get("choice");
} else {
check = '0';
check = '(0)';
}
});
if (check == "(3)") {
if (check == "(2)" ||
check == "(1)" ||
check == "(0)") {
FirebaseAuth.instance.signOut();
Fluttertoast.showToast(
msg: "No account found",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print("No account found");
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Volunteer()));
} else {
FirebaseAuth.instance.signOut();
print("No account found");
}
}
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
Fluttertoast.showToast(
msg: "No user found for that email.",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print('No user found for that email.');
} else if (e.code == 'wrong-password') {
Fluttertoast.showToast(
msg: "Wrong password provided for that user.",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print('Wrong password provided for that user.');
}
}
Expand Down Expand Up @@ -225,6 +277,7 @@ class _LoginPageState extends State<LoginPage> {
color: Colors.black54,
decoration: TextDecoration.underline,
)),

]),
)
],
Expand All @@ -234,9 +287,10 @@ class _LoginPageState extends State<LoginPage> {
),
),
),

);
}

Widget _textInput({hint, icon, myController, obscure}) {
return Container(
margin: EdgeInsets.only(top: 10),
Expand Down
32 changes: 31 additions & 1 deletion lib/pages/signup_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutterlogindesign/pages/volunteer_page.dart';
import 'package:flutterlogindesign/widgets/btn_widget.dart';
import 'package:flutterlogindesign/widgets/Headdersignup.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:fluttertoast/fluttertoast.dart';

import 'donor_dashboard.dart';

Expand Down Expand Up @@ -127,12 +128,41 @@ class _RegPageState extends State<RegPage> {
}
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
Fluttertoast.showToast(
msg: "The password provided is too weak.",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
print('The password provided is too weak.');
} else if (e.code == 'email-already-in-use') {
} else if (e.code == 'email-already-in-use') {
Fluttertoast.showToast(
msg: "The account already exists for that email.",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);

print(
'The account already exists for that email.');
}
} catch (e) {
Fluttertoast.showToast(
msg: "$e",
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);

print(e);
}
},
Expand Down
Loading

0 comments on commit 22f48c9

Please sign in to comment.