VenuInfo blabla #46

Merged
shas6395 merged 1 commits from shas6395 into master 2022-05-27 11:34:03 +02:00
2 changed files with 85 additions and 60 deletions

View File

@ -18,9 +18,7 @@ class VenueInfo {
late String _openHoursToday;
VenueInfo() {
}
VenueInfo(/*this._photos, this._tastes, this._priceClass, this._rating, this._totalRatings, this._openNow, this._openHoursToday*/);
Future getVenueInfo(String venueName) async {

View File

@ -6,6 +6,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
import 'VenueInfo.dart';
import 'WeatherData.dart';
import 'globals.dart' as globals;
@ -22,7 +23,7 @@ class _VenuePageState extends State<VenuePage> {
late WeatherData currentWeather;
final String imageLink = '';
late final Venue venue;
late VenueInfo venueInfo;
_VenuePageState(this.venue);
@ -38,8 +39,16 @@ class _VenuePageState extends State<VenuePage> {
@override
void initState() {
refreshWeather();
gatherVenueInfo();
}
Future gatherVenueInfo( ) async {
VenueInfo vu = VenueInfo();
venueInfo = vu;
venueInfo = await vu.getVenueInfo(venue.venueName);
}
Future refreshWeather() async {
WeatherData tempWeather = WeatherData(0, 0);
currentWeather = tempWeather;
@ -70,7 +79,12 @@ class _VenuePageState extends State<VenuePage> {
title: Text(venue.venueName),
backgroundColor: const Color(0xffac7b84),
),
body: Center(child: SingleChildScrollView(
body: Center(
child: FutureBuilder(
future: gatherVenueInfo(),
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.done) {
return SingleChildScrollView(
child: Container(
alignment: Alignment.center,
child: Column(children: <Widget>[
@ -82,7 +96,7 @@ class _VenuePageState extends State<VenuePage> {
),
Row(children: [
Expanded(
child: Image.network(validateAndGetImageLink()),
child: Image.network(venueInfo.getPhotoURL()),
),
]),
// Row(
@ -115,14 +129,20 @@ class _VenuePageState extends State<VenuePage> {
),
)
]),
const AboutTheSpotTable(),
AboutTheSpotTable(venueInfo: venueInfo),
/*GridView.count(
crossAxisCount: 2,
children: [],
)*/
]),
),
),
);
}
else {
return CircularProgressIndicator();
}
}
)
));
}
@ -159,17 +179,24 @@ class _VenuePageState extends State<VenuePage> {
}
//Just an example table
class AboutTheSpotTable extends StatelessWidget {
const AboutTheSpotTable({
class AboutTheSpotTable extends StatefulWidget {
final VenueInfo venueInfo;
AboutTheSpotTable({
Key? key,
required this.venueInfo,
}) : super(key: key);
@override
State<AboutTheSpotTable> createState() => _AboutTheSpotTableState();
}
class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
@override
Widget build(BuildContext context) {
return DataTable(
headingRowHeight: 30,
columnSpacing: 100,
dataRowHeight: 30,
//dataRowHeight: 30,
dataTextStyle: GoogleFonts.robotoCondensed(
color: const Color(0xff4F6272),
),
@ -182,18 +209,18 @@ class AboutTheSpotTable extends StatelessWidget {
)))),
const DataColumn(label: Text('', style: TextStyle())),
],
rows: const [
rows: [
DataRow(cells: [
DataCell(Text('Type of venue')),
DataCell(Text('Saloon')),
]),
DataRow(cells: [
DataCell(Text('Pricing')),
DataCell(Text('\$\$\$')),
DataCell(Text(widget.venueInfo.getPriceClass())),
]),
DataRow(cells: [
DataCell(Text('Rating')),
DataCell(Text('4.2/5')),
DataCell(Text(widget.venueInfo.getRating().toString() + ' (' + widget.venueInfo.getTotalRatings().toString() + ' ratings)')),
]),
DataRow(cells: [
DataCell(Text('Current activity')),
@ -201,7 +228,7 @@ class AboutTheSpotTable extends StatelessWidget {
]),
DataRow(cells: [
DataCell(Text('Opening hours')),
DataCell(Text('11:00-23:00')),
DataCell(Text(widget.venueInfo.getOpeningHours())),
]),
],
);