Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
riddhiss19 committed Sep 22, 2023
2 parents 68d96d3 + 777e14f commit 5b0b7a3
Show file tree
Hide file tree
Showing 16 changed files with 1,569 additions and 762 deletions.
597 changes: 305 additions & 292 deletions right_aid/lib/case_request.dart

Large diffs are not rendered by default.

449 changes: 240 additions & 209 deletions right_aid/lib/case_status.dart

Large diffs are not rendered by default.

453 changes: 231 additions & 222 deletions right_aid/lib/current_case.dart

Large diffs are not rendered by default.

85 changes: 78 additions & 7 deletions right_aid/lib/file_greivance.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,73 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:right_aid/firebase_options.dart';
import 'utilities/form_validation.dart';

class FileGrievance extends StatelessWidget {
class FileGrievance extends StatefulWidget {
const FileGrievance({super.key});
@override
State<FileGrievance> createState() => _FileGrievance();
}

class _FileGrievance extends State<FileGrievance> {
late final TextEditingController inmateName;
late final TextEditingController prisonName;
late final TextEditingController location;
late final TextEditingController relation;
late final TextEditingController password;

@override
void initState() {
inmateName = TextEditingController();
prisonName = TextEditingController();
location = TextEditingController();
relation = TextEditingController();
password = TextEditingController();
super.initState();
}

void fileGrievance() async {
try {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform);
print('Initialized');
} catch (e) {
print('Error initializing Firebase: $e');
}
final inmateDocumentReference =
FirebaseFirestore.instance.collection('file_grievance').doc();
await inmateDocumentReference.set({
'inmate_name': inmateName.text,
'prison_name': prisonName.text,
'location': location.text,
'relation': relation.text,
'password': password.text,
});
}

void clicked() {
if (FormValidation.isTextEditingControllerEmpty(inmateName) ||
FormValidation.isTextEditingControllerEmpty(prisonName) ||
FormValidation.isTextEditingControllerEmpty(location) ||
FormValidation.isTextEditingControllerEmpty(relation) ||
FormValidation.isTextEditingControllerEmpty(password)) {
FormValidation.showToast('Fill all details in the Form');
} else {
fileGrievance();
FormValidation.showToast("Grievance Submitted");
}
}

@override
void dispose() {
inmateName.dispose();
prisonName.dispose();
location.dispose();
relation.dispose();
password.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -45,9 +111,10 @@ class FileGrievance extends StatelessWidget {
const SizedBox(
height: 10,
),
const Padding(
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: TextField(
controller: inmateName,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -62,9 +129,10 @@ class FileGrievance extends StatelessWidget {
const SizedBox(
height: 10,
),
const Padding(
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: TextField(
controller: prisonName,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -80,9 +148,10 @@ class FileGrievance extends StatelessWidget {
const SizedBox(
height: 10,
),
const Padding(
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: TextField(
controller: location,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -98,9 +167,10 @@ class FileGrievance extends StatelessWidget {
const SizedBox(
height: 10,
),
const Padding(
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: TextField(
controller: relation,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -116,9 +186,10 @@ class FileGrievance extends StatelessWidget {
const SizedBox(
height: 10,
),
const Padding(
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: TextField(
controller: password,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -137,7 +208,7 @@ class FileGrievance extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: ElevatedButton(
onPressed: () => {},
onPressed: () => {clicked()},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<
Color>(
Expand Down
6 changes: 3 additions & 3 deletions right_aid/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Home extends StatelessWidget {
Text(
"28",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 26),
TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
),
SizedBox(
width: 10,
Expand All @@ -50,12 +50,12 @@ class Home extends StatelessWidget {
Text(
"OCT",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
fontWeight: FontWeight.bold, fontSize: 18),
),
Text(
"2023",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
fontWeight: FontWeight.bold, fontSize: 18),
),
],
)
Expand Down
43 changes: 34 additions & 9 deletions right_aid/lib/inmate_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:right_aid/firebase_options.dart';
import 'package:right_aid/inmate_signup.dart';
import 'utilities/form_validation.dart';
import 'utilities/user.dart';
import 'utilities/fetch_details.dart';
import 'home.dart';

class InmateLogin extends StatefulWidget {
const InmateLogin({super.key});
Expand All @@ -14,7 +18,6 @@ class InmateLogin extends StatefulWidget {
class _InmateLoginState extends State<InmateLogin> {
late final TextEditingController password;
late final TextEditingController cnr;

@override
void initState() {
cnr = TextEditingController();
Expand All @@ -41,19 +44,29 @@ class _InmateLoginState extends State<InmateLogin> {
// FirebaseFirestore.instance.collection('inmate').doc();
final CollectionReference inmateCollection =
FirebaseFirestore.instance.collection('inmate');
final QuerySnapshot querySnapshotOne = await inmateCollection
.where('cnr', isEqualTo: int.parse(cnr.text))
.get();
final QuerySnapshot querySnapshotOne =
await inmateCollection.where('cnr', isEqualTo: cnr.text).get();
if (querySnapshotOne.docs.isNotEmpty) {
final QuerySnapshot querySnapshotTwo = await inmateCollection
.where('cnr', isEqualTo: int.parse(cnr.text))
.where('is_verified', isEqualTo: true)
.where('cnr', isEqualTo: cnr.text)
.where('password', isEqualTo: (password.text))
.get();

if (querySnapshotTwo.docs.isNotEmpty) {
FormValidation.showToast('LogIn');
final QuerySnapshot querySnapshotThree = await inmateCollection
.where('cnr', isEqualTo: cnr.text)
.where('is_verified', isEqualTo: true)
.get();
if (querySnapshotThree.docs.isNotEmpty) {
FormValidation.showToast('LogIn Successful');
Navigator.push(
context, MaterialPageRoute(builder: (context) => Home()));
} else {
//we can add alertbox
FormValidation.showToast('Verification Pending');
}
} else {
//we can add alertbox
FormValidation.showToast('Verification Pending');
FormValidation.showToast('Incorrect Password');
}
} else {
FormValidation.showToast('CNR not found');
Expand Down Expand Up @@ -167,6 +180,18 @@ class _InmateLoginState extends State<InmateLogin> {
],
),
),
const SizedBox(
height: 5,
),
TextButton(
onPressed: () => {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InmateSignup()))
},
child: const Text("Create an account instead")),
const SizedBox(
height: 30,
),
Expand Down
7 changes: 6 additions & 1 deletion right_aid/lib/inmate_signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'utilities/form_validation.dart';
import 'firebase_options.dart';
import 'inmate_login.dart';
import 'utilities/form_validation.dart';

class InmateSignup extends StatefulWidget {
const InmateSignup({super.key});
Expand Down Expand Up @@ -37,7 +39,7 @@ class _InmateSignupState extends State<InmateSignup> {
'name': name.text,
'gender': gender.text,
'age': int.parse(age.text),
'cnr': int.parse(cnr.text),
'cnr': cnr.text,
'pid': int.parse(pid.text),
'handler_name': handlerName.text,
'phone_no': int.parse(phoneNo.text),
Expand All @@ -62,6 +64,9 @@ class _InmateSignupState extends State<InmateSignup> {
FormValidation.showToast('Fill all details in the Form');
} else {
storeInmateData();
FormValidation.showToast('SignUp Successful');
Navigator.push(
context, MaterialPageRoute(builder: (context) => (InmateLogin())));
}
}

Expand Down
6 changes: 3 additions & 3 deletions right_aid/lib/lawyer_connect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LawyerConnect extends StatelessWidget {

@override
Widget build(BuildContext context) {
return (Scaffold(
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
Expand All @@ -15,7 +15,7 @@ class LawyerConnect extends StatelessWidget {
child: Column(children: [
Row(
children: [
const TextField(
const TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide:
Expand Down Expand Up @@ -68,6 +68,6 @@ class LawyerConnect extends StatelessWidget {
])),
)
])),
));
);
}
}
Loading

0 comments on commit 5b0b7a3

Please sign in to comment.