Commit 7cfdc22c authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Merge branch 'EAnalyzer_KarunaratneGP' of http://gitlab.sliit.lk/2021-035/2021-035-covidefender

parents 89c65262 866f2436
......@@ -38,7 +38,7 @@ getDate(date){
getTime(time){
this.time= time;
}
//---------------------------------------------Create Data-----------------------------------------------------
createData(){
print("object");
......@@ -59,6 +59,52 @@ createData(){
}
//---------------------------------------------Read Data-----------------------------------------------------
readData(){
DocumentReference documentReference = Firestore.instance.collection("RiskLocation").document(userName);
documentReference.get().then((datasnapshot){
print(datasnapshot.data()["userName"]);
print(datasnapshot.data()["phoneNumber"]);
print(datasnapshot.data()["riskLocation"]);
print(datasnapshot.data()["hotelName"]);
print(datasnapshot.data()["date"]);
print(datasnapshot.data()["time"]);
});
}
//---------------------------------------------Update Data-----------------------------------------------------
updateData(){
print("object");
DocumentReference documentReference = Firestore.instance.collection("RiskLocation").document(userName);
Map<String, dynamic> locations ={
"userName": userName,
"phoneNumber": phoneNumber,
"riskLocation": riskLocation,
"hotelName": hotelName,
"date": date,
"time": time
};
documentReference.setData(locations).whenComplete(() {
print("$userName Updated");
});
}
//---------------------------------------------Delete Data-----------------------------------------------------
deleteData(){
DocumentReference documentReference = Firestore.instance.collection("RiskLocation").document(userName);
documentReference.delete().whenComplete((){
print("$userName Deleted");
});
}
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
//---------------------------------------------User Name-----------------------------------------------------
Widget _buildName(){
......@@ -82,6 +128,8 @@ Widget _buildName(){
Widget _buildPNo(){
return TextFormField(
decoration: InputDecoration(labelText: 'Phone Number'),
keyboardType: TextInputType.phone,
maxLength: 10,
validator: (String value){
if (value.isEmpty) {
return '*Phone Number is Required';
......@@ -154,8 +202,6 @@ Widget _buildDate(){
Widget _buildTime(){
return TextFormField(
decoration: InputDecoration(labelText: 'Time'),
keyboardType: TextInputType.phone,
maxLength: 10,
validator: (String value){
if (value.isEmpty) {
return '*Time is Required';
......@@ -183,8 +229,9 @@ Widget _buildTime(){
margin: EdgeInsets.all(24),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
child: ListView(
scrollDirection: Axis.vertical,
//mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildName(),
_buildPNo(),
......@@ -196,32 +243,63 @@ Widget _buildTime(){
SizedBox(height: 100),
RaisedButton(
color: Colors.green,
child: Text(
'Submit',
style: TextStyle(color: Colors.green, fontSize: 18),
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
if(!_formKey.currentState.validate()) {
return;
}
// _formKey.currentState.save();
createData();
// print(_fName);
// print(_lName);
// print(_age);
// print(_address);
// print(_nic);
// print(_phoneNumber);
// print(_riskLocation);
// print(_hotelName);
// print(_date);
// print(_time);
} ,
),
createData();
RaisedButton(
color: Colors.blue,
child: Text(
'View',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
readData();
} ,
)
),
RaisedButton(
color: Colors.yellowAccent[700],
child: Text(
'Update',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
updateData();
} ,
),
RaisedButton(
color: Colors.red,
child: Text(
'Delete',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
deleteData();
} ,
),
],
),),
......
import 'package:covidefender/EAnalyzer/HospitalDetails.dart';
import 'package:flutter/material.dart';
import 'AddLocation.dart';
......@@ -134,6 +135,26 @@ class EAnalyzerDash extends StatelessWidget {
],
)
),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
elevation: 4,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlatButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HospitalDetails()),
);
},
child: Image.asset('lib/assets/images/search80.png'),
),
Text('Search Hospitals', style: TextStyle(fontSize: 20.0))
],
)
),
],
),
)
......
import 'package:covidefender/EAnalyzer/AddLocation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
class HospitalDetails extends StatefulWidget {
HospitalDetails({Key key,this.title}) :super(key: key);
final String title;
@override
_HospitalDetailsState createState() => _HospitalDetailsState();
}
class _HospitalDetailsState extends State<HospitalDetails> {
//---------------------------------------------------------------------------------------------------------------------------------------
// Future<List<Hospital>> _getHospitals() async{
// var data = await http.get("https://www.hpb.health.gov.lk/api/get-current-statistical");
// var jsonData = json.decode(data.body);
// List<Hospital> hospitals = [];
// for(var hospital in jsonData["data"]){
// Hospital newHospital =Hospital(hospital["update_date_time"],hospital["local_new_cases"]);
// //, hospital["cumulative_local"], hospital["cumulative_foreign"], hospital["created_at"]
// hospitals.add(newHospital);
// }
// return hospitals;
// }
//---------------------------------------------------------------------------------------------------------------------------------------
Map data;
List userData;
Future getData() async{
http.Response response = await http.get("https://www.hpb.health.gov.lk/api/get-current-statistical");
data = json.decode(response.body);
setState(() {
userData = data["data"]["hospital_data"];
});
debugPrint(userData.toString());
}
@override
void initState() {
super.initState();
getData();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text("Search Hospitals COVID-19 Details"),
),
body: ListView.builder(
itemCount: userData == null ? 0 : userData.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
CircleAvatar(
//backgroundImage: NetworkImage(userData[index]["hospital_id"]) ,
),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text("Hospital ID: ${userData[index]["hospital_id"]}\n${userData[index]["hospital"]["name"]}\n${userData[index]["hospital"]["name_si"]}\n\nTotal Patients: ${userData[index]["cumulative_total"]}\nDate/Time: ${userData[index]["created_at"]}",
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
),),
),
// Text("\n\n\n\n\n\n\n\n\n${userData[index]["created_at"]}"),
// Text("${userData[index]["email"]}"),
],
),
),
);
},
),
//-----------------------------------------------------------------------------------------------------------------------------------------
// body: Container(
// child: FutureBuilder(
// //future: _getHospitals(),
// builder: (BuildContext context, AsyncSnapshot snapshot){
// if (snapshot.data == null) {
// return Container(
// child: Center(
// child: Text("No data....."),
// ),
// );
// }else{
// return ListView.builder(
// itemCount: snapshot.data.lenght,
// itemBuilder: (BuildContext context, int index){
// return ListTile(
// title: Text(snapshot.data[index].updateDateTime),
// subtitle: Text(snapshot.data[index].localNewCases),
// );
// },
// );
// }
// },
// ),
// ),
//---------------------------------------------------------------------------------------------------------------------------------------
);
}
}
//-----------------------------------------Class Hospital--------------------------------------------------
// class Hospital{
// final String date;
// final String count;
// final String hospitalId;
// final String hospital;
// final String cumulativeLocal;
// final String cumulativeForeign;
// final String createdAt;
//Hospital(this.hospitalId,this.hospital,this.cumulativeLocal,this.cumulativeForeign,this.createdAt);
// Hospital(this.date,this.count);
// }
\ No newline at end of file
......@@ -107,7 +107,7 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
fake_async:
dependency: transitive
description:
......@@ -158,6 +158,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
http_parser:
dependency: transitive
description:
......@@ -220,21 +227,21 @@ packages:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
version: "0.5.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.2.1"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
version: "1.11.1"
petitparser:
dependency: transitive
description:
......@@ -344,7 +351,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
version: "5.1.2"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.24.0-7.0"
......@@ -21,29 +21,37 @@ environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_svg: ^0.22.0
cloud_firestore: ^0.14.3
firebase_core : ^0.5.0
tflite: ^1.1.1
oktoast: ^2.3.2
quiver: ^2.0.0
cloud_firestore: ^0.14.3
firebase_core : ^0.5.0
wakelock: ^0.1.4+1
charts_flutter: ^0.9.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
http: ^0.12.2
#add dependencies for heart rate module
charts_flutter: ^0.9.0
wakelock: ^0.1.4+1
camera:
git:
url: http://github.com/indikaNK/plugins.git
path: packages/camera/camera
dev_dependencies:
flutter_test:
sdk: flutter
......@@ -75,6 +83,8 @@ flutter:
- lib/assets/images/feedback80.png
- lib/assets/images/list80.png
- lib/assets/images/search80.png
- lib/assets/
- lib/assets/images/awrenessLevel.png
- lib/assets/images/exit.png
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment