BottomModalSheet & Venue details #53

Merged
adsu7578 merged 4 commits from connecter into master 2022-05-30 15:30:42 +02:00
6 changed files with 410 additions and 366 deletions

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/Venue.dart';
@ -38,7 +40,7 @@ class _ListViewPageState extends State<ListViewPage> {
title: buildTitleText(index), title: buildTitleText(index),
subtitle: buildWeatherRow(), subtitle: buildWeatherRow(),
trailing: const Text('400m'), // trailing: const Text('400m'),
); );
}, },
); );
@ -85,4 +87,6 @@ class _ListViewPageState extends State<ListViewPage> {
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => VenuePage(venue))); .push(MaterialPageRoute(builder: (context) => VenuePage(venue)));
} }
} }

View File

@ -378,7 +378,7 @@ class MapState extends State<Map> {
CameraPosition(target: LatLng(lat, lng), zoom: 15))); CameraPosition(target: LatLng(lat, lng), zoom: 15)));
} }
Widget _boxes(double lat, double lng, String resturantName) { Widget _boxes(double lat, double lng, String restaurantName) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
_gotoLocation(lat, lng); _gotoLocation(lat, lng);
@ -405,7 +405,7 @@ class MapState extends State<Map> {
Container( Container(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text(resturantName), child: Text(restaurantName),
), ),
) )
], ],
@ -425,10 +425,9 @@ class MapState extends State<Map> {
} }
createBottomDrawer(Venue venue) async { createBottomDrawer(Venue venue) async {
// Position? position = await Geolocator.getLastKnownPosition();
// double bar = Geolocator.bearingBetween(position != null? position.latitude : 0, position != null? position.longitude : 0, venue.position.latitude, venue.position.longitude);
_bottomSheetIsOpen = true; _bottomSheetIsOpen = true;
Scaffold.of(context).showBottomSheet<void>(((context) { // Scaffold.of(context).showBottomSheet<void>(((context) {
showModalBottomSheet(context: context, builder: (BuildContext context) {
return InkWell( return InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -437,57 +436,59 @@ class MapState extends State<Map> {
); );
}, },
child: Container( child: Container(
height: 250, height: 175,
color: const Color(0xFFF5F5F5), color: const Color(0xFFF5F5F5),
child: Center( child: Center(
child: Column( child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Container( bottomSheetWidgetContainer(venue, context),
margin: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// mainAxisSize: MainAxisSize.min,
children: <Widget>[
columnCoveringNameAndAddress(venue),
columnCoveringRating(),
],
),
),
columnHandlingCloseButton(context),
Container(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Row(
children: [
const Text('Weather: \t\t'),
globals.forecast.getCurrentWeatherIcon(),
],
),
Row(
children: [
Text(' ' +
globals.forecast.getCurrentWeatherStatus()),
],
),
Row(
children: [
const Text('Distance:'),
],
)
],
),
)
], ],
), ),
), ),
), ),
); );
})); });
} }
Column columnHandlingCloseButton(BuildContext context) { Container bottomSheetWidgetContainer(Venue venue, BuildContext context) {
return Container(
margin: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
columnCoveringNameAndAddress(venue),
],
),
// columnCoveringRating(),
Column(
children: const [
weatherIconRow(),
weatherStatusRow(),
],
),
],
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
columnHandlingReadMoreButton(context, venue),
],
)
],
),
);
}
Column columnHandlingReadMoreButton(BuildContext context, Venue venue) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -496,19 +497,7 @@ class MapState extends State<Map> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
ElevatedButton( readMoreButton(context, venue),
child: const Text('Close'),
onPressed: () {
Navigator.pop(context);
_bottomSheetIsOpen = false;
}),
ElevatedButton(
child: const Text('ListView'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ListViewPage()));
},
),
], ],
), ),
), ),
@ -516,20 +505,20 @@ class MapState extends State<Map> {
); );
} }
Column columnCoveringRating() { ElevatedButton readMoreButton(BuildContext context, Venue venue) {
return Column( return ElevatedButton(
children: [ child: const Text(
Text( 'Read More',
'Rating', style: TextStyle(fontSize: 18),
style: GoogleFonts.robotoCondensed(
textStyle: const TextStyle(
color: Colors.black87,
fontSize: 20,
fontWeight: FontWeight.bold,
), ),
onPressed: () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => VenuePage(venue)));
_bottomSheetIsOpen = false;
},
style: ElevatedButton.styleFrom(
primary: globals.BUTTONCOLOR,
), ),
),
],
); );
} }
@ -542,7 +531,7 @@ class MapState extends State<Map> {
textStyle: const TextStyle( textStyle: const TextStyle(
color: Colors.black87, color: Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 24, fontSize: 26,
)), )),
), ),
Text( Text(
@ -551,7 +540,7 @@ class MapState extends State<Map> {
textStyle: const TextStyle( textStyle: const TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
fontSize: 18, fontSize: 20,
)), )),
) )
], ],
@ -562,6 +551,7 @@ class MapState extends State<Map> {
print(_bottomSheetIsOpen); print(_bottomSheetIsOpen);
if (_bottomSheetIsOpen) { if (_bottomSheetIsOpen) {
Navigator.pop(context); Navigator.pop(context);
_bottomSheetIsOpen = false;
} }
} }
@ -597,6 +587,46 @@ class MapState extends State<Map> {
}*/ }*/
} }
class weatherIconRow extends StatelessWidget {
const weatherIconRow({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
const Text(
'Weather: \t\t',
style: TextStyle(fontSize: 18),
),
globals.forecast.getCurrentWeatherIcon(),
],
);
}
}
class weatherStatusRow extends StatelessWidget {
const weatherStatusRow({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Text(
' ' + globals.forecast.getCurrentWeatherStatus(),
style: const TextStyle(
fontSize: 16,
fontStyle: FontStyle.italic,
),
),
],
);
}
}
Widget buildDrawerSignedIn(BuildContext context) { Widget buildDrawerSignedIn(BuildContext context) {
return Drawer( return Drawer(
child: ListView( child: ListView(

View File

@ -88,6 +88,18 @@ class WeatherData {
case 17: case 17:
weatherStatus = 'Heavy snow showers'; weatherStatus = 'Heavy snow showers';
break; break;
case 18:
weatherStatus = 'Light rain';
break;
case 19:
weatherStatus = 'Moderate rain';
break;
case 20:
weatherStatus = 'Heavy rain';
break;
case 21:
weatherStatus = 'Thunder';
break;
default: default:
weatherStatus = 'Undefined'; weatherStatus = 'Undefined';
} }
@ -136,6 +148,14 @@ class WeatherData {
return const FaIcon(FontAwesomeIcons.snowflake); return const FaIcon(FontAwesomeIcons.snowflake);
case 17: case 17:
return const FaIcon(FontAwesomeIcons.snowflake); return const FaIcon(FontAwesomeIcons.snowflake);
case 18:
return const FaIcon(FontAwesomeIcons.cloudRain);
case 19:
return const FaIcon(FontAwesomeIcons.cloudRain);
case 20:
return const FaIcon(FontAwesomeIcons.cloudShowersHeavy);
case 21:
return const FaIcon(FontAwesomeIcons.bolt);
default: default:
return const FaIcon(FontAwesomeIcons.times); return const FaIcon(FontAwesomeIcons.times);
} }

View File

@ -23,9 +23,9 @@ import 'globals.dart' as globals;
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// await Firebase.initializeApp(); await Firebase.initializeApp();
//await loadAllVenues(); await loadAllVenues();
//await fetchWeather(); await fetchWeather();
runApp(MyApp()); runApp(MyApp());
} }
@ -33,7 +33,7 @@ void main() async {
Future fetchWeather() async { Future fetchWeather() async {
WeatherData tempWeather = WeatherData(0, 0); WeatherData tempWeather = WeatherData(0, 0);
Uri weatherDataURI = Uri.parse( Uri weatherDataURI = Uri.parse(
'https://group-4-75.pvt.dsv.su.se/target/weather-0.0.2-SNAPSHOT.war/weather'); 'https://group-4-75.pvt.dsv.su.se/target/info.war/weather');
final response = await http.get(weatherDataURI); final response = await http.get(weatherDataURI);
@ -67,7 +67,7 @@ class MyApp extends StatelessWidget {
Future loadAllVenues() async { Future loadAllVenues() async {
Uri venueDataURI = Uri.parse( Uri venueDataURI = Uri.parse(
'https://group-4-75.pvt.dsv.su.se/target/weather-0.0.4-SNAPSHOT.war/venue'); 'https://group-4-75.pvt.dsv.su.se/target/info.war/venue');
final response = await http.get(venueDataURI); final response = await http.get(venueDataURI);
@ -77,7 +77,7 @@ Future loadAllVenues() async {
// var sd = ShadowDetector(); // var sd = ShadowDetector();
// await sd.evaluateShadowsForAllVenues(seventyFiveVenues); // await sd.evaluateShadowsForAllVenues(seventyFiveVenues);
} else { } else {
throw const HttpException("Problem fetching the weather data"); throw const HttpException("Problem fetching the venue data");
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/Venue.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -10,7 +11,6 @@ import 'VenueInfo.dart';
import 'WeatherData.dart'; import 'WeatherData.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
class VenuePage extends StatefulWidget { class VenuePage extends StatefulWidget {
const VenuePage(this.venue, {Key? key}) : super(key: key); const VenuePage(this.venue, {Key? key}) : super(key: key);
final Venue venue; final Venue venue;
@ -24,37 +24,26 @@ class _VenuePageState extends State<VenuePage> {
final String imageLink = ''; final String imageLink = '';
late final Venue venue; late final Venue venue;
late VenueInfo venueInfo; late VenueInfo venueInfo;
_VenuePageState(this.venue); _VenuePageState(this.venue);
validateAndGetImageLink() {
if (imageLink == '') {
return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg';
} else {
return imageLink;
}
}
@override @override
void initState() { void initState() {
refreshWeather(); refreshWeather();
gatherVenueInfo();
} }
Future gatherVenueInfo() async { Future gatherVenueInfo() async {
VenueInfo vu = VenueInfo(); VenueInfo vu = VenueInfo();
venueInfo = vu; venueInfo = vu;
venueInfo = await vu.getVenueInfo(venue.venueName); venueInfo = await vu.getVenueInfo(venue);
} }
Future refreshWeather() async { Future refreshWeather() async {
WeatherData tempWeather = WeatherData(0, 0); WeatherData tempWeather = WeatherData(0, 0);
currentWeather = tempWeather; currentWeather = tempWeather;
Uri weatherDataURI = Uri.parse( Uri weatherDataURI = Uri.parse(
'https://group-4-75.pvt.dsv.su.se/target/weather-0.0.4-SNAPSHOT.war/weather'); 'https://group-4-75.pvt.dsv.su.se/target/info.war/weather');
final response = await http.get(weatherDataURI); final response = await http.get(weatherDataURI);
@ -85,9 +74,23 @@ class _VenuePageState extends State<VenuePage> {
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
return SingleChildScrollView( return SingleChildScrollView(
child: Expanded(
child: Container( child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
alignment: Alignment.center, alignment: Alignment.center,
child: Column(children: <Widget>[ child: buildPageContentColumn(),
),
),
);
} else {
return const CircularProgressIndicator();
}
})));
}
Column buildPageContentColumn() {
return Column(children: <Widget>[
Row( Row(
children: const [ children: const [
ShareButton(), ShareButton(),
@ -99,50 +102,31 @@ class _VenuePageState extends State<VenuePage> {
child: Image.network(venueInfo.getPhotoURL()), child: Image.network(venueInfo.getPhotoURL()),
), ),
]), ]),
// Row( Row(children: [buildNameAndAddress(), buildWeatherInfo()]),
// children: const [ AboutTheSpotTable(venueInfo: venueInfo),
// Text( //Expanded(child: AboutTheSpotTable(venueInfo: venueInfo)),
// 'Placeholder for image', ]);
// ), }
// ],
// ), Expanded buildWeatherInfo() {
Row(children: [ return Expanded(
Expanded( child: Container(
child: buildWeatherColumn(),
),
);
}
Expanded buildNameAndAddress() {
return Expanded(
child: Column( child: Column(
children: [ children: [
Text(venue.venueName, Text(venue.venueName,
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
) )),
),
Text(venue.venueAddress + ' ' + venue.venueStreetNo), Text(venue.venueAddress + ' ' + venue.venueStreetNo),
], ],
)),
Expanded(
child: Container(
// decoration: BoxDecoration(
// border: Border.all(color: const Color(0xffaaaaaa)),
// ),
// color: const Color(0xffe9e9e9),
child: buildWeatherColumn(),
),
)
]),
AboutTheSpotTable(venueInfo: venueInfo),
/*GridView.count(
crossAxisCount: 2,
children: [],
)*/
]),
),
);
}
else {
return CircularProgressIndicator();
}
}
)
)); ));
} }
@ -151,26 +135,15 @@ class _VenuePageState extends State<VenuePage> {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: /*Text('Weather Status:', child:
style: GoogleFonts.robotoCondensed( Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
textStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
)),*/
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column( Column(
children: [ children: [
currentWeather.getCurrentWeatherIcon(), currentWeather.getCurrentWeatherIcon(),
Text(currentWeather.getCurrentWeatherStatus()), Text(currentWeather.getCurrentWeatherStatus()),
], ],
), ),
Text(currentWeather Text(currentWeather.getCurrentTemperature().toString() + '\u2103'),
.getCurrentTemperature()
.toString() +
'\u2103'),
]), ]),
), ),
], ],
@ -181,6 +154,7 @@ class _VenuePageState extends State<VenuePage> {
//Just an example table //Just an example table
class AboutTheSpotTable extends StatefulWidget { class AboutTheSpotTable extends StatefulWidget {
final VenueInfo venueInfo; final VenueInfo venueInfo;
AboutTheSpotTable({ AboutTheSpotTable({
Key? key, Key? key,
required this.venueInfo, required this.venueInfo,
@ -193,9 +167,10 @@ class AboutTheSpotTable extends StatefulWidget {
class _AboutTheSpotTableState extends State<AboutTheSpotTable> { class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DataTable( return Center(
headingRowHeight: 30, child: DataTable(
columnSpacing: 100, // headingRowHeight: 30,
// columnSpacing: 100,
//dataRowHeight: 30, //dataRowHeight: 30,
dataTextStyle: GoogleFonts.robotoCondensed( dataTextStyle: GoogleFonts.robotoCondensed(
color: const Color(0xff4F6272), color: const Color(0xff4F6272),
@ -210,33 +185,35 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
const DataColumn(label: Text('', style: TextStyle())), const DataColumn(label: Text('', style: TextStyle())),
], ],
rows: [ rows: [
DataRow(cells: [ const DataRow(cells: [
DataCell(Text('Type of venue')), DataCell(Text('Type of venue')),
DataCell(Text('Saloon')), DataCell(Text('Restaurant')),
]), ]),
DataRow(cells: [ DataRow(cells: [
DataCell(Text('Pricing')), const DataCell(Text('Pricing')),
DataCell(Text(widget.venueInfo.getPriceClass())), DataCell(Text(widget.venueInfo.getPriceClass())),
]), ]),
DataRow(cells: [ DataRow(cells: [
DataCell(Text('Rating')), const DataCell(Text('Rating')),
DataCell(Text(widget.venueInfo.getRating().toString() + ' (' + widget.venueInfo.getTotalRatings().toString() + ' ratings)')), DataCell(Text(widget.venueInfo.getRating().toString() +
' (' +
widget.venueInfo.getTotalRatings().toString() +
' ratings)')),
]), ]),
DataRow(cells: [ const DataRow(cells: [
DataCell(Text('Current activity')), DataCell(Text('Current activity')),
DataCell(Text('Moderate')), DataCell(Text('Moderate')),
]), ]),
DataRow(cells: [ DataRow(cells: [
DataCell(Text('Opening hours')), const DataCell(Text('Opening hours')),
DataCell(Text(widget.venueInfo.getOpeningHours())), DataCell(Text(widget.venueInfo.getOpeningHours())),
]), ]),
], ],
),
); );
} }
} }
class SavePlaceButton extends StatelessWidget { class SavePlaceButton extends StatelessWidget {
const SavePlaceButton({ const SavePlaceButton({
Key? key, Key? key,
@ -265,14 +242,26 @@ class ShareButton extends StatelessWidget {
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Expanded( return Expanded(
child: TextButton.icon( child: Column(
onPressed: () {}, children: <Widget>[
TextButton.icon(
onPressed: () {shareVenue();},
icon: const Icon(Icons.share), icon: const Icon(Icons.share),
label: const Text('Share'), label: const Text('Share'),
), ),
],
),
); );
} }
void shareVenue() {
Share.share('Share this venue', subject: 'Subject venue');
}
} }

View File

@ -50,6 +50,7 @@ dependencies:
webview_flutter: ^3.0.0 webview_flutter: ^3.0.0
syncfusion_flutter_sliders: ^20.1.57 syncfusion_flutter_sliders: ^20.1.57
intl: ^0.17.0 intl: ^0.17.0
share_plus: ^4.0.4
#Google Sign-in #Google Sign-in
firebase_auth: ^1.1.4 firebase_auth: ^1.1.4
google_sign_in: ^5.0.3 google_sign_in: ^5.0.3