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> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
//---------------------------------------------User Name-----------------------------------------------------
Widget _buildName() {
return TextFormField(
decoration: InputDecoration(labelText: 'Full Name'),
validator: (String value) {
if (value.isEmpty) {
return '*Full Name is Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String name) {
getUserName(name);
},
);
}
Widget _buildName(){
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.face),
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-----------------------------------------------------
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';
}
},
// onSaved: (String value){
// _lName = value;
// },
onChanged: (String id) {
getPhoneNumber(phoneNumber);
},
);
}
Widget _buildPNo(){
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.phone),
hintText: "Ex : 011XXXXXXX",
labelText: 'Phone Number'
),
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-----------------------------------------------------
Widget _buildLocation() {
return TextFormField(
decoration: InputDecoration(labelText: 'Risk Location'),
validator: (String value) {
if (value.isEmpty) {
return '*Risk Location is Required';
}
},
// onSaved: (String value){
// _age = value;
// },
onChanged: (String riskLocation) {
getRiskLocation(riskLocation);
},
);
}
Widget _buildLocation(){
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.location_on),
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-----------------------------------------------------
Widget _buildHotelName() {
return TextFormField(
decoration: InputDecoration(labelText: 'Hotel Name'),
validator: (String value) {
if (value.isEmpty) {
return '*Hotel Name is Required';
}
},
// onSaved: (String value){
// _address = value;
// },
onChanged: (String hotelName) {
getHotelName(hotelName);
},
);
}
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.hotel),
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-----------------------------------------------------
Widget _buildDate() {
return TextFormField(
decoration: InputDecoration(labelText: 'Date'),
validator: (String value) {
if (value.isEmpty) {
return '*Date is Required';
}
},
// onSaved: (String value){
// _nic = value;
// },
onChanged: (String date) {
getDate(date);
},
);
}
Widget _buildDate(){
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.calendar_today),
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-----------------------------------------------------
Widget _buildTime() {
return TextFormField(
decoration: InputDecoration(labelText: 'Time'),
validator: (String value) {
if (value.isEmpty) {
return '*Time is Required';
}
},
// onSaved: (String value){
// _phoneNumber = value;
// },
onChanged: (String time) {
getTime(time);
},
);
}
Widget _buildTime(){
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.lock_clock),
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
Widget build(BuildContext context) {
......@@ -232,69 +307,85 @@ class AddLocationState extends State<AddLocation> {
key: _formKey,
child: ListView(
scrollDirection: Axis.vertical,
//mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildName(),
_buildPNo(),
_buildLocation(),
_buildHotelName(),
_buildDate(),
_buildTime(),
SizedBox(height: 100),
RaisedButton(
color: Colors.green,
child: Text(
'Submit',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
if (!_formKey.currentState.validate()) {
return;
}
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();
},
),
],
),
),
//mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 10),
_buildName(),
SizedBox(height: 10),
_buildPNo(),
SizedBox(height: 10),
_buildLocation(),
SizedBox(height: 10),
_buildHotelName(),
SizedBox(height: 10),
_buildDate(),
SizedBox(height: 10),
_buildTime(),
//---------------------------------------------Submit-----------------------------------------------------
SizedBox(height: 50),
RaisedButton(
color: Colors.green,
child: Text(
'Submit',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
if(!_formKey.currentState.validate()) {
return;
}
createData();
} ,
),
// RaisedButton(
// color: Colors.blue,
// child: Text(
// 'View',
// style: TextStyle(color: Colors.white, fontSize: 18),
// ),
// onPressed: () {
// readData();
// } ,
// ),
//---------------------------------------------Update-----------------------------------------------------
RaisedButton(
color: Colors.yellowAccent[700],
child: Text(
'Update',
style: TextStyle(color: Colors.white, fontSize: 18),
),
onPressed: () {
updateData();
} ,
),
//---------------------------------------------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/HotelMap.dart';
import 'package:covidefender/EAnalyzer/SearchEvent.dart';
import 'package:flutter/material.dart';
import 'AddLocation.dart';
import 'RiskEventList.dart';
class EAnalyzerDash extends StatelessWidget {
@override
......@@ -56,6 +58,7 @@ class EAnalyzerDash extends StatelessWidget {
primary: false,
crossAxisCount: 2,
children: <Widget>[
//--------------------------------------Cards--------------------------------------------------------------------------------------
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
......@@ -107,7 +110,7 @@ class EAnalyzerDash extends StatelessWidget {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => EAnalyzerDash()),
MaterialPageRoute(builder: (context) => RiskEventList()),
);
},
child: Image.asset('lib/assets/images/list80.png'),
......@@ -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> {
padding: const EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
// CircleAvatar(
// ),
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"]}",
......
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: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 {
const SearchEvent({ Key key }) : super(key: key);
@override
_SearchEventState createState() => _SearchEventState();
}
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 {
var firestore = Firestore.instance;
QuerySnapshot qn = await firestore.collection("RiskLocation").getDocuments();
// String finalDate = '_' + year + '_' + month + '_' + date
// String riskLevelDocument = location + finalDate;
return qn.documents;
// int ima;
// void riskLevel(){
// ima = 200;
// print('Test');
// }
getHotelName(hotelName){
this.hotelName= hotelName;
}
navigateToDetail(DocumentSnapshot riskLocation){
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(riskLocation: riskLocation,)));
getDistrict(district){
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() {
// TODO: implement 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
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]),
),
);
});
}
} ),
);
}
});
// 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);
},
);
}
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;
DetailPage({this.riskLocation});
Future<void> check() async{
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
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text(widget.riskLocation.data()["hotelName"]),
title: Text("Search a Event"),
),
body: Container(
width: 410,
height: 100,
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
margin: EdgeInsets.all(24),
child: Form(
key: _formKey,
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]),),
],
)
),
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),),
),
),
SizedBox(height: 30),
RaisedButton(
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> {
body: Stack(
children: <Widget>[
Container(
height: size.height * .2,
//height: size.height * .2,
decoration: BoxDecoration(
image: DecorationImage(
alignment: Alignment.topCenter,
......@@ -44,11 +44,11 @@ class _HomeScreenState extends State<HomeScreen> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// CircleAvatar(
// radius: 32,
// backgroundImage: NetworkImage(
// 'https://upload.wikimedia.org/wikipedia/commons/a/a0/Pierre-Person.jpg'),
// ),
CircleAvatar(
radius: 55,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage('lib/assets/images/cdlogo2.png'),
),
SizedBox(
width: 16,
),
......
......@@ -91,6 +91,12 @@ flutter:
- lib/assets/images/feedback80.png
- lib/assets/images/list80.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/
......
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