Commit 885a0ba4 authored by indika N kumara's avatar indika N kumara

Merge branch 'EAnalyzer_KarunaratneGP' into 'develop_1'

E analyzer karunaratne gp

See merge request !26
parents 4aac3c3f c15ed477
...@@ -109,10 +109,23 @@ class AddLocationState extends State<AddLocation> { ...@@ -109,10 +109,23 @@ class AddLocationState extends State<AddLocation> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
//---------------------------------------------User Name----------------------------------------------------- //---------------------------------------------User Name-----------------------------------------------------
Widget _buildName() { Widget _buildName(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Full Name'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.face),
hintText: "Ex : John Smith",
labelText: 'Full Name'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Full Name is Required'; return '*Full Name is Required';
} }
...@@ -120,19 +133,31 @@ class AddLocationState extends State<AddLocation> { ...@@ -120,19 +133,31 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _fName = value; // _fName = value;
// }, // },
onChanged: (String name) { onChanged: (String name){
getUserName(name); getUserName(name);
}, },
); );
} }
//---------------------------------------------Phone Number----------------------------------------------------- //---------------------------------------------Phone Number-----------------------------------------------------
Widget _buildPNo() { Widget _buildPNo(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Phone Number'), decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.phone),
hintText: "Ex : 011XXXXXXX",
labelText: 'Phone Number'
),
keyboardType: TextInputType.phone, keyboardType: TextInputType.phone,
maxLength: 10, maxLength: 10,
validator: (String value) { validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Phone Number is Required'; return '*Phone Number is Required';
} }
...@@ -140,17 +165,29 @@ class AddLocationState extends State<AddLocation> { ...@@ -140,17 +165,29 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _lName = value; // _lName = value;
// }, // },
onChanged: (String id) { onChanged: (String id){
getPhoneNumber(phoneNumber); getPhoneNumber(phoneNumber);
}, },
); );
} }
//---------------------------------------------Risk Location----------------------------------------------------- //---------------------------------------------Risk Location-----------------------------------------------------
Widget _buildLocation() { Widget _buildLocation(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Risk Location'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.location_on),
hintText: "Ex : Galle",
labelText: 'Risk Location'
),
validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Risk Location is Required'; return '*Risk Location is Required';
} }
...@@ -158,17 +195,29 @@ class AddLocationState extends State<AddLocation> { ...@@ -158,17 +195,29 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _age = value; // _age = value;
// }, // },
onChanged: (String riskLocation) { onChanged: (String riskLocation){
getRiskLocation(riskLocation); getRiskLocation(riskLocation);
}, },
); );
} }
//---------------------------------------------Hotel Name----------------------------------------------------- //---------------------------------------------Hotel Name-----------------------------------------------------
Widget _buildHotelName() { Widget _buildHotelName(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Hotel Name'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.hotel),
hintText: "Ex : Hilton",
labelText: 'Hotel Name'
),
validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Hotel Name is Required'; return '*Hotel Name is Required';
} }
...@@ -176,17 +225,29 @@ class AddLocationState extends State<AddLocation> { ...@@ -176,17 +225,29 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _address = value; // _address = value;
// }, // },
onChanged: (String hotelName) { onChanged: (String hotelName){
getHotelName(hotelName); getHotelName(hotelName);
}, },
); );
} }
//---------------------------------------------Date----------------------------------------------------- //---------------------------------------------Date-----------------------------------------------------
Widget _buildDate() { Widget _buildDate(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Date'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.calendar_today),
hintText: "Ex : 2021/04/03",
labelText: 'Date'
),
validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Date is Required'; return '*Date is Required';
} }
...@@ -194,17 +255,30 @@ class AddLocationState extends State<AddLocation> { ...@@ -194,17 +255,30 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _nic = value; // _nic = value;
// }, // },
onChanged: (String date) { onChanged: (String date){
getDate(date); getDate(date);
}, },
); );
} }
//---------------------------------------------Time----------------------------------------------------- //---------------------------------------------Time-----------------------------------------------------
Widget _buildTime() { Widget _buildTime(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Time'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.lock_clock),
hintText: "Ex : 2.00 P.M",
labelText: 'Time'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) { if (value.isEmpty) {
return '*Time is Required'; return '*Time is Required';
} }
...@@ -212,11 +286,12 @@ class AddLocationState extends State<AddLocation> { ...@@ -212,11 +286,12 @@ class AddLocationState extends State<AddLocation> {
// onSaved: (String value){ // onSaved: (String value){
// _phoneNumber = value; // _phoneNumber = value;
// }, // },
onChanged: (String time) { onChanged: (String time){
getTime(time); getTime(time);
}, },
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -234,14 +309,21 @@ class AddLocationState extends State<AddLocation> { ...@@ -234,14 +309,21 @@ class AddLocationState extends State<AddLocation> {
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
//mainAxisAlignment: MainAxisAlignment.center, //mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
SizedBox(height: 10),
_buildName(), _buildName(),
SizedBox(height: 10),
_buildPNo(), _buildPNo(),
SizedBox(height: 10),
_buildLocation(), _buildLocation(),
SizedBox(height: 10),
_buildHotelName(), _buildHotelName(),
SizedBox(height: 10),
_buildDate(), _buildDate(),
SizedBox(height: 10),
_buildTime(), _buildTime(),
SizedBox(height: 100), //---------------------------------------------Submit-----------------------------------------------------
SizedBox(height: 50),
RaisedButton( RaisedButton(
color: Colors.green, color: Colors.green,
child: Text( child: Text(
...@@ -249,12 +331,14 @@ class AddLocationState extends State<AddLocation> { ...@@ -249,12 +331,14 @@ class AddLocationState extends State<AddLocation> {
style: TextStyle(color: Colors.white, fontSize: 18), style: TextStyle(color: Colors.white, fontSize: 18),
), ),
onPressed: () { onPressed: () {
if (!_formKey.currentState.validate()) { if(!_formKey.currentState.validate()) {
return; return;
} }
createData(); createData();
},
} ,
), ),
// RaisedButton( // RaisedButton(
...@@ -269,7 +353,7 @@ class AddLocationState extends State<AddLocation> { ...@@ -269,7 +353,7 @@ class AddLocationState extends State<AddLocation> {
// } , // } ,
// ), // ),
//---------------------------------------------Update-----------------------------------------------------
RaisedButton( RaisedButton(
color: Colors.yellowAccent[700], color: Colors.yellowAccent[700],
child: Text( child: Text(
...@@ -277,10 +361,12 @@ class AddLocationState extends State<AddLocation> { ...@@ -277,10 +361,12 @@ class AddLocationState extends State<AddLocation> {
style: TextStyle(color: Colors.white, fontSize: 18), style: TextStyle(color: Colors.white, fontSize: 18),
), ),
onPressed: () { onPressed: () {
updateData(); updateData();
},
),
} ,
),
//---------------------------------------------Delete-----------------------------------------------------
RaisedButton( RaisedButton(
color: Colors.red, color: Colors.red,
child: Text( child: Text(
...@@ -288,12 +374,17 @@ class AddLocationState extends State<AddLocation> { ...@@ -288,12 +374,17 @@ class AddLocationState extends State<AddLocation> {
style: TextStyle(color: Colors.white, fontSize: 18), style: TextStyle(color: Colors.white, fontSize: 18),
), ),
onPressed: () { onPressed: () {
deleteData(); deleteData();
},
} ,
), ),
], ],
), ),),
),
), ),
); );
} }
......
import 'package:covidefender/EAnalyzer/HospitalDetails.dart'; import 'package:covidefender/EAnalyzer/HospitalDetails.dart';
import 'package:covidefender/EAnalyzer/HotelMap.dart';
import 'package:covidefender/EAnalyzer/SearchEvent.dart'; import 'package:covidefender/EAnalyzer/SearchEvent.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'AddLocation.dart'; import 'AddLocation.dart';
import 'RiskEventList.dart';
class EAnalyzerDash extends StatelessWidget { class EAnalyzerDash extends StatelessWidget {
@override @override
...@@ -56,6 +58,7 @@ class EAnalyzerDash extends StatelessWidget { ...@@ -56,6 +58,7 @@ class EAnalyzerDash extends StatelessWidget {
primary: false, primary: false,
crossAxisCount: 2, crossAxisCount: 2,
children: <Widget>[ children: <Widget>[
//--------------------------------------Cards--------------------------------------------------------------------------------------
Card( Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)), borderRadius: BorderRadius.circular(8)),
...@@ -107,7 +110,7 @@ class EAnalyzerDash extends StatelessWidget { ...@@ -107,7 +110,7 @@ class EAnalyzerDash extends StatelessWidget {
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => EAnalyzerDash()), MaterialPageRoute(builder: (context) => RiskEventList()),
); );
}, },
child: Image.asset('lib/assets/images/list80.png'), child: Image.asset('lib/assets/images/list80.png'),
...@@ -156,6 +159,26 @@ class EAnalyzerDash extends StatelessWidget { ...@@ -156,6 +159,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) => HotelMap()),
);
},
child: Image.asset('lib/assets/images/feedback80.png'),
),
Text('Hotel Map', style: TextStyle(fontSize: 20.0))
],
)
),
], ],
), ),
) )
......
...@@ -72,6 +72,9 @@ class _HospitalDetailsState extends State<HospitalDetails> { ...@@ -72,6 +72,9 @@ class _HospitalDetailsState extends State<HospitalDetails> {
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
// CircleAvatar(
// ),
Padding( Padding(
padding: const EdgeInsets.all(12.0), 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"]}", 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"]}",
......
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class HotelMap extends StatefulWidget {
@override
_HotelMapState createState() => _HotelMapState();
}
class _HotelMapState extends State<HotelMap> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text("Hotel Google Map"),
),
body: Center(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(7.8731, 80.7718),
zoom: 8.0,
),
),
),
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class RiskEventList extends StatefulWidget {
const RiskEventList({ Key key }) : super(key: key);
@override
_RiskEventListState createState() => _RiskEventListState();
}
class _RiskEventListState extends State<RiskEventList> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text("Search Risk Hotels"),
),
body: ListPage(),
);
}
}
class ListPage extends StatefulWidget {
@override
_ListPageState createState() => _ListPageState();
}
class _ListPageState extends State<ListPage> {
Future _data;
Future getRiskLocation() async {
var firestore = Firestore.instance;
QuerySnapshot qn = await firestore.collection("RiskLocation").getDocuments();
return qn.documents;
}
navigateToDetail(DocumentSnapshot riskLocation){
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(riskLocation: riskLocation,)));
}
@override
void initState() {
// TODO: implement initState
super.initState();
_data = getRiskLocation();
}
@override
Widget build(BuildContext context) {
return Container(
child: FutureBuilder(
future: _data,
// ignore: missing_return
builder:(_, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SpinKitFadingCircle(
color: Colors.green,
size: 80.0,
),
);
}else{
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (_, index){
return Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.lightGreen[100],
child: ListTile(
leading: Icon(Icons.location_city, size: 40),
title: Text(snapshot.data[index].data()["hotelName"],style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),
subtitle: Text(snapshot.data[index].data()["riskLocation"],style: TextStyle(fontSize: 16.0),),
onTap: () => navigateToDetail(snapshot.data[index]),
),
);
});
}
} ),
);
}
}
class DetailPage extends StatefulWidget {
final DocumentSnapshot riskLocation;
DetailPage({this.riskLocation});
@override
_DetailPageState createState() => _DetailPageState();
}
class _DetailPageState extends State<DetailPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text(widget.riskLocation.data()["hotelName"]),
),
body: Container(
width: MediaQuery.of(context).size.width,
height: 100,
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
color: Colors.lightGreen[50],
child: ListTile(
leading: Icon(Icons.timelapse, size: 40),
title: Text("Date : ${widget.riskLocation.data()["date"]}" ,style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),
subtitle: Text("Time : ${widget.riskLocation.data()["time"]}",style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),
),
),
),
);
}
}
import 'package:flutter/material.dart'; // import 'dart:convert';
// import 'dart:html';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:intl/date_symbol_data_local.dart';
import 'dart:convert';
import 'dart:ffi';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:http/http.dart' as http;
import 'package:quiver/testing/time.dart';
import 'package:intl/intl.dart';
class SearchEvent extends StatefulWidget { class SearchEvent extends StatefulWidget {
const SearchEvent({ Key key }) : super(key: key);
@override @override
_SearchEventState createState() => _SearchEventState(); _SearchEventState createState() => _SearchEventState();
} }
class _SearchEventState extends State<SearchEvent> { class _SearchEventState extends State<SearchEvent> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text("Search an Event"),
),
body: ListPage(),
);
}
}
class ListPage extends StatefulWidget { String hotelName;
String district;
String noOfInfected;
String nearToDistrict;
String noOfPeople;
int ima;
@override
_ListPageState createState() => _ListPageState();
}
class _ListPageState extends State<ListPage> {
Future _data; //final List<String> dist = ['ampara', 'anuradhapura', 'badulla', 'batticaloa','colombo','galle','gampaha','hambantota','jaffna','kalmunai','kalutara','kandy','kegalle','kilinochchi','kurunagala','mannar','matale','matara','monaragala','mullaitivu','nuwara eliya','polonnaruwa','puttalam','ratnapura','trincomalee','vavuniya'];
var finalRisk = 'rrrr';
var tcVisibility = false;
DateTime now = new DateTime.now();
// Duration dur = new Duration(days: 1);
// var yesterday = now.subtract(const Duration(days: 1));
// var formatterDate = new DateFormat('dd');
// var formatterMonth = new DateFormat('MM');
// var formatterYear = new DateFormat('yyyy');
// String date = formatterDate.format(yesterday);
// String month = formatterMonth.format(yesterday);
// String year = formatterYear.format(yesterday);
// String finalDate = '_' + year + '_' + month + '_' + date
// String riskLevelDocument = location + finalDate;
// int ima;
// void riskLevel(){
// ima = 200;
// print('Test');
// }
getHotelName(hotelName){
this.hotelName= hotelName;
}
getDistrict(district){
this.district= district;
}
getInfected(noOfInfected){
this.noOfInfected= noOfInfected;
}
Future getRiskLocation() async { getNearDistrict(nearToDistrict){
var firestore = Firestore.instance; this.nearToDistrict= nearToDistrict;
QuerySnapshot qn = await firestore.collection("RiskLocation").getDocuments(); }
return qn.documents; getPeople(noOfPeople){
this.noOfPeople= noOfPeople;
} }
navigateToDetail(DocumentSnapshot riskLocation){ getNumberOfcases(String district) async{
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(riskLocation: riskLocation,))); DateTime now = new DateTime.now();
//Duration dur = new Duration(days: 1);
var yesterday = now.subtract(const Duration(days: 3));
// String year = yesterday.year.toString();
// String month = yesterday.month.toString();
// String date = yesterday.day.toString();
String formattedDate = new DateFormat('yyyy-MM-dd').format(yesterday);
// // String riskLevelDocument = location + '_' + formattedDate;
// // var formatterDate = new DateFormat('dd');
// // var formatterMonth = new DateFormat('MM');
// // var formatterYear = new DateFormat('yyyy');
// // String date = formatterDate.format(yesterday);
// // String month = formatterMonth.format(yesterday);
// String year = formatterYear.format(yesterday);
String riskLevelDocument = district + '_' + formattedDate;
// var a = Firestore.instance.collection('RiskLevel').document(riskLevelDocument)
// .get().then(function(Document) =>
// print(Document("cases"));
// );
DocumentSnapshot querySnapshot = await Firestore.instance.collection("RiskLevel").document(riskLevelDocument).get();
Map<String, dynamic> data = querySnapshot.data();
// val = querySnapshot.documents.length;
// var val = data['cases'];
// String riskLevelDocument = location + finalDate;
this.noOfInfected = data['cases'];
print(noOfInfected);
// return data['cases'].toString();
} }
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
void checkMethodSimple(int value) {
}
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
_data = getRiskLocation();
} }
@override
Widget build(BuildContext context) {
return Container(
child: FutureBuilder(
future: _data,
// ignore: missing_return
builder:(_, snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SpinKitFadingCircle( //---------------------------------------------Hotel Name-----------------------------------------------------
color: Colors.green, Widget _buildHotelName(){
size: 80.0, return TextFormField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
), ),
); focusedBorder: OutlineInputBorder(
}else{ borderSide: BorderSide(color: Colors.green),
return ListView.builder( borderRadius: BorderRadius.all(Radius.circular(20))
itemCount: snapshot.data.length, ),
itemBuilder: (_, index){ prefixIcon: Icon(Icons.home),
return Card( hintText: "Ex : Hilton",
elevation: 8, labelText: 'Hotel Name'
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
), ),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*Hotel Name Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String hotelName){
getHotelName(hotelName);
},
);
}
color: Colors.lightGreen[100], //---------------------------------------------District-----------------------------------------------------
child: ListTile( Widget _buildDistrict(){
leading: Icon(Icons.location_city, size: 40), return DropdownButtonFormField(
title: Text(snapshot.data[index].data()["hotelName"],style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), items: <String>['ampara','anuradhapura','badulla','batticaloa','colombo','galle','gampaha','hambantota','jaffna','kalmunai','kalutara','kandy','kegalle','kilinochchi','kurunagala','mannar','matale','matara','monaragala','mullaitivu','nuwara eliya','polonnaruwa','puttalam','ratnapura','trincomalee','vavuniya']
subtitle: Text(snapshot.data[index].data()["riskLocation"],style: TextStyle(fontSize: 16.0),), .map<DropdownMenuItem<String>>((String value) {
onTap: () => navigateToDetail(snapshot.data[index]), return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
), ),
prefixIcon: Icon(Icons.location_on),
hintText: "Ex : Colombo",
labelText: 'District'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*District is Required';
}
},
onSaved: (String value){
district = value;
},
onChanged: (String district){
getDistrict(district);
getNumberOfcases(district);
},
); );
}
//---------------------------------------------No Of Infected-----------------------------------------------------
Widget _buildNoOfInfected(){
return TextFormField(
readOnly: true,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.people_outlined),
hintText: "No Of Infected people",
labelText: this.noOfInfected
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*No Of Infected people is Required';
}
},
// onSaved: (String value){
// noOfInfected = value;
// },
onChanged: (String noOfInfected){
getInfected(noOfInfected);
setState(() {
}); });
// DocumentReference documentReference = Firestore.instance.collection('RiskLevel').document('district');
// print(documentReference);
},
);
}
//---------------------------------------------Near To District-----------------------------------------------------
Widget _buildNearToDistrict(){
return DropdownButtonFormField(
items: <String>['0','1']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.location_on),
hintText: "Ex : 0 or 1",
labelText: 'Near to District or not'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*This is Required';
} }
} ), },
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String nearToDistrict){
getNearDistrict(nearToDistrict);
},
); );
}
//---------------------------------------------No of people-----------------------------------------------------
Widget _buildNoOfPeople(){
return TextFormField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo[900]),
borderRadius: BorderRadius.all(Radius.circular(20))
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20))
),
prefixIcon: Icon(Icons.people_outline),
hintText: "Ex : 250",
labelText: 'No Of People'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*This is Required';
} }
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String noOfPeople){
getPeople(noOfPeople);
},
);
}
//------------------------------------------------Connect to Model---------------------------------------------------------------------
Future Getdata(url) async{
http.Response Response = await http.get(url);
return Response.body;
} }
class DetailPage extends StatefulWidget { Future<void> check() async{
final DocumentSnapshot riskLocation; setState(() async{
DetailPage({this.riskLocation}); String urls = 'https://eanalyzer.herokuapp.com/api/eanalyzer?NoInfected='+noOfInfected.toString()+'&NearToDistrict='+nearToDistrict.toString()+'&NoOfPeople='+noOfPeople.toString();
var Data = await Getdata(urls);
var reText = jsonDecode(Data);
//print(reText);
// var ex = [2];
//-----------------------------------------------------OutPut------------------------------------------------------------------------------
if(reText.toString() == '[0]') {
//print("This is a Low Risk area");
reText = "Low Risk";
finalRisk = reText;
ima = 101;
}
else if(reText.toString() == '[1]') {
//print("This is a Moderate Risk area");
reText = "Moderate Risk";
finalRisk = reText;
ima = 102;
}
else if(reText.toString() == '[2]') {
//print("This is a High Risk area");
reText = "High Risk";
finalRisk = reText;
ima = 103;
}
print(reText);
tcVisibility = true;
print('$now');
});
//print(now.subtract(dur));
@override
_DetailPageState createState() => _DetailPageState();
} }
class _DetailPageState extends State<DetailPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backwardsCompatibility: false, backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20), backgroundColor: Color(0xFF1B5E20),
title: Text(widget.riskLocation.data()["hotelName"]), title: Text("Search a Event"),
), ),
body: Container( body: Container(
width: 410, margin: EdgeInsets.all(24),
height: 100, child: Form(
child: Card( key: _formKey,
elevation: 8, child: ListView(
scrollDirection: Axis.vertical,
//mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 10),
_buildHotelName(),
SizedBox(height: 10),
_buildDistrict(),
SizedBox(height: 10),
new RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.green)),
child: new Text('View No of Infected People',textAlign: TextAlign.center,
style: TextStyle(color: Colors.green[900], fontSize: 17),),
onPressed: voteUp,
),
SizedBox(height: 10),
_buildNoOfInfected(),
SizedBox(height: 10),
_buildNearToDistrict(),
SizedBox(height: 10),
_buildNoOfPeople(),
SizedBox(height: 50),
//Image(image: AssetImage('lib/assets/images/200.gif')),
//----------------------------------------------------------------------------------------------------
// Image.asset('lib/assets/images/101.gif',fit: BoxFit.contain,width: 150,height: 150,),
// Center(
// child:
// Text('This is a $finalRisk area',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold, color: Colors.red[900]),)),
// SizedBox(height: 10),
Visibility(
visible: tcVisibility,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Image.asset(
'lib/assets/images/$ima.gif',
fit: BoxFit.contain,width: 150,height: 150,
),
),
Text('This is a $finalRisk event',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold, color: Colors.red[900]),),
],
)
),
SizedBox(height: 30),
RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.green[900])),
padding: EdgeInsets.all(15.0),
color: Colors.green,
child: Text(
'Check Risk Level',textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 30),
), ),
color: Colors.lightGreen[50], onPressed: () {
check();
Visibility();
voteUp();
child: ListTile(
leading: Icon(Icons.timelapse, size: 40),
title: Text("Date : ${widget.riskLocation.data()["date"]}" ,style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),
subtitle: Text("Time : ${widget.riskLocation.data()["time"]}",style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),
// if(!_formKey.currentState.validate()) {
// return;
//}
//String urls = 'https://eanalyzer.herokuapp.com/api/eanalyzer?NoInfected='+noOfInfected.toString()+'&NearToDistrict='+nearToDistrict.toString()+'&NoOfPeople='+noOfPeople.toString();
// var Data = await Getdata(urls);
// var reText = jsonDecode(Data);
// riskLevel();
},
),
SizedBox(height: 20),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.blue[900])),
padding: EdgeInsets.all(15.0),
color: Colors.blue[900],
child: Text(
'View Risk Level',textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 30),
), ),
onPressed: voteUp,
), ),
// new Text('Up Votes: $votes'),
// new RaisedButton(
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18.0),
// side: BorderSide(color: Colors.green[900])),
// child: new Text('Vote up'),
// onPressed: voteUp,
// ),
],
),),
), ),
); );
} }
int votes = 0;
void voteUp() {
setState(() {
votes = votes + 1;
});
}
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ class _HomeScreenState extends State<HomeScreen> { ...@@ -27,7 +27,7 @@ class _HomeScreenState extends State<HomeScreen> {
body: Stack( body: Stack(
children: <Widget>[ children: <Widget>[
Container( Container(
height: size.height * .2, //height: size.height * .2,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
...@@ -44,11 +44,11 @@ class _HomeScreenState extends State<HomeScreen> { ...@@ -44,11 +44,11 @@ class _HomeScreenState extends State<HomeScreen> {
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
// CircleAvatar( CircleAvatar(
// radius: 32, radius: 55,
// backgroundImage: NetworkImage( backgroundColor: Colors.transparent,
// 'https://upload.wikimedia.org/wikipedia/commons/a/a0/Pierre-Person.jpg'), backgroundImage: AssetImage('lib/assets/images/cdlogo2.png'),
// ), ),
SizedBox( SizedBox(
width: 16, width: 16,
), ),
......
...@@ -91,6 +91,12 @@ flutter: ...@@ -91,6 +91,12 @@ flutter:
- lib/assets/images/feedback80.png - lib/assets/images/feedback80.png
- lib/assets/images/list80.png - lib/assets/images/list80.png
- lib/assets/images/search80.png - lib/assets/images/search80.png
- lib/assets/images/101.gif
- lib/assets/images/102.gif
- lib/assets/images/103.gif
- lib/assets/images/cdlogo.png
- lib/assets/images/cdlogo1.png
- lib/assets/images/cdlogo2.png
- lib/assets/ - lib/assets/
......
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