From 2b6e2bb4ad7eb9dd569e6f081e7e797bbdda8bba Mon Sep 17 00:00:00 2001 From: shas6395 Date: Mon, 30 May 2022 13:42:12 +0200 Subject: [PATCH 1/4] HomePage and Globals updated --- lib/HomePage.dart | 49 +++++++++++------------------------------------ lib/globals.dart | 1 + 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/lib/HomePage.dart b/lib/HomePage.dart index 9830dd4..b3d2fb7 100644 --- a/lib/HomePage.dart +++ b/lib/HomePage.dart @@ -32,31 +32,23 @@ class _HomePageState extends State { padding: EdgeInsets.fromLTRB(80, 80, 80, 0), child: Text( 'Sun Chasers', - style: GoogleFonts.libreBaskerville( - fontSize: 35, + style: GoogleFonts.roboto( + fontSize: 52, color: globals.TEXTCOLOR, ), + textAlign: TextAlign.center, ), ), const SizedBox(height: 10), - - Text( - 'The #1 Sunny Spot Finder', - style: GoogleFonts.libreBaskerville( - fontSize: 20, - fontWeight: FontWeight. bold, - color: globals.TEXTCOLOR, - ), - ), Container( - padding: EdgeInsets.fromLTRB(80, 40, 80, 80), + margin: EdgeInsets.fromLTRB(80, 80, 80, 80), child: ElevatedButton( style: ElevatedButton.styleFrom( fixedSize: const Size(200, 200), primary: globals.BUTTONCOLOR, - elevation: 100, + elevation: globals.elevation, shape: const CircleBorder(), ), onPressed: () { @@ -66,19 +58,12 @@ class _HomePageState extends State { ); }, child: Text( - (globals.LOGGED_IN_USER.userID == 0 ? 'FIND SPOT BY LOCATION \n \n without signing in' : 'FIND SPOT BY LOCATION'), + (globals.LOGGED_IN_USER.userID == 0 ? '\nFIND SPOT BY LOCATION \n \n as guest' : 'FIND SPOT BY LOCATION'), textAlign: TextAlign.center, style: TextStyle( fontSize: 18, color: Colors.white, - shadows: [ - Shadow( - offset: Offset(2, 2), - blurRadius: 10.0, - color: globals.SHADOWCOLOR, - ), - ] ), ), ), @@ -100,7 +85,7 @@ class _HomePageState extends State { style: ElevatedButton.styleFrom( fixedSize: const Size(200, 50), primary: globals.BUTTONCOLOR, - elevation: 100, + elevation: globals.elevation, ), onPressed: () { Navigator.push( @@ -112,13 +97,7 @@ class _HomePageState extends State { style: TextStyle( fontSize: 18, color: Colors.white, - shadows: [ - Shadow( - offset: Offset(2, 2), - blurRadius: 10.0, - color: globals.SHADOWCOLOR, - ), - ]) + ) ), ), Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5)), @@ -126,7 +105,7 @@ class _HomePageState extends State { style: ElevatedButton.styleFrom( fixedSize: const Size(200, 50), primary: globals.BUTTONCOLOR, - elevation: 100, + elevation: globals.elevation, ), onPressed: () { Navigator.push( @@ -138,13 +117,7 @@ class _HomePageState extends State { style: TextStyle( fontSize: 18, color: Colors.white, - shadows: [ - Shadow( - offset: Offset(2, 2), - blurRadius: 10.0, - color: Color.fromARGB(255, 0, 0, 0), - ), - ]) + ) ), ) ] @@ -157,7 +130,7 @@ class _HomePageState extends State { style: ElevatedButton.styleFrom( fixedSize: const Size(200, 50), primary: globals.BUTTONCOLOR, - elevation: 100, + elevation: globals.elevation, ), onPressed: () { globals.LOGGED_IN_USER = User.User(0, "", ""); diff --git a/lib/globals.dart b/lib/globals.dart index 0790a73..b800077 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -19,6 +19,7 @@ Color PINKBACKGROUND = const Color.fromARGB(255, 240, 229, 229); 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); +const double elevation = 5; late List VENUES = []; late WeatherData forecast; -- 2.39.5 From 5c428f84531d4cd4fe00da397068a8a4067faa38 Mon Sep 17 00:00:00 2001 From: shas6395 Date: Mon, 30 May 2022 14:05:48 +0200 Subject: [PATCH 2/4] HomePage and Globals updated --- lib/main.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 836f655..9053067 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,8 +24,8 @@ import 'globals.dart' as globals; void main() async { WidgetsFlutterBinding.ensureInitialized(); // await Firebase.initializeApp(); - //await loadAllVenues(); - //await fetchWeather(); + 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); -- 2.39.5 From defc4826116d100538ee08a59f9254151c6be4cb Mon Sep 17 00:00:00 2001 From: shas6395 Date: Mon, 30 May 2022 18:04:05 +0200 Subject: [PATCH 3/4] Final version? --- lib/Map.dart | 23 +++++++++-------- lib/VenueInfo.dart | 63 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/lib/Map.dart b/lib/Map.dart index 209bfae..1ce02b2 100644 --- a/lib/Map.dart +++ b/lib/Map.dart @@ -454,20 +454,21 @@ class MapState extends State { ], ), // columnCoveringRating(), + + ], + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ Column( children: const [ weatherIconRow(), weatherStatusRow(), ], ), - ], - ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ columnHandlingReadMoreButton(context, venue), ], ) @@ -497,7 +498,7 @@ class MapState extends State { return ElevatedButton( child: const Text( 'Read More', - style: TextStyle(fontSize: 18), + style: TextStyle(fontSize: 16), ), onPressed: () { Navigator.push( @@ -519,7 +520,7 @@ class MapState extends State { textStyle: const TextStyle( color: Colors.black87, fontWeight: FontWeight.bold, - fontSize: 26, + fontSize: 20, )), ), Text( @@ -528,7 +529,7 @@ class MapState extends State { textStyle: const TextStyle( color: Colors.black, fontWeight: FontWeight.w300, - fontSize: 20, + fontSize: 14, )), ) ], diff --git a/lib/VenueInfo.dart b/lib/VenueInfo.dart index 38bf11e..23db92c 100644 --- a/lib/VenueInfo.dart +++ b/lib/VenueInfo.dart @@ -2,13 +2,14 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:html/dom.dart' as dom; +import 'package:intl/intl.dart'; import 'dart:io'; import 'Venue.dart'; class VenueInfo { - static const photoSize = 'original'; //Can be replaced with custom size (Example Format: '300x400') + static const photoSize = '600x400'; //Can be replaced with custom size (Example Format: '300x400') late String _photo = 'https://www.bing.com/th?id=OIP.ZSXrQuieNC-hoPC4kIv_vgAAAA&w=212&h=212&c=8&rs=1&qlt=90&o=6&dpr=1.35&pid=3.1&rm=2'; late int _priceClass = -1; late double _rating = -1; @@ -17,6 +18,7 @@ class VenueInfo { late String _openHoursToday = 'N/A'; late String _fsqLink; late double _popularity = -1; + late List _hoursPopular = []; VenueInfo(); @@ -36,7 +38,7 @@ class VenueInfo { if(results.isNotEmpty && data['results'][0]['link'] != null) { _fsqLink = data['results'][0]['link']; final response2 = await http.get( - Uri.parse('https://api.foursquare.com$_fsqLink?fields=price%2Crating%2Cphotos%2Chours%2Cstats%2Cpopularity'), + Uri.parse('https://api.foursquare.com$_fsqLink?fields=price%2Crating%2Cphotos%2Chours%2Cstats%2Cpopularity%2Chours_popular'), headers: { HttpHeaders.authorizationHeader: 'fsq3LBbeZ8imQK8X1hov7DTb9F64Xs1fs2bojHQ99QNm4TE=', } @@ -51,6 +53,8 @@ class VenueInfo { data['popularity'] != null ? _popularity = data['popularity']: null; data['photos'][0]['prefix'] != null && data['photos'][0]['suffix'] != null ? _photo = data['photos'][0]['prefix'] + photoSize + data['photos'][0]['suffix']: null; + _hoursPopular = data['hours_popular'] != null ? _hoursPopular = data['hours_popular']: null; + } else { throw const HttpException("No connection to api.foursquare.com"); @@ -110,6 +114,46 @@ class VenueInfo { } }*/ + + String getPopularHoursToday() { + var today = DateFormat('EEEE').format(DateTime.now()); + if(_hoursPopular.isEmpty) { + return 'N/A'; + } + if(today == 'Monday') { + return findPopularHours(1); + } + if(today == 'Tuesday') { + return findPopularHours(2); + } + if(today == 'Wednesday') { + return findPopularHours(3); + } + if(today == 'Thursday') { + return findPopularHours(4); + } + if(today == 'Friday') { + return findPopularHours(5); + } + if(today == 'Saturday') { + return findPopularHours(6); + } + if(today == 'Sunday') { + return findPopularHours(7); + } + return 'N/A'; + } + + String findPopularHours(int dayNumber) { + String toReturn = ''; + for(var h in _hoursPopular) { + if(h['day'] == dayNumber) { + toReturn += (h['open'] + '-' + h['close'] + '\n'); + } + } + return toReturn; + } + String getRating() { return _rating != -1 ? _rating.toString() + '/10': 'N/A'; } @@ -119,7 +163,7 @@ class VenueInfo { } String getOpenStatus() { - return _openNow ? 'Open now!': 'Closed'; + return _openNow ? 'Yes': 'No'; } String getOpeningHours() { @@ -145,4 +189,17 @@ class VenueInfo { String getVenueURL () { return 'https://api.foursquare.com$_fsqLink'; } + +} + + +enum WeekDays { + monday, + tuesday, + wednesday, + thursday, + friday, + saturday, + sunday, + } \ No newline at end of file -- 2.39.5 From 739bb5fc6e25b4942d9031c8b614bfde22a0430d Mon Sep 17 00:00:00 2001 From: shas6395 Date: Mon, 30 May 2022 18:21:43 +0200 Subject: [PATCH 4/4] Final version? --- lib/venuePage.dart | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/venuePage.dart b/lib/venuePage.dart index 3a581be..9609049 100644 --- a/lib/venuePage.dart +++ b/lib/venuePage.dart @@ -191,14 +191,19 @@ class _AboutTheSpotTableState extends State { label: Text('About the spot', style: GoogleFonts.roboto( textStyle: const TextStyle( - fontSize: 18, + fontSize: 14, + fontWeight: FontWeight.bold, )))), const DataColumn(label: Text('', style: TextStyle())), ], rows: [ - const DataRow(cells: [ - DataCell(Text('Type of venue')), - DataCell(Text('Restaurant')), + DataRow(cells: [ + DataCell(Text('Open?')), + DataCell(Text(widget.venueInfo.getOpenStatus())), + ]), + DataRow(cells: [ + DataCell(Text('Popularity')), + DataCell(Text(widget.venueInfo.getPopularity())), ]), DataRow(cells: [ const DataCell(Text('Pricing')), @@ -211,9 +216,9 @@ class _AboutTheSpotTableState extends State { widget.venueInfo.getTotalRatings().toString() + ' ratings)')), ]), - const DataRow(cells: [ - DataCell(Text('Current activity')), - DataCell(Text('Moderate')), + DataRow(cells: [ + DataCell(Text('Popular hours')), + DataCell(Text(widget.venueInfo.getPopularHoursToday())), ]), DataRow(cells: [ const DataCell(Text('Opening hours')), -- 2.39.5