From 1f659c8913ac3b902b18977b02405c97479e3d84 Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Mon, 30 May 2022 14:06:35 +0200 Subject: [PATCH 1/2] New bottomsheet and venue features --- lib/ListViewPage.dart | 60 ++++--- lib/Map.dart | 401 ++++++++++++++++++++++-------------------- lib/VenueInfo.dart | 5 +- lib/WeatherData.dart | 20 +++ lib/main.dart | 18 +- lib/venuePage.dart | 273 ++++++++++++++-------------- 6 files changed, 416 insertions(+), 361 deletions(-) diff --git a/lib/ListViewPage.dart b/lib/ListViewPage.dart index 10195fa..05b2f7e 100644 --- a/lib/ListViewPage.dart +++ b/lib/ListViewPage.dart @@ -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'; @@ -20,7 +22,7 @@ class _ListViewPageState extends State { return Scaffold( appBar: AppBar( title: const Text('Venues near you',), - backgroundColor: globals.BACKGROUNDCOLOR, + backgroundColor: globals.BACKGROUNDCOLOR, ), body: buildListView(), ); @@ -32,13 +34,13 @@ class _ListViewPageState extends State { itemCount: allVenues.length, itemBuilder: (context, index) { return ListTile( - shape: buildBorder(), - onTap: () => _navigateToVenue(allVenues[index]), - leading: buildIconBox(index, context), - title: buildTitleText(index), - subtitle: buildWeatherRow(), + shape: buildBorder(), + onTap: () => _navigateToVenue(allVenues[index]), + leading: buildIconBox(index, context), + title: buildTitleText(index), + subtitle: buildWeatherRow(), - trailing: const Text('400m'), + // trailing: const Text('400m'), ); }, ); @@ -46,43 +48,45 @@ class _ListViewPageState extends State { RoundedRectangleBorder buildBorder() { return RoundedRectangleBorder( - side: const BorderSide(color: Color(0xffe9e9e9), width: 1), - borderRadius: BorderRadius.circular(5)); + side: const BorderSide(color: Color(0xffe9e9e9), width: 1), + borderRadius: BorderRadius.circular(5)); } SizedBox buildIconBox(int index, BuildContext context) { return SizedBox( - height: double.infinity, - child: allVenues[index].getIcon(context), - ); + height: double.infinity, + child: allVenues[index].getIcon(context), + ); } Row buildWeatherRow() { return Row( - children: [ - const Text('Current weather: '), - const Spacer( - flex: 2, - ), - globals.forecast.getCurrentWeatherIcon(), - const Spacer(), - ], - ); + children: [ + const Text('Current weather: '), + const Spacer( + flex: 2, + ), + globals.forecast.getCurrentWeatherIcon(), + const Spacer(), + ], + ); } Text buildTitleText(int index) { return Text( - allVenues[index].venueName.toString(), - style: GoogleFonts.roboto( - textStyle: const TextStyle( - fontSize: 18, - color: Color(0xff994411), - )), - ); + allVenues[index].venueName.toString(), + style: GoogleFonts.roboto( + textStyle: const TextStyle( + fontSize: 18, + color: Color(0xff994411), + )), + ); } void _navigateToVenue(Venue venue) { Navigator.of(context) .push(MaterialPageRoute(builder: (context) => VenuePage(venue))); } + + } diff --git a/lib/Map.dart b/lib/Map.dart index d3d1e6e..4c1382f 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -106,18 +106,18 @@ class MapState extends State { color: Colors.white, child: Center( child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - /*const Text('BottomSheet'), + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + /*const Text('BottomSheet'), ElevatedButton( child: const Text('Close BottomSheet'), onPressed: () {Navigator.pop(context);})*/ - Container( - child: Text(webScraper.openingHoursThisWeek.length.toString()), - ), - ], - )), + Container( + child: Text(webScraper.openingHoursThisWeek.length.toString()), + ), + ], + )), ); })); } @@ -238,19 +238,19 @@ class MapState extends State { icon: Icon(Icons.filter_list), iconSize: 40, itemBuilder: (context) => [ - const PopupMenuItem( - child: Text( - "Filters", - style: TextStyle( - fontSize: 20, + const PopupMenuItem( + child: Text( + "Filters", + style: TextStyle( + fontSize: 20, + ), + ), + padding: EdgeInsets.only(left: 60), ), - ), - padding: EdgeInsets.only(left: 60), - ), - createCheckBoxes(), - createPriceSlider(), - PopupMenuItem( - child: ButtonBar( + createCheckBoxes(), + createPriceSlider(), + PopupMenuItem( + child: ButtonBar( alignment: MainAxisAlignment.center, children: [ ElevatedButton( @@ -266,7 +266,7 @@ class MapState extends State { ), ], )) - ]); + ]); } // Creates the checkboxes for the filter menu @@ -282,46 +282,46 @@ class MapState extends State { ), StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return CheckboxListTile( - value: _barFilterValue, - onChanged: (bool? newValue) { - setState(() { - _barFilterValue = newValue; - }); - }, - title: const Icon( - Icons.sports_bar, - color: Colors.orange, - )); - }), + return CheckboxListTile( + value: _barFilterValue, + onChanged: (bool? newValue) { + setState(() { + _barFilterValue = newValue; + }); + }, + title: const Icon( + Icons.sports_bar, + color: Colors.orange, + )); + }), StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return CheckboxListTile( - value: _restaurantFilterValue, - onChanged: (bool? newValue) { - setState(() { - _restaurantFilterValue = newValue; - }); - }, - title: Icon( - Icons.restaurant, - color: Colors.blueGrey[200], - ), - ); - }), + return CheckboxListTile( + value: _restaurantFilterValue, + onChanged: (bool? newValue) { + setState(() { + _restaurantFilterValue = newValue; + }); + }, + title: Icon( + Icons.restaurant, + color: Colors.blueGrey[200], + ), + ); + }), //Cafe checkbox StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return CheckboxListTile( - value: _cafeFilterValue, - onChanged: (bool? newValue) { - setState(() => _cafeFilterValue = newValue); - }, - title: Icon( - Icons.coffee, - color: Colors.brown[400], - )); - }), + return CheckboxListTile( + value: _cafeFilterValue, + onChanged: (bool? newValue) { + setState(() => _cafeFilterValue = newValue); + }, + title: Icon( + Icons.coffee, + color: Colors.brown[400], + )); + }), ], /*floatingActionButton: Padding( @@ -347,30 +347,30 @@ class MapState extends State { return PopupMenuItem( child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return SfSlider( - value: _priceFilterValue, - onChanged: (dynamic newValue) { - setState((() => _priceFilterValue = newValue)); - }, - min: 1, - max: 3, - showTicks: true, - interval: 1, - activeColor: Colors.blue, - showLabels: true, - stepSize: 1.0, - labelFormatterCallback: (dynamic value, String formattedText) { - switch (value) { - case 1: - return '\$'; - case 2: - return '\$\$'; - case 3: - return '\$\$\$'; - } - return value.toString(); - }); - }), + return SfSlider( + value: _priceFilterValue, + onChanged: (dynamic newValue) { + setState((() => _priceFilterValue = newValue)); + }, + min: 1, + max: 3, + showTicks: true, + interval: 1, + activeColor: Colors.blue, + showLabels: true, + stepSize: 1.0, + labelFormatterCallback: (dynamic value, String formattedText) { + switch (value) { + case 1: + return '\$'; + case 2: + return '\$\$'; + case 3: + return '\$\$\$'; + } + return value.toString(); + }); + }), ); } @@ -380,40 +380,40 @@ class MapState extends State { 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); }, child: Container( child: FittedBox( - child: Material( - color: Colors.white, - elevation: 14.0, - borderRadius: BorderRadius.circular(24.0), - shadowColor: Color(0x802196F3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: 250, - height: 200, - child: ClipRRect( - borderRadius: new BorderRadius.circular(24.0), - child: + child: Material( + color: Colors.white, + elevation: 14.0, + borderRadius: BorderRadius.circular(24.0), + shadowColor: Color(0x802196F3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 250, + height: 200, + child: ClipRRect( + borderRadius: new BorderRadius.circular(24.0), + child: const Image(image: AssetImage('assets/images/bild.png')), - ), - ), - Container( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text(resturantName), - ), - ) - ], + ), ), - ), - )), + Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text(restaurantName), + ), + ) + ], + ), + ), + )), ); } @@ -427,8 +427,6 @@ class MapState extends State { } 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(((context) { return InkWell( @@ -439,48 +437,12 @@ class MapState extends State { ); }, 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: [ - 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), ], ), ), @@ -489,7 +451,45 @@ class MapState extends State { })); } - 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: [ + 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: [ @@ -498,19 +498,7 @@ class MapState extends State { 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), ], ), ), @@ -518,20 +506,20 @@ class MapState extends State { ); } - 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,19 +530,19 @@ class MapState extends State { venue.venueName, style: GoogleFonts.roboto( textStyle: const TextStyle( - color: Colors.black87, - fontWeight: FontWeight.bold, - fontSize: 24, - )), + color: Colors.black87, + fontWeight: FontWeight.bold, + fontSize: 26, + )), ), Text( venue.venueAddress + ' ' + venue.venueStreetNo, style: GoogleFonts.roboto( textStyle: const TextStyle( - color: Colors.black, - fontWeight: FontWeight.w300, - fontSize: 18, - )), + color: Colors.black, + fontWeight: FontWeight.w300, + fontSize: 20, + )), ) ], ); @@ -564,6 +552,7 @@ class MapState extends State { print(_bottomSheetIsOpen); if (_bottomSheetIsOpen) { Navigator.pop(context); + _bottomSheetIsOpen = false; } } @@ -599,6 +588,46 @@ class MapState extends State { }*/ } +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( @@ -606,7 +635,7 @@ Widget buildDrawerSignedIn(BuildContext context) { children: [ DrawerHeader( decoration: - const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), + const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), child: Column( children: const [ Text( @@ -667,7 +696,7 @@ Widget buildDrawerSignedOut(BuildContext context) { children: [ DrawerHeader( decoration: - const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), + const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), child: Column( children: const [ Text( @@ -737,4 +766,4 @@ class _Marker { var coordinates; _Marker(this.Plats_1, this.Gatunr_1, this.coordinates); -} \ No newline at end of file +} diff --git a/lib/VenueInfo.dart b/lib/VenueInfo.dart index 8b6ea69..f5150b2 100644 --- a/lib/VenueInfo.dart +++ b/lib/VenueInfo.dart @@ -78,8 +78,11 @@ class VenueInfo { } String getOpeningHours() { + String splitString; if(_openHoursToday.isNotEmpty) { - return _openHoursToday; + splitString = _openHoursToday.replaceAll(';', '\n'); + splitString = splitString.replaceAll(',', ',\n'); + return splitString; } return 'N/A'; } diff --git a/lib/WeatherData.dart b/lib/WeatherData.dart index b555fe8..4726afd 100644 --- a/lib/WeatherData.dart +++ b/lib/WeatherData.dart @@ -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); } diff --git a/lib/main.dart b/lib/main.dart index 9e44a0f..55be3dd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,14 +26,26 @@ void main() async { await Firebase.initializeApp(); await loadAllVenues(); await fetchWeather(); + // await createVenue(); + // await setWeather(); runApp(MyApp()); } +setWeather() { + WeatherData weather = WeatherData(4, 15); + globals.forecast = weather; +} + +createVenue() { + Venue venue = Venue(00, 'Restaurang Aira', 'Biskopsvägen', '9', const LatLng(59.32117929060902, 18.123636884658502)); + globals.VENUES.add(venue); +} + 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 +79,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 +89,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"); } } diff --git a/lib/venuePage.dart b/lib/venuePage.dart index 3d4a2ad..741e822 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -10,7 +10,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 +23,27 @@ class _VenuePageState extends State { 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 { + Future gatherVenueInfo() async { VenueInfo vu = VenueInfo(); venueInfo = vu; venueInfo = await vu.getVenueInfo(venue.venueName); } - 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); @@ -80,70 +69,62 @@ class _VenuePageState extends State { backgroundColor: const Color(0xffac7b84), ), body: Center( - child: FutureBuilder( - future: gatherVenueInfo(), - builder: (context, snapshot) { - if(snapshot.connectionState == ConnectionState.done) { - return SingleChildScrollView( - child: Container( - alignment: Alignment.center, - child: Column(children: [ - Row( - children: const [ - ShareButton(), - SavePlaceButton(), - ], - ), - Row(children: [ - Expanded( - child: Image.network(venueInfo.getPhotoURL()), - ), - ]), - // Row( - // children: const [ - // Text( - // 'Placeholder for image', - // ), - // ], - // ), - Row(children: [ - 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(); - } - } - ) - )); + child: FutureBuilder( + future: gatherVenueInfo(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + alignment: Alignment.center, + child: buildPageContentColumn(), + ), + ); + } else { + return const CircularProgressIndicator(); + } + }))); + } + + Column buildPageContentColumn() { + return Column(children: [ + Row( + children: const [ + ShareButton(), + SavePlaceButton(), + ], + ), + Row(children: [ + Expanded( + child: Image.network(venueInfo.getPhotoURL()), + ), + ]), + Row(children: [buildNameAndAddress(), buildWeatherInfo()]), + 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), + ], + )); } Column buildWeatherColumn() { @@ -151,27 +132,16 @@ class _VenuePageState extends State { 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, + child: + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Column( children: [ - Column( - children: [ - currentWeather.getCurrentWeatherIcon(), - Text(currentWeather.getCurrentWeatherStatus()), - ], - ), - Text(currentWeather - .getCurrentTemperature() - .toString() + - '\u2103'), - ]), + currentWeather.getCurrentWeatherIcon(), + Text(currentWeather.getCurrentWeatherStatus()), + ], + ), + Text(currentWeather.getCurrentTemperature().toString() + '\u2103'), + ]), ), ], ); @@ -181,7 +151,8 @@ class _VenuePageState extends State { //Just an example table class AboutTheSpotTable extends StatefulWidget { final VenueInfo venueInfo; - AboutTheSpotTable({ + + AboutTheSpotTable({ Key? key, required this.venueInfo, }) : super(key: key); @@ -193,50 +164,53 @@ class AboutTheSpotTable extends StatefulWidget { class _AboutTheSpotTableState extends State { @override Widget build(BuildContext context) { - return DataTable( - headingRowHeight: 30, - columnSpacing: 100, - //dataRowHeight: 30, - dataTextStyle: GoogleFonts.robotoCondensed( - color: const Color(0xff4F6272), + return Center( + child: DataTable( + // headingRowHeight: 30, + // columnSpacing: 100, + //dataRowHeight: 30, + dataTextStyle: GoogleFonts.robotoCondensed( + color: const Color(0xff4F6272), + ), + columns: [ + DataColumn( + label: Text('About the spot', + style: GoogleFonts.roboto( + textStyle: const TextStyle( + fontSize: 18, + )))), + const DataColumn(label: Text('', style: TextStyle())), + ], + rows: [ + const DataRow(cells: [ + DataCell(Text('Type of venue')), + DataCell(Text('Restaurant')), + ]), + DataRow(cells: [ + const DataCell(Text('Pricing')), + DataCell(Text(widget.venueInfo.getPriceClass())), + ]), + DataRow(cells: [ + const DataCell(Text('Rating')), + DataCell(Text(widget.venueInfo.getRating().toString() + + ' (' + + widget.venueInfo.getTotalRatings().toString() + + ' ratings)')), + ]), + const DataRow(cells: [ + DataCell(Text('Current activity')), + DataCell(Text('Moderate')), + ]), + DataRow(cells: [ + const DataCell(Text('Opening hours')), + DataCell(Text(widget.venueInfo.getOpeningHours())), + ]), + ], ), - columns: [ - DataColumn( - label: Text('About the spot', - style: GoogleFonts.roboto( - textStyle: const TextStyle( - fontSize: 18, - )))), - const DataColumn(label: Text('', style: TextStyle())), - ], - rows: [ - DataRow(cells: [ - DataCell(Text('Type of venue')), - DataCell(Text('Saloon')), - ]), - DataRow(cells: [ - DataCell(Text('Pricing')), - DataCell(Text(widget.venueInfo.getPriceClass())), - ]), - DataRow(cells: [ - DataCell(Text('Rating')), - DataCell(Text(widget.venueInfo.getRating().toString() + ' (' + widget.venueInfo.getTotalRatings().toString() + ' ratings)')), - ]), - DataRow(cells: [ - DataCell(Text('Current activity')), - DataCell(Text('Moderate')), - ]), - DataRow(cells: [ - DataCell(Text('Opening hours')), - DataCell(Text(widget.venueInfo.getOpeningHours())), - ]), - ], ); } } - - class SavePlaceButton extends StatelessWidget { const SavePlaceButton({ Key? key, @@ -265,14 +239,27 @@ class ShareButton extends StatelessWidget { Key? key, }) : super(key: key); + /* Future share() async { + await FlutterShare.share( + title: 'Share this place', + text: 'Share this place', + linkUrl: 'https://flutter.dev/', + chooserTitle: 'Example Chooser Title'); + } +*/ @override Widget build(BuildContext context) { return Expanded( - child: TextButton.icon( - onPressed: () {}, - icon: const Icon(Icons.share), - label: const Text('Share'), + child: Column( + children: [ + TextButton.icon( + onPressed: () {}, + icon: const Icon(Icons.share), + label: const Text('Share'), + ), + ], ), ); } -} \ No newline at end of file + +} -- 2.39.5 From 5270b3ee81054893e301538479fb1804ece62921 Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Mon, 30 May 2022 15:22:51 +0200 Subject: [PATCH 2/2] change to modalBottomSheet --- lib/Map.dart | 5 +++-- lib/venuePage.dart | 34 ++++++++++++++++++---------------- pubspec.yaml | 1 + 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/Map.dart b/lib/Map.dart index ce8a915..41eb8c4 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -426,7 +426,8 @@ class MapState extends State { createBottomDrawer(Venue venue) async { _bottomSheetIsOpen = true; - Scaffold.of(context).showBottomSheet(((context) { + // Scaffold.of(context).showBottomSheet(((context) { + showModalBottomSheet(context: context, builder: (BuildContext context) { return InkWell( onTap: () { Navigator.push( @@ -446,7 +447,7 @@ class MapState extends State { ), ), ); - })); + }); } Container bottomSheetWidgetContainer(Venue venue, BuildContext context) { diff --git a/lib/venuePage.dart b/lib/venuePage.dart index 741e822..98c5328 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -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'; @@ -29,13 +30,12 @@ class _VenuePageState extends State { @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 { @@ -74,11 +74,13 @@ class _VenuePageState extends State { builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { return SingleChildScrollView( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - alignment: Alignment.center, - child: buildPageContentColumn(), + child: Expanded( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + alignment: Alignment.center, + child: buildPageContentColumn(), + ), ), ); } else { @@ -102,6 +104,7 @@ class _VenuePageState extends State { ]), Row(children: [buildNameAndAddress(), buildWeatherInfo()]), AboutTheSpotTable(venueInfo: venueInfo), + //Expanded(child: AboutTheSpotTable(venueInfo: venueInfo)), ]); } @@ -239,21 +242,14 @@ class ShareButton extends StatelessWidget { Key? key, }) : super(key: key); - /* Future share() async { - await FlutterShare.share( - title: 'Share this place', - text: 'Share this place', - linkUrl: 'https://flutter.dev/', - chooserTitle: 'Example Chooser Title'); - } -*/ + @override Widget build(BuildContext context) { return Expanded( child: Column( children: [ TextButton.icon( - onPressed: () {}, + onPressed: () {shareVenue();}, icon: const Icon(Icons.share), label: const Text('Share'), ), @@ -262,4 +258,10 @@ class ShareButton extends StatelessWidget { ); } + void shareVenue() { + + Share.share('Share this venue', subject: 'Subject venue'); + + } + } diff --git a/pubspec.yaml b/pubspec.yaml index ebe0661..d5595ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 -- 2.39.5