Commit 8fc789d3 authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Done some parts in Searchevent.dart page

parent 7cfdc22c
import 'package:covidefender/EAnalyzer/HospitalDetails.dart'; import 'package:covidefender/EAnalyzer/HospitalDetails.dart';
import 'package:covidefender/EAnalyzer/SearchEvent.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'AddLocation.dart'; import 'AddLocation.dart';
...@@ -126,7 +127,7 @@ class EAnalyzerDash extends StatelessWidget { ...@@ -126,7 +127,7 @@ class EAnalyzerDash extends StatelessWidget {
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => EAnalyzerDash()), MaterialPageRoute(builder: (context) => SearchEvent()),
); );
}, },
child: Image.asset('lib/assets/images/search80.png'), child: Image.asset('lib/assets/images/search80.png'),
......
...@@ -21,13 +21,13 @@ class _LoadingScreenState extends State<LoadingScreen> { ...@@ -21,13 +21,13 @@ class _LoadingScreenState extends State<LoadingScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.green.shade300, backgroundColor: Colors.lightGreen[400],
body: Stack( body: Stack(
children: <Widget>[ children: <Widget>[
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
alignment: Alignment.topCenter, alignment: Alignment.center,
image: AssetImage('lib/assets/images/eana.png'), image: AssetImage('lib/assets/images/eana.png'),
))), ))),
] ]
......
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.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 {
@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: Text("Loading...."),
);
}else{
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (_, index){
return Card(
child: ListTile(
title: Text(snapshot.data[index].data()["hotelName"]),
subtitle: Text(snapshot.data[index].data()["riskLocation"]),
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(
child: Card(child: ListTile(
title: Text(widget.riskLocation.data()["date"]),
subtitle: Text(widget.riskLocation.data()["time"]),
),
),
),
);
}
}
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