From 66efb8117a5656ad75f6b878e9510dcdc62ffeef Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Wed, 25 May 2022 10:44:56 +0200 Subject: [PATCH 1/4] Added support to creating VenueObjects from data --- lib/Venue.dart | 105 ++++++++++++++++++++++++++----- lib/WeatherData.dart | 143 +++++++++++++++++++++++++++++++++++++++++++ lib/main.dart | 67 +++++++++++++++++--- lib/venuePage.dart | 9 +-- 4 files changed, 297 insertions(+), 27 deletions(-) create mode 100644 lib/WeatherData.dart diff --git a/lib/Venue.dart b/lib/Venue.dart index 049dc90..368d761 100644 --- a/lib/Venue.dart +++ b/lib/Venue.dart @@ -1,31 +1,108 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class Venue { - late String venueName; - late int venueID; - late VenueType typeOfVenue; + int venueID; + String venueName; + String venueAddress; + String venueStreetNo; late LatLng position; - late InfoWindow infoWindow; bool inShade = false; + Venue(this.venueID, this.venueName, this.venueAddress, this.venueStreetNo, + this.position); - Venue(this.venueName, - this.venueID, this.typeOfVenue, this.position); + factory Venue.fromJson(Map json, id) { + var tempId = id; + var tempName = json['name']; + var tempAddress = json['address']; + var tempStreetNo = json['streetNo']; + var tempCoordinates = json['coordinates']; + + var splitArr = []; + splitArr = tempCoordinates.toString().split(';'); + LatLng tempPosition = LatLng(double.parse(splitArr[1]), double.parse(splitArr[0])); + + + print(splitArr[0].toString() + ' : ' + splitArr[1].toString()); + print('Coordinates: ' + tempCoordinates); + print('Parsed: ' + double.parse(splitArr[0]).toString()); + print(LatLng(double.parse(splitArr[1]), double.parse(splitArr[0]))); + print(tempAddress + tempName); + print(tempPosition.latitude.toString() + " " + splitArr[0]); + + // print('Json-Object:'); + // print(json); + + // print(venues); + // print(json['name']); + // print(json['address']); + // print(json['streetNo']); + // print(json['coordinates']); + + if (tempName != null && + tempAddress != null && + tempStreetNo != null && + tempCoordinates != null) { + return Venue(tempId, tempName, tempAddress, tempStreetNo, tempPosition); + } else { + return Venue(0, 'name', 'address', 'streetNo', const LatLng(0, 0)); + } + } BitmapDescriptor drawIconColor() { - if(inShade) { + if (inShade) { return BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueAzure); - } - else { + } else { return BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueYellow); } } + Widget getVenue(BuildContext context) { + return Text(venueName); + } + Widget getAddress(BuildContext context) { + return Text(venueAddress + ' ' + venueStreetNo); + } + + Widget getCoordinates(BuildContext context) { + return Text(position.toString()); + } + + LatLng getPositionAsLatLng(BuildContext context) { + return position; + } + + Widget getIcon(BuildContext context) { + if (venueName.toLowerCase().contains('estau')) { + return const Icon(Icons.restaurant); + } else if (venueName.toLowerCase().contains('kaf')) { + return const Icon(Icons.local_cafe); + } else if (venueName.toLowerCase().contains('pizz')) { + return const Icon(Icons.local_pizza); + } else { + return const Icon(Icons.food_bank); + } + } + + @override + String toString() { + return 'ID: ' + + venueID.toString() + + ' ' + + 'name: ' + + venueName + + ', ' + + 'address: ' + + venueAddress + + ' ' + + venueStreetNo + + ', ' + + 'coordinates: ' + + position.toString(); + } } - - -enum VenueType{ - cafe, restaurant, bar -} \ No newline at end of file +enum VenueType { cafe, restaurant, bar } diff --git a/lib/WeatherData.dart b/lib/WeatherData.dart new file mode 100644 index 0000000..83ae1f0 --- /dev/null +++ b/lib/WeatherData.dart @@ -0,0 +1,143 @@ + +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class WeatherData { + final int weatherValue; + final int temperature; + + WeatherData(this.weatherValue, this.temperature); + + factory WeatherData.fromJson(Map json) { + var value = json.values; + var tempWeatherData; + var tempTemperature; + + if (value.first['wsymb2'] is int) { + tempWeatherData = value.first['wsymb2']; + } + if (value.first['temp'] is double) { + tempTemperature = value.first['temp']; + } + + if (tempWeatherData != null && tempTemperature != null) { + return WeatherData(tempWeatherData, tempTemperature.round()); + } else { + return WeatherData(0, 0); + } + } + + int getCurrentTemperature() { + return temperature; + } + + String getCurrentWeatherStatus() { + String weatherStatus; + switch (weatherValue) { + case 0: + weatherStatus = 'Undefined'; + break; + case 1: + weatherStatus = 'Clear sky'; + break; + case 2: + weatherStatus = 'Nearly clear sky'; + break; + case 3: + weatherStatus = 'Variable cloudiness'; + break; + case 4: + weatherStatus = 'Halfclear sky'; + break; + case 5: + weatherStatus = 'Cloudy sky'; + break; + case 6: + weatherStatus = 'Overcast'; + break; + case 7: + weatherStatus = 'Fog'; + break; + case 8: + weatherStatus = 'Light rain showers'; + break; + case 9: + weatherStatus = 'Moderate rain showers'; + break; + case 10: + weatherStatus = 'Heavy rain showers'; + break; + case 11: + weatherStatus = 'Thunderstorm'; + break; + case 12: + weatherStatus = 'Light sleet showers'; + break; + case 13: + weatherStatus = 'Moderate sleet showers'; + break; + case 14: + weatherStatus = 'Heavy sleet showers'; + break; + case 15: + weatherStatus = 'Light snow showers'; + break; + case 16: + weatherStatus = 'Moderate snow showers'; + break; + case 17: + weatherStatus = 'Heavy snow showers'; + break; + default: + weatherStatus = 'Undefined'; + } + return weatherStatus; + } + + Widget getCurrentWeatherIcon() { + switch (weatherValue) { + case 1: + return const Icon( + Icons.sunny, + color: Color.fromARGB(255, 251, 183, 9), + ); + case 2: + return const Icon( + Icons.sunny, + color: Color.fromARGB(255, 251, 183, 9), + ); + case 3: + return const FaIcon(FontAwesomeIcons.cloudSun); + case 4: + return const FaIcon(FontAwesomeIcons.cloudSun); + case 5: + return const FaIcon(FontAwesomeIcons.cloud); + case 6: + return const FaIcon(FontAwesomeIcons.cloud); + case 7: + return const FaIcon(FontAwesomeIcons.smog); + case 8: + return const FaIcon(FontAwesomeIcons.umbrella); + case 9: + return const FaIcon(FontAwesomeIcons.cloudRain); + case 10: + return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); + case 11: + return const FaIcon(FontAwesomeIcons.cloudflare); + case 12: + return const FaIcon(FontAwesomeIcons.cloudRain); + case 13: + return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); + case 14: + return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); + case 15: + return const FaIcon(FontAwesomeIcons.snowflake); + case 16: + return const FaIcon(FontAwesomeIcons.snowflake); + case 17: + return const FaIcon(FontAwesomeIcons.snowflake); + default: + return const FaIcon(FontAwesomeIcons.times); + } + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 9f740d4..6232f8d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,6 @@ import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; @@ -8,6 +10,7 @@ import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart'; import 'package:provider/provider.dart'; +import 'package:http/http.dart' as http; import 'Map.dart'; import 'HomePage.dart'; @@ -41,19 +44,65 @@ class MyApp extends StatelessWidget { ); } } -Future loadAllVenues() async{ + +Future loadAllVenues() async { + + Uri venueDataURI = Uri.parse( + 'https://group-4-75.pvt.dsv.su.se/target/weather-0.0.4-SNAPSHOT.war/venue'); + + final response = await http.get(venueDataURI); + + if (response.statusCode == 200) { + var data = json.decode(response.body); + var _allVenuesTemp = []; + + addValidVenues(data, _allVenuesTemp); + + var count = 0; + for (Venue vdata in _allVenuesTemp) { + count++; + //print(count.toString() + ': ' + vdata.toString()); + globals.VENUES.add(vdata); + } + } else { + throw const HttpException("Problem fetching the weather data"); + } +} + +void addValidVenues(data, List _allVenuesTemp) { + for (var i = 0; i < data.values.first.length; i++) { + if (!data.values.first[i]['name'].contains('©') && + !data.values.first[i]['name'].contains('¶') && + !data.values.first[i]['name'].contains('¥') && + !data.values.first[i]['name'].contains('Ã') && + !data.values.first[i]['name'].contains('Â') && + !data.values.first[i]['address'].contains('©') && + !data.values.first[i]['address'].contains('¶') && + !data.values.first[i]['address'].contains('¥') && + !data.values.first[i]['address'].contains('Ã')) { + _allVenuesTemp.add(Venue.fromJson(data.values.first[i], i)); + } else { + continue; + } + } +} + +/* +Future loadAllVenues() async { globals.VENUES = []; var db = mysql(); await db.getConnection().then((conn) async { - String sql = "select venueName, venueID, latitude, longitude from maen0574.venue"; - await conn.query(sql).then((results){ - for(var row in results){ - globals.VENUES.add(Venue(row[0], row[1], VenueType.restaurant, LatLng(row[2], row[3]))); + String sql = + "select venueName, venueID, latitude, longitude from maen0574.venue"; + await conn.query(sql).then((results) { + for (var row in results) { + globals.VENUES.add(Venue( + row[0], row[1], VenueType.restaurant, LatLng(row[2], row[3]))); } }); }); - var sd = ShadowDetector(); - await sd.evaluateShadowsForAllVenues(globals.VENUES); - -} \ No newline at end of file +var sd = ShadowDetector(); +await sd.evaluateShadowsForAllVenues(globals.VENUES); +} +*/ diff --git a/lib/venuePage.dart b/lib/venuePage.dart index 0d7a1a9..dd46be7 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -6,10 +6,11 @@ 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 'WeatherData.dart'; // Color _backgroundColor = const Color(0xffac7b84); -class WeatherData { +/*class WeatherData { final int weatherValue; final int temperature; @@ -144,10 +145,10 @@ class WeatherData { case 17: return const FaIcon(FontAwesomeIcons.snowflake); default: - return const Icon(Icons.not_accessible); + return const FaIcon(FontAwesomeIcons.times); } } -} +}*/ class VenuePage extends StatefulWidget { const VenuePage(this.venue, {Key? key}) : super(key: key); @@ -370,7 +371,7 @@ class SavePlaceButton extends StatelessWidget { ), label: const Text('Save place'), style: TextButton.styleFrom( - primary: Color(0xff4f6272), + primary: const Color(0xff4f6272), ), ), ); -- 2.39.5 From d41908c203e3219200040c1778363f71a74a7712 Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Wed, 25 May 2022 14:03:24 +0200 Subject: [PATCH 2/4] Added functionality for navigation in the app --- lib/Map.dart | 345 ++++++++++++++++++++++++++++------------ lib/ShadowDetector.dart | 2 +- lib/Venue.dart | 6 +- lib/WeatherData.dart | 3 + lib/globals.dart | 3 + lib/main.dart | 71 +++++---- lib/venuePage.dart | 2 + 7 files changed, 292 insertions(+), 140 deletions(-) diff --git a/lib/Map.dart b/lib/Map.dart index 532ecc6..f9a210c 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -1,7 +1,10 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:flutter_applicationdemo/WeatherData.dart'; import 'package:flutter_applicationdemo/WebScraper.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'dart:async'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:flutter_google_places/flutter_google_places.dart'; @@ -12,13 +15,13 @@ import 'package:geolocator/geolocator.dart'; import 'package:flutter_applicationdemo/login/User.dart'; import 'SettingsPage.dart'; +import 'WeatherData.dart'; +import 'venuePage.dart'; import 'Venue.dart'; import 'globals.dart' as globals; - import 'globals.dart' as globals; - class Map extends StatefulWidget { @override State createState() => MapState(); @@ -28,29 +31,27 @@ const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk"; final homeSacffoldKey = GlobalKey(); - class MapState extends State { + bool _bottomSheetIsOpen = false; - Future getMerkerData() async { - var url = Uri.parse('https://openstreetgs.stockholm.se/geoservice/api/b8e20fd7-5654-465e-8976-35b4de902b41/wfs?service=wfs&version=1.1.0&request=GetFeature&typeNames=od_gis:Markupplatelse&srsName=EPSG:4326&outputFormat=json'); +/* Future getMerkerData() async { + var url = Uri.parse( + 'https://openstreetgs.stockholm.se/geoservice/api/b8e20fd7-5654-465e-8976-35b4de902b41/wfs?service=wfs&version=1.1.0&request=GetFeature&typeNames=od_gis:Markupplatelse&srsName=EPSG:4326&outputFormat=json'); var response = await http.get(url); print('Response status: ${response.statusCode}'); - // print('Response body: ${response.body.toString()}'); + // print('Response body: ${response.body.toString()}'); var jsonData = jsonDecode(response.body); - - - - } + }*/ final Completer _controller = Completer(); LocationData? _currentPosition; - final TextEditingController _searchController = TextEditingController(); + final TextEditingController _searchController = TextEditingController(); - static const CameraPosition _kGooglePlex = CameraPosition( - target: LatLng(59.325027,18.068516), + static const CameraPosition _stockholmCity = CameraPosition( + target: LatLng(59.325027, 18.068516), zoom: 14.4746, ); @@ -63,48 +64,48 @@ class MapState extends State { super.initState(); } - void createBottomSheet(String venueName) async { - var webScraper = WebScraper(); - await webScraper.getWebsiteData(venueName); - Scaffold.of(context).showBottomSheet( - ((context) { - return Container( - height: 420, - color: Colors.white, - child: Center( - child: Column( - 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()), - ), - - ], - ) - ), - ); - }) - ); - } - initialize() { List allVenues = globals.VENUES; - for(var venue in allVenues) { + for (var venue in allVenues) { Marker marker = Marker( - markerId: MarkerId(venue.venueID.toString()), - position: venue.position, - onTap: () => createBottomSheet(venue.venueName), - icon: venue.drawIconColor(), - ); + markerId: MarkerId(venue.venueID.toString()), + position: venue.position, + /*infoWindow: InfoWindow( + title: venue.venueName, + snippet: venue.venueAddress, + ),*/ + // onTap: () => createBottomSheet(venue.venueName), + onTap: () => createBottomDrawer(venue), + icon: venue.drawIconColor(), + ); markersList.add(marker); } } + void createBottomSheet(String venueName) async { + var webScraper = WebScraper(); + await webScraper.getWebsiteData(venueName); + Scaffold.of(context).showBottomSheet(((context) { + return Container( + height: 420, + color: Colors.white, + child: Center( + child: Column( + 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()), + ), + ], + )), + ); + })); + } Future _getLocationPermission() async { Location location = Location(); @@ -145,9 +146,10 @@ class MapState extends State { final Mode _mode = Mode.fullscreen; int currentIndex = 0; - final screens =[ + final screens = [ Map(), ]; + @override Widget build(BuildContext context) { return Scaffold( @@ -155,8 +157,10 @@ class MapState extends State { key: homeSacffoldKey, //leading: IconButton(icon: Icon(Icons.search), onPressed:() {},), actions: [ - IconButton(icon: const Icon(Icons.search), onPressed:() { - },), + IconButton( + icon: const Icon(Icons.search), + onPressed: () {}, + ), ], title: TextFormField( controller: _searchController, @@ -168,78 +172,79 @@ class MapState extends State { ), backgroundColor: const Color.fromARGB(255, 190, 146, 160), ), - body: Stack ( + body: Stack( children: [ GoogleMap( mapType: MapType.normal, - initialCameraPosition: _kGooglePlex, + myLocationEnabled: true, + initialCameraPosition: _stockholmCity, markers: markersList.map((e) => e).toSet(), onMapCreated: (GoogleMapController controller) { - _controller.complete(controller); - }, + _controller.complete(controller); + }, + onTap: (LatLng) { + closeBottomSheetIfOpen(); + }, ), - // ElevatedButton(onPressed: () {} //_handelPressButton - // ,child: const Text("Search Placses")) + // ElevatedButton(onPressed: () {} //_handelPressButton + // ,child: const Text("Search Placses")) ], ), - - floatingActionButton: Padding( - padding: const EdgeInsets.only(top: 100.0), - child: FloatingActionButton( + floatingActionButton: Padding( + padding: const EdgeInsets.only(top: 100.0), + child: FloatingActionButton( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const SettingsPage())); + Navigator.push(context, + MaterialPageRoute(builder: (context) => const SettingsPage())); }, - backgroundColor: Colors.purple, - child: const Icon(Icons.filter_alt), - ), - ), - floatingActionButtonLocation: FloatingActionButtonLocation.endTop, - ); - } - + backgroundColor: Colors.purple, + child: const Icon(Icons.filter_alt), + ), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.endTop, + ); + } Future _gotoLocation(double lat, double lng) async { final GoogleMapController controller = await _controller.future; - controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(target: LatLng(lat,lng), zoom: 15))); + controller.animateCamera(CameraUpdate.newCameraPosition( + CameraPosition(target: LatLng(lat, lng), zoom: 15))); } Widget _boxes(double lat, double lng, String resturantName) { return GestureDetector( - onTap: () { _gotoLocation(lat, lng);}, + 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: const Image( - image: AssetImage('assets/images/bild.png') - ), - ), + 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: + 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(resturantName), + ), + ) + ], + ), ), + )), ); } @@ -252,7 +257,140 @@ class MapState extends State { zoom: 14.4746))); } - /* Future _handelPressButton() 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; + Scaffold.of(context).showBottomSheet(((context) { + return InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => VenuePage(venue)), + ); + }, + child: Container( + height: 250, + 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:'), + ], + ) + ], + ), + ) + ], + ), + ), + ), + ); + })); + } + + Column columnHandlingCloseButton(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + child: const Text('Close'), + onPressed: () { + Navigator.pop(context); + _bottomSheetIsOpen = false; + }), + ], + ), + ), + ], + ); + } + + Column columnCoveringRating() { + return Column( + children: [ + Text( + 'Rating', + style: GoogleFonts.robotoCondensed( + textStyle: const TextStyle( + color: Colors.black87, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ); + } + + Column columnCoveringNameAndAddress(Venue venue) { + return Column( + children: [ + Text( + venue.venueName, + style: GoogleFonts.roboto( + textStyle: const TextStyle( + color: Colors.black87, + fontWeight: FontWeight.bold, + fontSize: 24, + )), + ), + Text( + venue.venueAddress + ' ' + venue.venueStreetNo, + style: GoogleFonts.roboto( + textStyle: const TextStyle( + color: Colors.black, + fontWeight: FontWeight.w200, + fontSize: 18, + )), + ) + ], + ); + } + + closeBottomSheetIfOpen() { + print(_bottomSheetIsOpen); + if (_bottomSheetIsOpen) { + Navigator.pop(context); + } + } + +/* Future _handelPressButton() async { Prediction? p = await PlacesAutocomplete.show( context: context, @@ -291,4 +429,3 @@ class MapState extends State { googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0)); }*/ } - diff --git a/lib/ShadowDetector.dart b/lib/ShadowDetector.dart index 4ab54b0..18894ee 100644 --- a/lib/ShadowDetector.dart +++ b/lib/ShadowDetector.dart @@ -37,7 +37,7 @@ class ShadowDetector { List get listWithVenuesInShade => venuesInShade; //Get all venues with their shadow status updated. - void evaluateShadowsForOneVenue (Venue venue) async { + Future evaluateShadowsForOneVenue (Venue venue) async { LatLng pos= venue.position; final lat = pos.latitude.toString(); final lng = pos.longitude.toString(); diff --git a/lib/Venue.dart b/lib/Venue.dart index 368d761..f316da3 100644 --- a/lib/Venue.dart +++ b/lib/Venue.dart @@ -25,12 +25,12 @@ class Venue { LatLng tempPosition = LatLng(double.parse(splitArr[1]), double.parse(splitArr[0])); - print(splitArr[0].toString() + ' : ' + splitArr[1].toString()); +/* print(splitArr[0].toString() + ' : ' + splitArr[1].toString()); print('Coordinates: ' + tempCoordinates); print('Parsed: ' + double.parse(splitArr[0]).toString()); print(LatLng(double.parse(splitArr[1]), double.parse(splitArr[0]))); print(tempAddress + tempName); - print(tempPosition.latitude.toString() + " " + splitArr[0]); + print(tempPosition.latitude.toString() + " " + splitArr[0]);*/ // print('Json-Object:'); // print(json); @@ -91,7 +91,7 @@ class Venue { String toString() { return 'ID: ' + venueID.toString() + - ' ' + + ', ' + 'name: ' + venueName + ', ' + diff --git a/lib/WeatherData.dart b/lib/WeatherData.dart index 83ae1f0..f25d511 100644 --- a/lib/WeatherData.dart +++ b/lib/WeatherData.dart @@ -140,4 +140,7 @@ class WeatherData { return const FaIcon(FontAwesomeIcons.times); } } + + + } \ No newline at end of file diff --git a/lib/globals.dart b/lib/globals.dart index 7e1bf16..89d0250 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1,3 +1,5 @@ +import 'package:flutter_applicationdemo/WeatherData.dart'; + import 'Venue.dart'; import 'package:flutter_applicationdemo/login/User.dart'; import '../login/User.dart'; @@ -19,6 +21,7 @@ Color TEXTCOLOR = const Color.fromARGB(255, 79, 98, 114); Color SHADOWCOLOR = const Color.fromARGB(255, 0, 0, 0); Color TEXTWHITE = const Color.fromARGB(0, 0, 0, 0); late List VENUES = []; +late WeatherData forecast; Venue? getVenueByID(int searchedVenueID){ for(var V in VENUES){ diff --git a/lib/main.dart b/lib/main.dart index 6232f8d..9e44a0f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,6 +13,7 @@ import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; import 'Map.dart'; +import 'WeatherData.dart'; import 'HomePage.dart'; import 'Venue.dart'; import 'mysql.dart'; @@ -24,10 +25,29 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); await loadAllVenues(); + await fetchWeather(); runApp(MyApp()); } +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'); + + final response = await http.get(weatherDataURI); + + if (response.statusCode == 200) { + var data = json.decode(response.body); + tempWeather = WeatherData.fromJson(data); + print(data); + + globals.forecast = tempWeather; + } else { + throw const HttpException("Problem fetching the weather data"); + } +} + class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { @@ -46,32 +66,39 @@ 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'); final response = await http.get(venueDataURI); if (response.statusCode == 200) { - var data = json.decode(response.body); - var _allVenuesTemp = []; + addVenues(response); - addValidVenues(data, _allVenuesTemp); - - var count = 0; - for (Venue vdata in _allVenuesTemp) { - count++; - //print(count.toString() + ': ' + vdata.toString()); - globals.VENUES.add(vdata); - } + // var sd = ShadowDetector(); + // await sd.evaluateShadowsForAllVenues(seventyFiveVenues); } else { throw const HttpException("Problem fetching the weather data"); } } +void addVenues(http.Response response) { + var data = json.decode(response.body); + var _allVenuesTemp = []; + + addValidVenues(data, _allVenuesTemp); + + for (Venue venue in _allVenuesTemp) { + globals.VENUES.add(venue); + } +} + void addValidVenues(data, List _allVenuesTemp) { for (var i = 0; i < data.values.first.length; i++) { - if (!data.values.first[i]['name'].contains('©') && + if (data.values.first[i]['name'] == null) { + continue; + } else if (data.values.first[i]['address'].contains('null')) { + continue; + } else if (!data.values.first[i]['name'].contains('©') && !data.values.first[i]['name'].contains('¶') && !data.values.first[i]['name'].contains('¥') && !data.values.first[i]['name'].contains('Ã') && @@ -86,23 +113,3 @@ void addValidVenues(data, List _allVenuesTemp) { } } } - -/* -Future loadAllVenues() async { - globals.VENUES = []; - var db = mysql(); - await db.getConnection().then((conn) async { - String sql = - "select venueName, venueID, latitude, longitude from maen0574.venue"; - await conn.query(sql).then((results) { - for (var row in results) { - globals.VENUES.add(Venue( - row[0], row[1], VenueType.restaurant, LatLng(row[2], row[3]))); - } - }); - }); - -var sd = ShadowDetector(); -await sd.evaluateShadowsForAllVenues(globals.VENUES); -} -*/ diff --git a/lib/venuePage.dart b/lib/venuePage.dart index dd46be7..acc8d1f 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -165,6 +165,8 @@ class _VenuePageState extends State { _VenuePageState(this.venue); + + validateAndGetImageLink() { if (imageLink == '') { return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg'; -- 2.39.5 From 0c0600c493224ad1e4bd32c267ef904b98b3eaa8 Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Thu, 26 May 2022 10:39:45 +0200 Subject: [PATCH 3/4] Added list view --- lib/ListViewPage.dart | 88 ++++++++++++++++ lib/Map.dart | 15 ++- lib/WeatherData.dart | 4 +- lib/globals.dart | 1 - lib/venuePage.dart | 239 ++++++++---------------------------------- 5 files changed, 149 insertions(+), 198 deletions(-) create mode 100644 lib/ListViewPage.dart diff --git a/lib/ListViewPage.dart b/lib/ListViewPage.dart new file mode 100644 index 0000000..10195fa --- /dev/null +++ b/lib/ListViewPage.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import 'globals.dart' as globals; +import 'package:flutter_applicationdemo/Venue.dart'; +import 'VenuePage.dart'; + +class ListViewPage extends StatefulWidget { + const ListViewPage({Key? key}) : super(key: key); + + @override + State createState() => _ListViewPageState(); +} + +class _ListViewPageState extends State { + final List allVenues = globals.VENUES; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Venues near you',), + backgroundColor: globals.BACKGROUNDCOLOR, + ), + body: buildListView(), + ); + } + + ListView buildListView() { + return ListView.builder( + padding: const EdgeInsets.all(8), + itemCount: allVenues.length, + itemBuilder: (context, index) { + return ListTile( + shape: buildBorder(), + onTap: () => _navigateToVenue(allVenues[index]), + leading: buildIconBox(index, context), + title: buildTitleText(index), + subtitle: buildWeatherRow(), + + trailing: const Text('400m'), + ); + }, + ); + } + + RoundedRectangleBorder buildBorder() { + return RoundedRectangleBorder( + 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), + ); + } + + Row buildWeatherRow() { + return Row( + 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), + )), + ); + } + + void _navigateToVenue(Venue venue) { + Navigator.of(context) + .push(MaterialPageRoute(builder: (context) => VenuePage(venue))); + } +} diff --git a/lib/Map.dart b/lib/Map.dart index f9a210c..7f9a9ea 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:flutter_applicationdemo/ListViewPage.dart'; import 'package:flutter_applicationdemo/WeatherData.dart'; import 'package:flutter_applicationdemo/WebScraper.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -300,7 +301,8 @@ class MapState extends State { ), Row( children: [ - Text('– ' + globals.forecast.getCurrentWeatherStatus()), + Text('– ' + + globals.forecast.getCurrentWeatherStatus()), ], ), Row( @@ -334,6 +336,15 @@ class MapState extends State { Navigator.pop(context); _bottomSheetIsOpen = false; }), + ElevatedButton( + child: const Text('ListView'), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ListViewPage())); + }, + ), ], ), ), @@ -375,7 +386,7 @@ class MapState extends State { style: GoogleFonts.roboto( textStyle: const TextStyle( color: Colors.black, - fontWeight: FontWeight.w200, + fontWeight: FontWeight.w300, fontSize: 18, )), ) diff --git a/lib/WeatherData.dart b/lib/WeatherData.dart index f25d511..b555fe8 100644 --- a/lib/WeatherData.dart +++ b/lib/WeatherData.dart @@ -99,12 +99,12 @@ class WeatherData { case 1: return const Icon( Icons.sunny, - color: Color.fromARGB(255, 251, 183, 9), + color: Color.fromARGB(255, 255, 161, 19), ); case 2: return const Icon( Icons.sunny, - color: Color.fromARGB(255, 251, 183, 9), + color: Color.fromARGB(255, 255, 161, 19), ); case 3: return const FaIcon(FontAwesomeIcons.cloudSun); diff --git a/lib/globals.dart b/lib/globals.dart index 89d0250..0790a73 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; import 'HomePage.dart'; import 'Venue.dart'; -import 'Venue.dart'; import 'main.dart'; User LOGGED_IN_USER = User(0, "", ""); diff --git a/lib/venuePage.dart b/lib/venuePage.dart index acc8d1f..b3e769e 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -7,148 +7,8 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'WeatherData.dart'; +import 'globals.dart' as globals; -// Color _backgroundColor = const Color(0xffac7b84); - -/*class WeatherData { - final int weatherValue; - final int temperature; - - WeatherData(this.weatherValue, this.temperature); - - factory WeatherData.fromJson(Map json) { - var value = json.values; - var tempWeatherData; - var tempTemperature; - - if (value.first['wsymb2'] is int) { - tempWeatherData = value.first['wsymb2']; - } - if (value.first['temp'] is double) { - tempTemperature = value.first['temp']; - } - - if (tempWeatherData != null && tempTemperature != null) { - return WeatherData(tempWeatherData, tempTemperature.round()); - } else { - return WeatherData(0, 0); - } - } - - int getCurrentTemperature() { - return temperature; - } - - String getCurrentWeatherStatus() { - String weatherStatus; - switch (weatherValue) { - case 0: - weatherStatus = 'Undefined'; - break; - case 1: - weatherStatus = 'Clear sky'; - break; - case 2: - weatherStatus = 'Nearly clear sky'; - break; - case 3: - weatherStatus = 'Variable cloudiness'; - break; - case 4: - weatherStatus = 'Halfclear sky'; - break; - case 5: - weatherStatus = 'Cloudy sky'; - break; - case 6: - weatherStatus = 'Overcast'; - break; - case 7: - weatherStatus = 'Fog'; - break; - case 8: - weatherStatus = 'Light rain showers'; - break; - case 9: - weatherStatus = 'Moderate rain showers'; - break; - case 10: - weatherStatus = 'Heavy rain showers'; - break; - case 11: - weatherStatus = 'Thunderstorm'; - break; - case 12: - weatherStatus = 'Light sleet showers'; - break; - case 13: - weatherStatus = 'Moderate sleet showers'; - break; - case 14: - weatherStatus = 'Heavy sleet showers'; - break; - case 15: - weatherStatus = 'Light snow showers'; - break; - case 16: - weatherStatus = 'Moderate snow showers'; - break; - case 17: - weatherStatus = 'Heavy snow showers'; - break; - default: - weatherStatus = 'Undefined'; - } - return weatherStatus; - } - - Widget getCurrentWeatherIcon() { - switch (weatherValue) { - case 1: - return const Icon( - Icons.sunny, - color: Color.fromARGB(255, 251, 183, 9), - ); - case 2: - return const Icon( - Icons.sunny, - color: Color.fromARGB(255, 251, 183, 9), - ); - case 3: - return const FaIcon(FontAwesomeIcons.cloudSun); - case 4: - return const FaIcon(FontAwesomeIcons.cloudSun); - case 5: - return const FaIcon(FontAwesomeIcons.cloud); - case 6: - return const FaIcon(FontAwesomeIcons.cloud); - case 7: - return const FaIcon(FontAwesomeIcons.smog); - case 8: - return const FaIcon(FontAwesomeIcons.umbrella); - case 9: - return const FaIcon(FontAwesomeIcons.cloudRain); - case 10: - return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); - case 11: - return const FaIcon(FontAwesomeIcons.cloudflare); - case 12: - return const FaIcon(FontAwesomeIcons.cloudRain); - case 13: - return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); - case 14: - return const FaIcon(FontAwesomeIcons.cloudShowersHeavy); - case 15: - return const FaIcon(FontAwesomeIcons.snowflake); - case 16: - return const FaIcon(FontAwesomeIcons.snowflake); - case 17: - return const FaIcon(FontAwesomeIcons.snowflake); - default: - return const FaIcon(FontAwesomeIcons.times); - } - } -}*/ class VenuePage extends StatefulWidget { const VenuePage(this.venue, {Key? key}) : super(key: key); @@ -185,17 +45,16 @@ class _VenuePageState extends State { currentWeather = tempWeather; 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/weather-0.0.4-SNAPSHOT.war/weather'); - final responce = await http.get(weatherDataURI); + final response = await http.get(weatherDataURI); - if (responce.statusCode == 200) { - var data = json.decode(responce.body); + if (response.statusCode == 200) { + var data = json.decode(response.body); tempWeather = WeatherData.fromJson(data); - print(data); - setState(() { + globals.forecast = tempWeather; currentWeather = tempWeather; //Could be a widget instead?? }); } else { @@ -237,8 +96,13 @@ class _VenuePageState extends State { Expanded( child: Column( children: [ - Text(venue.venueName), - Text('This is the address'), + Text(venue.venueName, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ) + ), + Text(venue.venueAddress + ' ' + venue.venueStreetNo), ], )), Expanded( @@ -247,34 +111,7 @@ class _VenuePageState extends State { // border: Border.all(color: const Color(0xffaaaaaa)), // ), // color: const Color(0xffe9e9e9), - child: Column( - 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: [ - Column( - children: [ - currentWeather.getCurrentWeatherIcon(), - Text(currentWeather.getCurrentWeatherStatus()), - ], - ), - Text(currentWeather - .getCurrentTemperature() - .toString() + - '\u2103'), - ]), - ], - ), + child: buildWeatherColumn(), ), ) ]), @@ -288,6 +125,37 @@ class _VenuePageState extends State { ), )); } + + Column buildWeatherColumn() { + return Column( + 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: [ + Column( + children: [ + currentWeather.getCurrentWeatherIcon(), + Text(currentWeather.getCurrentWeatherStatus()), + ], + ), + Text(currentWeather + .getCurrentTemperature() + .toString() + + '\u2103'), + ]), + ), + ], + ); + } } //Just an example table @@ -340,22 +208,7 @@ class AboutTheSpotTable extends StatelessWidget { } } -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// backgroundColor: const Color(0xfffceff9), -// appBar: AppBar( -// title: const Text('My Venue'), -// backgroundColor: _backgroundColor, -// ), -// body: Row( -// children: const [ -// ShareButton(), -// SavePlaceButton(), -// ], -// )); -// } -// } + class SavePlaceButton extends StatelessWidget { const SavePlaceButton({ -- 2.39.5 From 9f359b944e96835c3fd626a3fcbe04561e155a0f Mon Sep 17 00:00:00 2001 From: Adam Sundberg Date: Thu, 26 May 2022 11:21:45 +0200 Subject: [PATCH 4/4] Fixes for conflicts --- lib/Map.dart | 249 +++++++++++++++++++++++++-------------------------- 1 file changed, 124 insertions(+), 125 deletions(-) diff --git a/lib/Map.dart b/lib/Map.dart index 9873938..1e14063 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -27,14 +27,13 @@ import 'globals.dart' as globals; import 'package:syncfusion_flutter_sliders/sliders.dart'; import 'globals.dart' as globals; -======= +import 'HomePage.dart'; import 'SettingsPage.dart'; import 'Venue.dart'; import 'globals.dart' as globals; import 'FeedbackPage.dart'; import 'login/CreateAccountPage.dart'; import 'login/signInPage.dart'; ->>>>>>> master class Map extends StatefulWidget { @override @@ -175,26 +174,24 @@ class MapState extends State { title: const Text("Sun chasers"), key: homeSacffoldKey, //leading: IconButton(icon: Icon(Icons.search), onPressed:() {},), - actions: [ + /*actions: [ IconButton( icon: const Icon(Icons.search), onPressed: () {}, ), - ], - title: TextFormField( + ],*/ + /*title: TextFormField( controller: _searchController, textCapitalization: TextCapitalization.words, decoration: const InputDecoration(hintText: 'Find your place'), onChanged: (value) { print(value); }, - ), -<<<<<<< HEAD + ),*/ actions: [createFilterMenuButton()], backgroundColor: const Color.fromARGB(255, 190, 146, 160), ), - body: Stack( -======= + /*body: Stack( backgroundColor: const Color.fromARGB(255, 190, 146, 160), ), body: Stack( @@ -202,10 +199,9 @@ class MapState extends State { child: Container( child: globals.LOGGED_IN_USER.userID == 0 ? buildDrawerSignedOut(context) : buildDrawerSignedIn(context), ), - ), + ),*/ - body: Stack ( ->>>>>>> master + body: Stack( children: [ GoogleMap( mapType: MapType.normal, @@ -226,10 +222,18 @@ class MapState extends State { floatingActionButton: Padding( padding: const EdgeInsets.only(top: 100.0), child: FloatingActionButton( + onPressed: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => const SettingsPage())); + }, + backgroundColor: Colors.purple, + child: const Icon(Icons.filter_alt), + ), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.endTop, ); } -<<<<<<< HEAD PopupMenuButton createFilterMenuButton() { return PopupMenuButton( icon: Icon(Icons.filter_list), @@ -250,10 +254,9 @@ class MapState extends State { child: ButtonBar( alignment: MainAxisAlignment.center, children: [ - ElevatedButton( - onPressed: - null, // TODO: Fixa så att kartan filtreras när man klickar på 'Apply Filters' + onPressed: null, + // TODO: Fixa så att kartan filtreras när man klickar på 'Apply Filters' child: Text( "Apply Filters", style: TextStyle(color: Colors.black), @@ -270,72 +273,76 @@ class MapState extends State { // Creates the checkboxes for the filter menu PopupMenuItem createCheckBoxes() { return PopupMenuItem( - child: Padding( - padding: const EdgeInsets.all(8), - child: Expanded( - child: Column( - - children: [ - Divider(color: Colors.black,), - 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, - )); - }), - StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return CheckboxListTile( - value: _restaurantFilterValue, - onChanged: (bool? newValue) { - setState(() { - _restaurantFilterValue = newValue; - }); - }, - title: Icon( - Icons.restaurant, - color: Colors.blueGrey[200], + child: Padding( + padding: const EdgeInsets.all(8), + child: Expanded( + child: Column( + children: [ + Divider( + color: Colors.black, ), - ); - }), - //Cafe checkbox + 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, + )); + }), + StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + 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], - )); - }), + StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return CheckboxListTile( + value: _cafeFilterValue, + onChanged: (bool? newValue) { + setState(() => _cafeFilterValue = newValue); + }, + title: Icon( + Icons.coffee, + color: Colors.brown[400], + )); + }), + ], - ], -======= - floatingActionButton: Padding( - padding: const EdgeInsets.only(top: 100.0), - child: FloatingActionButton( - onPressed: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => const SettingsPage())); - }, - backgroundColor: Colors.purple, - child: const Icon(Icons.filter_alt), - ), - ), - floatingActionButtonLocation: FloatingActionButtonLocation.endTop, - ); + /*floatingActionButton: Padding( + padding: const EdgeInsets.only(top: 100.0), + child: FloatingActionButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsPage())); + }, + backgroundColor: Colors.purple, + child: const Icon(Icons.filter_alt), + ), + ), + floatingActionButtonLocation: FloatingActionButtonLocation + .endTop,*/ + ), + ))); } PopupMenuItem createPriceSlider() { @@ -502,10 +509,8 @@ class MapState extends State { ElevatedButton( child: const Text('ListView'), onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ListViewPage())); + Navigator.push(context, + MaterialPageRoute(builder: (context) => ListViewPage())); }, ), ], @@ -603,45 +608,43 @@ class MapState extends State { googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0)); }*/ } -<<<<<<< HEAD -======= -Widget buildDrawerSignedIn(BuildContext context){ +Widget buildDrawerSignedIn(BuildContext context) { return Drawer( child: ListView( padding: EdgeInsets.zero, children: [ DrawerHeader( - decoration: const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), - child: Column(children: const [ - Text('Sun Chaser', - style :TextStyle(fontSize: 32), - ), - - SizedBox(height: 30), - Icon(Icons.account_box_rounded), - - ], - + decoration: + const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), + child: Column( + children: const [ + Text( + 'Sun Chaser', + style: TextStyle(fontSize: 32), + ), + SizedBox(height: 30), + Icon(Icons.account_box_rounded), + ], ), - ), - ListTile( leading: Icon(Icons.logout), title: Text('Sign out'), - onTap:(){ + onTap: () { globals.LOGGED_IN_USER = User(0, "", ""); Navigator.push( context, - MaterialPageRoute(builder: (context) => HomePage()), //Replace Container() with call to Map-page. + MaterialPageRoute( + builder: (context) => + HomePage()), //Replace Container() with call to Map-page. ); }, ), ListTile( leading: Icon(Icons.thumb_up_alt), title: Text('Give feedback'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( @@ -649,12 +652,11 @@ Widget buildDrawerSignedIn(BuildContext context){ ), ); }, - ), ListTile( leading: Icon(Icons.settings), title: Text('Settings'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( @@ -663,33 +665,33 @@ Widget buildDrawerSignedIn(BuildContext context){ ); }, ), - ], ), ); } -Widget buildDrawerSignedOut(BuildContext context){ +Widget buildDrawerSignedOut(BuildContext context) { return Drawer( child: ListView( padding: EdgeInsets.zero, children: [ DrawerHeader( - decoration: const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), - child: Column(children: const [ - Text('Sun Chaser', - style :TextStyle(fontSize: 32), - ), - - SizedBox(height: 30), - ], + decoration: + const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)), + child: Column( + children: const [ + Text( + 'Sun Chaser', + style: TextStyle(fontSize: 32), + ), + SizedBox(height: 30), + ], ), ), - ListTile( leading: Icon(Icons.account_box_rounded), title: Text('Create account'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( @@ -697,22 +699,23 @@ Widget buildDrawerSignedOut(BuildContext context){ ), ); }, - ), + ), ListTile( leading: Icon(Icons.login), title: Text('Sign in'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => SignInPage(), ), ); - },), + }, + ), ListTile( leading: Icon(Icons.thumb_up_alt), title: Text('Give feedback'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( @@ -724,7 +727,7 @@ Widget buildDrawerSignedOut(BuildContext context){ ListTile( leading: Icon(Icons.settings), title: Text('Settings'), - onTap:(){ + onTap: () { Navigator.push( context, MaterialPageRoute( @@ -738,14 +741,10 @@ Widget buildDrawerSignedOut(BuildContext context){ ); } - class _Marker { - var Plats_1; var Gatunr_1; var coordinates; _Marker(this.Plats_1, this.Gatunr_1, this.coordinates); - } ->>>>>>> master -- 2.39.5