Commit 8f94e6aa authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Change some codes in hotelmap dart file

parent 7aceccb6
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
android:label="covidefender" android:label="covidefender"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY" <meta-data android:name="com.google.android.geo.API_KEY"
android:value=""/> android:value="AIzaSyBuDih9ioyQAR9ikg3zEoE_5mhXvZh5oAw"/>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleTop" android:launchMode="singleTop"
......
...@@ -3,6 +3,7 @@ import 'package:covidefender/EAnalyzer/HotelMap.dart'; ...@@ -3,6 +3,7 @@ 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
...@@ -108,7 +109,7 @@ class EAnalyzerDash extends StatelessWidget { ...@@ -108,7 +109,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'),
......
...@@ -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"]}",
......
...@@ -23,8 +23,9 @@ class _HotelMapState extends State<HotelMap> { ...@@ -23,8 +23,9 @@ class _HotelMapState extends State<HotelMap> {
child: GoogleMap( child: GoogleMap(
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: LatLng(40.7128, -74.0060), target: LatLng(7.8731, 80.7718),
zoom: 20.0,
zoom: 8.0,
), ),
), ),
), ),
......
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 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_spinkit/flutter_spinkit.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 Risk Hotels"),
),
body: ListPage(),
);
}
}
class ListPage extends StatefulWidget {
@override
_ListPageState createState() => _ListPageState();
}
class _ListPageState extends State<ListPage> { String hotelName;
String district;
int nearToDistrict;
int noOfPeople;
String date;
// int ima;
Future _data; // void riskLevel(){
// ima = 200;
// print('Test');
// }
Future getRiskLocation() async { getHotelName(hotelName){
var firestore = Firestore.instance; this.hotelName= hotelName;
QuerySnapshot qn = await firestore.collection("RiskLocation").getDocuments(); }
return qn.documents; getDistrict(district){
this.district= district;
} }
navigateToDetail(DocumentSnapshot riskLocation){ getNearDistrict(nearToDistrict){
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(riskLocation: riskLocation,))); this.nearToDistrict= nearToDistrict;
} }
@override
void initState() { getPeople(noOfPeople){
// TODO: implement initState this.noOfPeople= noOfPeople;
super.initState();
_data = getRiskLocation();
} }
@override getDate(date){
Widget build(BuildContext context) { this.date= date;
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]),
),
);
});
}
} ),
);
} }
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
void checkMethodSimple(int value) {
} }
// @override
// void initState() {
// riskLevel();
// // TODO: implement initState
// super.initState();
// }
class DetailPage extends StatefulWidget {
final DocumentSnapshot riskLocation;
DetailPage({this.riskLocation});
@override //---------------------------------------------Hotel Name-----------------------------------------------------
_DetailPageState createState() => _DetailPageState(); 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 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 : Colombo",
labelText: 'District'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*District is Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String district){
getDistrict(district);
},
);
}
//---------------------------------------------Near To District-----------------------------------------------------
Widget _buildNearToDistrict(){
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 : 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);
},
);
}
//---------------------------------------------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'
),
// ignore: missing_return
validator: (String value){
if (value.isEmpty) {
return '*Date is Required';
}
},
// onSaved: (String value){
// _fName = value;
// },
onChanged: (String date){
getNearDistrict(date);
},
);
} }
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 Hotel"),
), ),
body: Container( body: Container(
width: MediaQuery.of(context).size.width, 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>[
color: Colors.lightGreen[50], SizedBox(height: 10),
_buildHotelName(),
child: ListTile( SizedBox(height: 10),
leading: Icon(Icons.timelapse, size: 40), _buildDistrict(),
title: Text("Date : ${widget.riskLocation.data()["date"]}" ,style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), SizedBox(height: 10),
subtitle: Text("Time : ${widget.riskLocation.data()["time"]}",style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),), _buildNearToDistrict(),
SizedBox(height: 10),
), _buildNoOfPeople(),
), SizedBox(height: 10),
_buildDate(),
SizedBox(height: 50),
//Image(image: AssetImage('lib/assets/images/200.gif')),
Image.asset('lib/assets/images/200.gif',fit: BoxFit.contain,width: 150,height: 150,),
Text('This is a Risk Location',style: TextStyle(fontSize: 20, color: Colors.red[900]),),
RaisedButton(
color: Colors.green,
child: Center(
child: Text(
'Check Risk Level',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
onPressed: () {
if(!_formKey.currentState.validate()) {
return;
}
// riskLevel();
} ,
),
],
),),
), ),
); );
} }
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ dependencies: ...@@ -33,7 +33,7 @@ dependencies:
wakelock: ^0.1.4+1 wakelock: ^0.1.4+1
charts_flutter: ^0.9.0 charts_flutter: ^0.9.0
flutter_spinkit: "^4.1.2" flutter_spinkit: "^4.1.2"
google_maps_flutter: ^2.0.6
...@@ -52,6 +52,7 @@ dependencies: ...@@ -52,6 +52,7 @@ dependencies:
git: git:
url: http://github.com/indikaNK/plugins.git url: http://github.com/indikaNK/plugins.git
path: packages/camera/camera path: packages/camera/camera
google_maps_flutter: ^2.0.6
dev_dependencies: dev_dependencies:
...@@ -85,6 +86,7 @@ flutter: ...@@ -85,6 +86,7 @@ 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/200.gif
- 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