-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from niloysikdar/database
Database
- Loading branch information
Showing
11 changed files
with
381 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "738401306408", | ||
"project_id": "plaso-connect-demo", | ||
"storage_bucket": "plaso-connect-demo.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:738401306408:android:ffd9fe0392346ec6ea721d", | ||
"android_client_info": { | ||
"package_name": "com.example.plaso_connect" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "738401306408-j2pu2fmtuhmkbe2k5sks08ptjlmutik4.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.example.plaso_connect", | ||
"certificate_hash": "d7126d7e8df9109930d3da8d61331117d2282ed3" | ||
} | ||
}, | ||
{ | ||
"client_id": "738401306408-6vobpdsuchf4ovvrgmvgvvp33fqf3q7e.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCM2ndPvkDWVKg7-SLGwdTVd5is-OhZ87Q" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "738401306408-6vobpdsuchf4ovvrgmvgvvp33fqf3q7e.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class DonorModel { | ||
final String name; | ||
final String phone; | ||
final String age; | ||
final String address; | ||
final String pin; | ||
final String bloodGroup; | ||
final String covidStatus; | ||
final String dateOfRecovery; | ||
final String vaccinationStatus; | ||
|
||
DonorModel({ | ||
required this.name, | ||
required this.phone, | ||
required this.age, | ||
required this.address, | ||
required this.pin, | ||
required this.bloodGroup, | ||
required this.covidStatus, | ||
required this.dateOfRecovery, | ||
required this.vaccinationStatus, | ||
}); | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'name': name, | ||
'phone': phone, | ||
'age': age, | ||
'address': address, | ||
'pin': pin, | ||
'bloodGroup': bloodGroup, | ||
'covidStatus': covidStatus, | ||
'dateOfRecovery': dateOfRecovery, | ||
'vaccinationStatus': vaccinationStatus, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:plaso_connect/constants/colors.dart'; | ||
import 'package:plaso_connect/models/donormodel.dart'; | ||
import 'package:plaso_connect/widgets/boxdecoration.dart'; | ||
|
||
class DonorList extends StatefulWidget { | ||
@override | ||
_DonorListState createState() => _DonorListState(); | ||
} | ||
|
||
class _DonorListState extends State<DonorList> { | ||
// late Stream alldonors; | ||
|
||
// getallDonors() { | ||
// alldonors = DatabaseMethod().getDonors(pin: "733202"); | ||
// setState(() {}); | ||
// } | ||
|
||
// @override | ||
// void initState() { | ||
// super.initState(); | ||
// getallDonors(); | ||
// } | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
Size size = MediaQuery.of(context).size; | ||
return SafeArea( | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: Text("Donor List"), | ||
centerTitle: true, | ||
), | ||
body: Container( | ||
height: size.height, | ||
width: size.width, | ||
child: StreamBuilder( | ||
stream: FirebaseFirestore.instance | ||
.collection("plasmaDonors") | ||
.snapshots(), | ||
builder: | ||
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { | ||
if (snapshot.hasData) { | ||
return ListView.builder( | ||
itemCount: snapshot.data!.docs.length, | ||
itemBuilder: (context, index) { | ||
DonorModel donorModel = DonorModel( | ||
name: snapshot.data!.docs[index]["name"], | ||
phone: snapshot.data!.docs[index]["phone"], | ||
age: snapshot.data!.docs[index]["age"], | ||
address: snapshot.data!.docs[index]["address"], | ||
pin: snapshot.data!.docs[index]["pin"], | ||
bloodGroup: snapshot.data!.docs[index]["bloodGroup"], | ||
covidStatus: snapshot.data!.docs[index]["covidStatus"], | ||
dateOfRecovery: snapshot.data!.docs[index] | ||
["dateOfRecovery"], | ||
vaccinationStatus: snapshot.data!.docs[index] | ||
["vaccinationStatus"], | ||
); | ||
return donorCard( | ||
donorModel: donorModel, | ||
size: size, | ||
); | ||
}, | ||
); | ||
} else if (snapshot.hasError) { | ||
return Text("Error"); | ||
} else { | ||
return Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
} | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget donorCard({required DonorModel donorModel, required Size size}) { | ||
return Container( | ||
margin: EdgeInsets.all(20), | ||
padding: EdgeInsets.all(20), | ||
decoration: newboxDecoration(), | ||
width: size.width, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
"${donorModel.name}, ${donorModel.age}, ${donorModel.bloodGroup}", | ||
style: TextStyle( | ||
color: kelectronBlue, | ||
fontSize: 22, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
SizedBox(height: 3), | ||
Text( | ||
donorModel.address, | ||
style: TextStyle( | ||
color: kelectronBlue, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w500, | ||
), | ||
), | ||
SizedBox(height: 3), | ||
Text( | ||
"PIN: ${donorModel.pin}", | ||
style: TextStyle( | ||
color: kelectronBlue, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
SizedBox(height: 3), | ||
Text( | ||
"Phone: ${donorModel.phone}", | ||
style: TextStyle( | ||
color: kelectronBlue, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
SizedBox(height: 3), | ||
Text( | ||
(donorModel.vaccinationStatus == "0") | ||
? "Not Vaccinated yet" | ||
: "Vaccinated", | ||
style: TextStyle( | ||
color: kelectronBlue, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w500, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.