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,114 +109,189 @@ class AddLocationState extends State<AddLocation> { ...@@ -109,114 +109,189 @@ 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(
if (value.isEmpty) { borderSide: BorderSide(color: Colors.indigo[900]),
return '*Full Name is Required'; borderRadius: BorderRadius.all(Radius.circular(20))
} ),
}, focusedBorder: OutlineInputBorder(
// onSaved: (String value){ borderSide: BorderSide(color: Colors.green),
// _fName = value; borderRadius: BorderRadius.all(Radius.circular(20))
// }, ),
onChanged: (String name) { prefixIcon: Icon(Icons.face),
getUserName(name); hintText: "Ex : John Smith",
}, labelText: 'Full Name'
); ),
} // ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*Full Name is Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String name){
getUserName(name);
},
);
}
//---------------------------------------------Phone Number----------------------------------------------------- //---------------------------------------------Phone Number-----------------------------------------------------
Widget _buildPNo() { Widget _buildPNo(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Phone Number'), decoration: InputDecoration(
keyboardType: TextInputType.phone, enabledBorder: OutlineInputBorder(
maxLength: 10, borderSide: BorderSide(color: Colors.indigo[900]),
validator: (String value) { borderRadius: BorderRadius.all(Radius.circular(20))
if (value.isEmpty) { ),
return '*Phone Number is Required'; focusedBorder: OutlineInputBorder(
} borderSide: BorderSide(color: Colors.green),
}, borderRadius: BorderRadius.all(Radius.circular(20))
// onSaved: (String value){ ),
// _lName = value; prefixIcon: Icon(Icons.phone),
// }, hintText: "Ex : 011XXXXXXX",
onChanged: (String id) { labelText: 'Phone Number'
getPhoneNumber(phoneNumber); ),
}, keyboardType: TextInputType.phone,
); maxLength: 10,
} validator: (String value){
if (value.isEmpty) {
return '*Phone Number is Required';
}
},
// onSaved: (String value){
// _lName = value;
// },
onChanged: (String id){
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(
if (value.isEmpty) { borderSide: BorderSide(color: Colors.indigo[900]),
return '*Risk Location is Required'; borderRadius: BorderRadius.all(Radius.circular(20))
} ),
}, focusedBorder: OutlineInputBorder(
// onSaved: (String value){ borderSide: BorderSide(color: Colors.green),
// _age = value; borderRadius: BorderRadius.all(Radius.circular(20))
// }, ),
onChanged: (String riskLocation) { prefixIcon: Icon(Icons.location_on),
getRiskLocation(riskLocation); hintText: "Ex : Galle",
}, labelText: 'Risk Location'
); ),
} validator: (String value){
if (value.isEmpty) {
return '*Risk Location is Required';
}
},
// onSaved: (String value){
// _age = value;
// },
onChanged: (String 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(
if (value.isEmpty) { borderSide: BorderSide(color: Colors.indigo[900]),
return '*Hotel Name is Required'; borderRadius: BorderRadius.all(Radius.circular(20))
} ),
}, focusedBorder: OutlineInputBorder(
// onSaved: (String value){ borderSide: BorderSide(color: Colors.green),
// _address = value; borderRadius: BorderRadius.all(Radius.circular(20))
// }, ),
onChanged: (String hotelName) { prefixIcon: Icon(Icons.hotel),
getHotelName(hotelName); hintText: "Ex : Hilton",
}, labelText: 'Hotel Name'
); ),
} validator: (String value){
if (value.isEmpty) {
return '*Hotel Name is Required';
}
},
// onSaved: (String value){
// _address = value;
// },
onChanged: (String hotelName){
getHotelName(hotelName);
},
);
}
//---------------------------------------------Date----------------------------------------------------- //---------------------------------------------Date-----------------------------------------------------
Widget _buildDate() { Widget _buildDate(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Date'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
if (value.isEmpty) { borderSide: BorderSide(color: Colors.indigo[900]),
return '*Date is Required'; borderRadius: BorderRadius.all(Radius.circular(20))
} ),
}, focusedBorder: OutlineInputBorder(
// onSaved: (String value){ borderSide: BorderSide(color: Colors.green),
// _nic = value; borderRadius: BorderRadius.all(Radius.circular(20))
// }, ),
onChanged: (String date) { prefixIcon: Icon(Icons.calendar_today),
getDate(date); hintText: "Ex : 2021/04/03",
}, labelText: 'Date'
); ),
} validator: (String value){
if (value.isEmpty) {
return '*Date is Required';
}
},
// onSaved: (String value){
// _nic = value;
// },
onChanged: (String date){
getDate(date);
},
);
}
//---------------------------------------------Time----------------------------------------------------- //---------------------------------------------Time-----------------------------------------------------
Widget _buildTime() { Widget _buildTime(){
return TextFormField( return TextFormField(
decoration: InputDecoration(labelText: 'Time'), decoration: InputDecoration(
validator: (String value) { enabledBorder: OutlineInputBorder(
if (value.isEmpty) { borderSide: BorderSide(color: Colors.indigo[900]),
return '*Time is Required'; borderRadius: BorderRadius.all(Radius.circular(20))
} ),
}, focusedBorder: OutlineInputBorder(
// onSaved: (String value){ borderSide: BorderSide(color: Colors.green),
// _phoneNumber = value; borderRadius: BorderRadius.all(Radius.circular(20))
// }, ),
onChanged: (String time) { prefixIcon: Icon(Icons.lock_clock),
getTime(time); hintText: "Ex : 2.00 P.M",
}, labelText: 'Time'
); ),
} // ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*Time is Required';
}
},
// onSaved: (String value){
// _phoneNumber = value;
// },
onChanged: (String time){
getTime(time);
},
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -232,69 +307,85 @@ class AddLocationState extends State<AddLocation> { ...@@ -232,69 +307,85 @@ class AddLocationState extends State<AddLocation> {
key: _formKey, key: _formKey,
child: ListView( child: ListView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
//mainAxisAlignment: MainAxisAlignment.center, //mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
_buildName(), SizedBox(height: 10),
_buildPNo(), _buildName(),
_buildLocation(), SizedBox(height: 10),
_buildHotelName(), _buildPNo(),
_buildDate(), SizedBox(height: 10),
_buildTime(), _buildLocation(),
SizedBox(height: 10),
SizedBox(height: 100), _buildHotelName(),
RaisedButton( SizedBox(height: 10),
color: Colors.green, _buildDate(),
child: Text( SizedBox(height: 10),
'Submit', _buildTime(),
style: TextStyle(color: Colors.white, fontSize: 18),
), //---------------------------------------------Submit-----------------------------------------------------
onPressed: () { SizedBox(height: 50),
if (!_formKey.currentState.validate()) { RaisedButton(
return; color: Colors.green,
} child: Text(
'Submit',
createData(); style: TextStyle(color: Colors.white, fontSize: 18),
}, ),
), onPressed: () {
if(!_formKey.currentState.validate()) {
// RaisedButton( return;
// color: Colors.blue, }
// child: Text(
// 'View', createData();
// style: TextStyle(color: Colors.white, fontSize: 18),
// ),
// onPressed: () { } ,
),
// readData();
// RaisedButton(
// } , // color: Colors.blue,
// ), // child: Text(
// 'View',
RaisedButton( // style: TextStyle(color: Colors.white, fontSize: 18),
color: Colors.yellowAccent[700], // ),
child: Text( // onPressed: () {
'Update',
style: TextStyle(color: Colors.white, fontSize: 18), // readData();
),
onPressed: () { // } ,
updateData(); // ),
}, //---------------------------------------------Update-----------------------------------------------------
), RaisedButton(
color: Colors.yellowAccent[700],
RaisedButton( child: Text(
color: Colors.red, 'Update',
child: Text( style: TextStyle(color: Colors.white, fontSize: 18),
'Delete', ),
style: TextStyle(color: Colors.white, fontSize: 18), onPressed: () {
),
onPressed: () { updateData();
deleteData();
}, } ,
), ),
], //---------------------------------------------Delete-----------------------------------------------------
), RaisedButton(
), color: Colors.red,
child: Text(
'Delete',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
deleteData();
} ,
),
],
),),
), ),
); );
} }
} }
\ No newline at end of file
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> { //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);
Future _data; // 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);
Future getRiskLocation() async { // String finalDate = '_' + year + '_' + month + '_' + date
var firestore = Firestore.instance; // String riskLevelDocument = location + finalDate;
QuerySnapshot qn = await firestore.collection("RiskLocation").getDocuments();
return qn.documents;
// int ima;
// void riskLevel(){
// ima = 200;
// print('Test');
// }
getHotelName(hotelName){
this.hotelName= hotelName;
} }
navigateToDetail(DocumentSnapshot riskLocation){ getDistrict(district){
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(riskLocation: riskLocation,))); this.district= district;
} }
@override
getInfected(noOfInfected){
this.noOfInfected= noOfInfected;
}
getNearDistrict(nearToDistrict){
this.nearToDistrict= nearToDistrict;
}
getPeople(noOfPeople){
this.noOfPeople= noOfPeople;
}
getNumberOfcases(String district) async{
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
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(
//---------------------------------------------Hotel Name-----------------------------------------------------
Widget _buildHotelName(){
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.home),
hintText: "Ex : Hilton",
labelText: 'Hotel Name'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*Hotel Name Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String hotelName){
getHotelName(hotelName);
},
);
}
//---------------------------------------------District-----------------------------------------------------
Widget _buildDistrict(){
return DropdownButtonFormField(
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']
.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 : 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(() {
future: _data, });
// ignore: missing_return // DocumentReference documentReference = Firestore.instance.collection('RiskLevel').document('district');
builder:(_, snapshot){ // print(documentReference);
},
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SpinKitFadingCircle( );
color: Colors.green, }
size: 80.0,
), //---------------------------------------------Near To District-----------------------------------------------------
); Widget _buildNearToDistrict(){
}else{ return DropdownButtonFormField(
return ListView.builder( items: <String>['0','1']
itemCount: snapshot.data.length, .map<DropdownMenuItem<String>>((String value) {
itemBuilder: (_, index){ return DropdownMenuItem<String>(
return Card( value: value,
elevation: 8, child: Text(value),
shape: RoundedRectangleBorder( );
borderRadius: BorderRadius.circular(15.0), }).toList(),
), decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
color: Colors.lightGreen[100], borderSide: BorderSide(color: Colors.indigo[900]),
child: ListTile( borderRadius: BorderRadius.all(Radius.circular(20))
leading: Icon(Icons.location_city, size: 40), ),
title: Text(snapshot.data[index].data()["hotelName"],style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), focusedBorder: OutlineInputBorder(
subtitle: Text(snapshot.data[index].data()["riskLocation"],style: TextStyle(fontSize: 16.0),), borderSide: BorderSide(color: Colors.green),
onTap: () => navigateToDetail(snapshot.data[index]), 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);
},
);
} }
class DetailPage extends StatefulWidget { //---------------------------------------------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;
}
final DocumentSnapshot riskLocation; Future<void> check() async{
DetailPage({this.riskLocation});
setState(() async{
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(
shape: RoundedRectangleBorder( scrollDirection: Axis.vertical,
borderRadius: BorderRadius.circular(20.0), //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]),),
],
)
), ),
color: Colors.lightGreen[50],
child: ListTile( SizedBox(height: 30),
leading: Icon(Icons.timelapse, size: 40),
title: Text("Date : ${widget.riskLocation.data()["date"]}" ,style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), RaisedButton(
subtitle: Text("Time : ${widget.riskLocation.data()["time"]}",style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), shape: RoundedRectangleBorder(
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),
),
onPressed: () {
check();
Visibility();
voteUp();
// 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