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

View File

@ -378,7 +378,7 @@ class MapState extends State<Map> {
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(
onTap: () {
_gotoLocation(lat, lng);
@ -405,7 +405,7 @@ class MapState extends State<Map> {
Container(
child: Padding(
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 {
// 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;
Scaffold.of(context).showBottomSheet<void>(((context) {
// Scaffold.of(context).showBottomSheet<void>(((context) {
showModalBottomSheet(context: context, builder: (BuildContext context) {
return InkWell(
onTap: () {
Navigator.push(
@ -437,57 +436,59 @@ class MapState extends State<Map> {
);
},
child: Container(
height: 250,
height: 175,
color: const Color(0xFFF5F5F5),
child: Center(
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
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:'),
],
)
],
),
)
bottomSheetWidgetContainer(venue, context),
],
),
),
),
);
}));
});
}
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(
mainAxisSize: MainAxisSize.min,
children: [
@ -496,19 +497,7 @@ class MapState extends State<Map> {
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
child: const Text('Close'),
onPressed: () {
Navigator.pop(context);
_bottomSheetIsOpen = false;
}),
ElevatedButton(
child: const Text('ListView'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ListViewPage()));
},
),
readMoreButton(context, venue),
],
),
),
@ -516,20 +505,20 @@ class MapState extends State<Map> {
);
}
Column columnCoveringRating() {
return Column(
children: [
Text(
'Rating',
style: GoogleFonts.robotoCondensed(
textStyle: const TextStyle(
color: Colors.black87,
fontSize: 20,
fontWeight: FontWeight.bold,
ElevatedButton readMoreButton(BuildContext context, Venue venue) {
return ElevatedButton(
child: const Text(
'Read More',
style: TextStyle(fontSize: 18),
),
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(
color: Colors.black87,
fontWeight: FontWeight.bold,
fontSize: 24,
fontSize: 26,
)),
),
Text(
@ -551,7 +540,7 @@ class MapState extends State<Map> {
textStyle: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.w300,
fontSize: 18,
fontSize: 20,
)),
)
],
@ -562,6 +551,7 @@ class MapState extends State<Map> {
print(_bottomSheetIsOpen);
if (_bottomSheetIsOpen) {
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) {
return Drawer(
child: ListView(

View File

@ -88,6 +88,18 @@ class WeatherData {
case 17:
weatherStatus = 'Heavy snow showers';
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:
weatherStatus = 'Undefined';
}
@ -136,6 +148,14 @@ class WeatherData {
return const FaIcon(FontAwesomeIcons.snowflake);
case 17:
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:
return const FaIcon(FontAwesomeIcons.times);
}

View File

@ -23,9 +23,9 @@ import 'globals.dart' as globals;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// await Firebase.initializeApp();
//await loadAllVenues();
//await fetchWeather();
await Firebase.initializeApp();
await loadAllVenues();
await fetchWeather();
runApp(MyApp());
}
@ -33,7 +33,7 @@ void main() async {
Future fetchWeather() async {
WeatherData tempWeather = WeatherData(0, 0);
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);
@ -67,7 +67,7 @@ class MyApp extends StatelessWidget {
Future loadAllVenues() async {
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);
@ -77,7 +77,7 @@ Future loadAllVenues() async {
// var sd = ShadowDetector();
// await sd.evaluateShadowsForAllVenues(seventyFiveVenues);
} 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:io';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_applicationdemo/Venue.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter/material.dart';
@ -10,7 +11,6 @@ import 'VenueInfo.dart';
import 'WeatherData.dart';
import 'globals.dart' as globals;
class VenuePage extends StatefulWidget {
const VenuePage(this.venue, {Key? key}) : super(key: key);
final Venue venue;
@ -24,37 +24,26 @@ class _VenuePageState extends State<VenuePage> {
final String imageLink = '';
late final Venue venue;
late VenueInfo venueInfo;
_VenuePageState(this.venue);
validateAndGetImageLink() {
if (imageLink == '') {
return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg';
} else {
return imageLink;
}
}
@override
void initState() {
refreshWeather();
gatherVenueInfo();
}
Future gatherVenueInfo() async {
VenueInfo vu = VenueInfo();
venueInfo = vu;
venueInfo = await vu.getVenueInfo(venue.venueName);
venueInfo = await vu.getVenueInfo(venue);
}
Future refreshWeather() async {
WeatherData tempWeather = WeatherData(0, 0);
currentWeather = tempWeather;
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);
@ -85,9 +74,23 @@ class _VenuePageState extends State<VenuePage> {
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return SingleChildScrollView(
child: Expanded(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
alignment: Alignment.center,
child: Column(children: <Widget>[
child: buildPageContentColumn(),
),
),
);
} else {
return const CircularProgressIndicator();
}
})));
}
Column buildPageContentColumn() {
return Column(children: <Widget>[
Row(
children: const [
ShareButton(),
@ -99,50 +102,31 @@ class _VenuePageState extends State<VenuePage> {
child: Image.network(venueInfo.getPhotoURL()),
),
]),
// Row(
// children: const [
// Text(
// 'Placeholder for image',
// ),
// ],
// ),
Row(children: [
Expanded(
Row(children: [buildNameAndAddress(), buildWeatherInfo()]),
AboutTheSpotTable(venueInfo: venueInfo),
//Expanded(child: AboutTheSpotTable(venueInfo: venueInfo)),
]);
}
Expanded buildWeatherInfo() {
return Expanded(
child: Container(
child: buildWeatherColumn(),
),
);
}
Expanded buildNameAndAddress() {
return Expanded(
child: Column(
children: [
Text(venue.venueName,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
)
),
)),
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: [
Padding(
padding: const EdgeInsets.all(4.0),
child: /*Text('Weather Status:',
style: GoogleFonts.robotoCondensed(
textStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
)),*/
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
child:
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Column(
children: [
currentWeather.getCurrentWeatherIcon(),
Text(currentWeather.getCurrentWeatherStatus()),
],
),
Text(currentWeather
.getCurrentTemperature()
.toString() +
'\u2103'),
Text(currentWeather.getCurrentTemperature().toString() + '\u2103'),
]),
),
],
@ -181,6 +154,7 @@ class _VenuePageState extends State<VenuePage> {
//Just an example table
class AboutTheSpotTable extends StatefulWidget {
final VenueInfo venueInfo;
AboutTheSpotTable({
Key? key,
required this.venueInfo,
@ -193,9 +167,10 @@ class AboutTheSpotTable extends StatefulWidget {
class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
@override
Widget build(BuildContext context) {
return DataTable(
headingRowHeight: 30,
columnSpacing: 100,
return Center(
child: DataTable(
// headingRowHeight: 30,
// columnSpacing: 100,
//dataRowHeight: 30,
dataTextStyle: GoogleFonts.robotoCondensed(
color: const Color(0xff4F6272),
@ -210,33 +185,35 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
const DataColumn(label: Text('', style: TextStyle())),
],
rows: [
DataRow(cells: [
const DataRow(cells: [
DataCell(Text('Type of venue')),
DataCell(Text('Saloon')),
DataCell(Text('Restaurant')),
]),
DataRow(cells: [
DataCell(Text('Pricing')),
const DataCell(Text('Pricing')),
DataCell(Text(widget.venueInfo.getPriceClass())),
]),
DataRow(cells: [
DataCell(Text('Rating')),
DataCell(Text(widget.venueInfo.getRating().toString() + ' (' + widget.venueInfo.getTotalRatings().toString() + ' ratings)')),
const DataCell(Text('Rating')),
DataCell(Text(widget.venueInfo.getRating().toString() +
' (' +
widget.venueInfo.getTotalRatings().toString() +
' ratings)')),
]),
DataRow(cells: [
const DataRow(cells: [
DataCell(Text('Current activity')),
DataCell(Text('Moderate')),
]),
DataRow(cells: [
DataCell(Text('Opening hours')),
const DataCell(Text('Opening hours')),
DataCell(Text(widget.venueInfo.getOpeningHours())),
]),
],
),
);
}
}
class SavePlaceButton extends StatelessWidget {
const SavePlaceButton({
Key? key,
@ -265,14 +242,26 @@ class ShareButton extends StatelessWidget {
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Expanded(
child: TextButton.icon(
onPressed: () {},
child: Column(
children: <Widget>[
TextButton.icon(
onPressed: () {shareVenue();},
icon: const Icon(Icons.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
syncfusion_flutter_sliders: ^20.1.57
intl: ^0.17.0
share_plus: ^4.0.4
#Google Sign-in
firebase_auth: ^1.1.4
google_sign_in: ^5.0.3