LoginPage #60

Merged
maen0574 merged 6 commits from LoginPage into master 2022-06-01 22:50:13 +02:00
5 changed files with 96 additions and 59 deletions
Showing only changes of commit 049ca366e3 - Show all commits

View File

@ -26,31 +26,23 @@ class _HomePageState extends State<HomePage> {
padding: EdgeInsets.fromLTRB(80, 80, 80, 0), padding: EdgeInsets.fromLTRB(80, 80, 80, 0),
child: Text( child: Text(
'Sun Chasers', 'Sun Chasers',
style: GoogleFonts.libreBaskerville( style: GoogleFonts.roboto(
fontSize: 35, fontSize: 52,
color: globals.TEXTCOLOR, color: globals.TEXTCOLOR,
), ),
textAlign: TextAlign.center,
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Text(
'The #1 Sunny Spot Finder',
style: GoogleFonts.libreBaskerville(
fontSize: 20,
fontWeight: FontWeight. bold,
color: globals.TEXTCOLOR,
),
),
Container( Container(
padding: EdgeInsets.fromLTRB(80, 40, 80, 80), margin: EdgeInsets.fromLTRB(80, 80, 80, 80),
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 200), fixedSize: const Size(200, 200),
primary: globals.BUTTONCOLOR, primary: globals.BUTTONCOLOR,
elevation: 100, elevation: globals.elevation,
shape: const CircleBorder(), shape: const CircleBorder(),
), ),
onPressed: () { onPressed: () {
@ -60,19 +52,12 @@ class _HomePageState extends State<HomePage> {
); );
}, },
child: Text( 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, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
color: Colors.white, color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: globals.SHADOWCOLOR,
),
]
), ),
), ),
), ),
@ -94,7 +79,7 @@ class _HomePageState extends State<HomePage> {
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50), fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR, primary: globals.BUTTONCOLOR,
elevation: 100, elevation: globals.elevation,
), ),
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
@ -106,13 +91,7 @@ class _HomePageState extends State<HomePage> {
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
color: Colors.white, color: Colors.white,
shadows: <Shadow> [ )
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: globals.SHADOWCOLOR,
),
])
), ),
), ),
Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5)), Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5)),
@ -120,7 +99,7 @@ class _HomePageState extends State<HomePage> {
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50), fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR, primary: globals.BUTTONCOLOR,
elevation: 100, elevation: globals.elevation,
), ),
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
@ -132,13 +111,7 @@ class _HomePageState extends State<HomePage> {
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
color: Colors.white, color: Colors.white,
shadows: <Shadow> [ )
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
])
), ),
) )
] ]
@ -151,7 +124,7 @@ class _HomePageState extends State<HomePage> {
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50), fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR, primary: globals.BUTTONCOLOR,
elevation: 100, elevation: globals.elevation,
), ),
onPressed: () { onPressed: () {
globals.LOGGED_IN_USER = User.User(0, "", ""); globals.LOGGED_IN_USER = User.User(0, "", "");

View File

@ -444,20 +444,21 @@ class MapState extends State<Map> {
], ],
), ),
// columnCoveringRating(), // columnCoveringRating(),
],
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column( Column(
children: const [ children: const [
weatherIconRow(), weatherIconRow(),
weatherStatusRow(), weatherStatusRow(),
], ],
), ),
],
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
columnHandlingReadMoreButton(context, venue), columnHandlingReadMoreButton(context, venue),
], ],
) )
@ -487,7 +488,7 @@ class MapState extends State<Map> {
return ElevatedButton( return ElevatedButton(
child: const Text( child: const Text(
'Read More', 'Read More',
style: TextStyle(fontSize: 18), style: TextStyle(fontSize: 16),
), ),
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
@ -509,7 +510,7 @@ class MapState extends State<Map> {
textStyle: const TextStyle( textStyle: const TextStyle(
color: Colors.black87, color: Colors.black87,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 26, fontSize: 20,
)), )),
), ),
Text( Text(
@ -518,7 +519,7 @@ class MapState extends State<Map> {
textStyle: const TextStyle( textStyle: const TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
fontSize: 20, fontSize: 14,
)), )),
) )
], ],

View File

@ -2,13 +2,14 @@ import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom; import 'package:html/dom.dart' as dom;
import 'package:intl/intl.dart';
import 'dart:io'; import 'dart:io';
import 'Venue.dart'; import 'Venue.dart';
class VenueInfo { 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 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 int _priceClass = -1;
late double _rating = -1; late double _rating = -1;
@ -17,6 +18,7 @@ class VenueInfo {
late String _openHoursToday = 'N/A'; late String _openHoursToday = 'N/A';
late String _fsqLink; late String _fsqLink;
late double _popularity = -1; late double _popularity = -1;
late List<dynamic> _hoursPopular = [];
VenueInfo(); VenueInfo();
@ -36,7 +38,7 @@ class VenueInfo {
if(results.isNotEmpty && data['results'][0]['link'] != null) { if(results.isNotEmpty && data['results'][0]['link'] != null) {
_fsqLink = data['results'][0]['link']; _fsqLink = data['results'][0]['link'];
final response2 = await http.get( 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: { headers: {
HttpHeaders.authorizationHeader: 'fsq3LBbeZ8imQK8X1hov7DTb9F64Xs1fs2bojHQ99QNm4TE=', HttpHeaders.authorizationHeader: 'fsq3LBbeZ8imQK8X1hov7DTb9F64Xs1fs2bojHQ99QNm4TE=',
} }
@ -51,6 +53,8 @@ class VenueInfo {
data['popularity'] != null ? _popularity = data['popularity']: null; data['popularity'] != null ? _popularity = data['popularity']: null;
data['photos'][0]['prefix'] != null && data['photos'][0]['suffix'] != null ? data['photos'][0]['prefix'] != null && data['photos'][0]['suffix'] != null ?
_photo = data['photos'][0]['prefix'] + photoSize + 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 { else {
throw const HttpException("No connection to api.foursquare.com"); 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() { String getRating() {
return _rating != -1 ? _rating.toString() + '/10': 'N/A'; return _rating != -1 ? _rating.toString() + '/10': 'N/A';
} }
@ -119,7 +163,7 @@ class VenueInfo {
} }
String getOpenStatus() { String getOpenStatus() {
return _openNow ? 'Open now!': 'Closed'; return _openNow ? 'Yes': 'No';
} }
String getOpeningHours() { String getOpeningHours() {
@ -145,4 +189,17 @@ class VenueInfo {
String getVenueURL () { String getVenueURL () {
return 'https://api.foursquare.com$_fsqLink'; return 'https://api.foursquare.com$_fsqLink';
} }
}
enum WeekDays {
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday,
} }

View File

@ -19,6 +19,7 @@ Color PINKBACKGROUND = const Color.fromARGB(255, 240, 229, 229);
Color TEXTCOLOR = const Color.fromARGB(255, 79, 98, 114); Color TEXTCOLOR = const Color.fromARGB(255, 79, 98, 114);
Color SHADOWCOLOR = const Color.fromARGB(255, 0, 0, 0); Color SHADOWCOLOR = const Color.fromARGB(255, 0, 0, 0);
Color TEXTWHITE = const Color.fromARGB(0, 0, 0, 0); Color TEXTWHITE = const Color.fromARGB(0, 0, 0, 0);
const double elevation = 5;
late List<Venue> VENUES = []; late List<Venue> VENUES = [];
late WeatherData forecast; late WeatherData forecast;

View File

@ -190,14 +190,19 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
label: Text('About the spot', label: Text('About the spot',
style: GoogleFonts.roboto( style: GoogleFonts.roboto(
textStyle: const TextStyle( textStyle: const TextStyle(
fontSize: 18, fontSize: 14,
fontWeight: FontWeight.bold,
)))), )))),
const DataColumn(label: Text('', style: TextStyle())), const DataColumn(label: Text('', style: TextStyle())),
], ],
rows: [ rows: [
const DataRow(cells: [ DataRow(cells: [
DataCell(Text('Type of venue')), DataCell(Text('Open?')),
DataCell(Text('Restaurant')), DataCell(Text(widget.venueInfo.getOpenStatus())),
]),
DataRow(cells: [
DataCell(Text('Popularity')),
DataCell(Text(widget.venueInfo.getPopularity())),
]), ]),
DataRow(cells: [ DataRow(cells: [
const DataCell(Text('Pricing')), const DataCell(Text('Pricing')),
@ -210,9 +215,9 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
widget.venueInfo.getTotalRatings().toString() + widget.venueInfo.getTotalRatings().toString() +
' ratings)')), ' ratings)')),
]), ]),
const DataRow(cells: [ DataRow(cells: [
DataCell(Text('Current activity')), DataCell(Text('Popular hours')),
DataCell(Text('Moderate')), DataCell(Text(widget.venueInfo.getPopularHoursToday())),
]), ]),
DataRow(cells: [ DataRow(cells: [
const DataCell(Text('Opening hours')), const DataCell(Text('Opening hours')),