AdamsBranch #41

Merged
adli7087 merged 6 commits from AdamsBranch into master 2022-05-25 15:30:42 +02:00
17 changed files with 327 additions and 562 deletions
Showing only changes of commit b51ee4156b - Show all commits

View File

@ -1,173 +0,0 @@
PODS:
- AppAuth (1.5.0):
- AppAuth/Core (= 1.5.0)
- AppAuth/ExternalUserAgent (= 1.5.0)
- AppAuth/Core (1.5.0)
- AppAuth/ExternalUserAgent (1.5.0):
- AppAuth/Core
- Firebase/Auth (8.15.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 8.15.0)
- Firebase/CoreOnly (8.15.0):
- FirebaseCore (= 8.15.0)
- firebase_auth (1.4.1):
- Firebase/Auth (= 8.15.0)
- firebase_core
- Flutter
- firebase_core (1.17.0):
- Firebase/CoreOnly (= 8.15.0)
- Flutter
- FirebaseAuth (8.15.0):
- FirebaseCore (~> 8.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/Environment (~> 7.7)
- GTMSessionFetcher/Core (~> 1.5)
- FirebaseCore (8.15.0):
- FirebaseCoreDiagnostics (~> 8.0)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/Logger (~> 7.7)
- FirebaseCoreDiagnostics (8.15.0):
- GoogleDataTransport (~> 9.1)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/Logger (~> 7.7)
- nanopb (~> 2.30908.0)
- Flutter (1.0.0)
- flutter_native_splash (0.0.1):
- Flutter
- geocoding (1.0.5):
- Flutter
- geolocator_apple (1.2.0):
- Flutter
- google_maps_flutter (0.0.1):
- Flutter
- GoogleMaps
- google_sign_in_ios (0.0.1):
- Flutter
- GoogleSignIn (~> 5.0)
- GoogleDataTransport (9.1.4):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleMaps (4.1.0):
- GoogleMaps/Maps (= 4.1.0)
- GoogleMaps/Base (4.1.0)
- GoogleMaps/Maps (4.1.0):
- GoogleMaps/Base
- GoogleSignIn (5.0.2):
- AppAuth (~> 1.2)
- GTMAppAuth (~> 1.0)
- GTMSessionFetcher/Core (~> 1.1)
- GoogleUtilities/AppDelegateSwizzler (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.7.0):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.7.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.7.0)"
- GoogleUtilities/Reachability (7.7.0):
- GoogleUtilities/Logger
- GTMAppAuth (1.3.0):
- AppAuth/Core (~> 1.4)
- GTMSessionFetcher/Core (~> 1.5)
- GTMSessionFetcher/Core (1.7.2)
- location (0.0.1):
- Flutter
- nanopb (2.30908.0):
- nanopb/decode (= 2.30908.0)
- nanopb/encode (= 2.30908.0)
- nanopb/decode (2.30908.0)
- nanopb/encode (2.30908.0)
- package_info_plus (0.4.5):
- Flutter
- path_provider_ios (0.0.1):
- Flutter
- PromisesObjC (2.1.0)
DEPENDENCIES:
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- geocoding (from `.symlinks/plugins/geocoding/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
- google_maps_flutter (from `.symlinks/plugins/google_maps_flutter/ios`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/ios`)
- location (from `.symlinks/plugins/location/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
SPEC REPOS:
trunk:
- AppAuth
- Firebase
- FirebaseAuth
- FirebaseCore
- FirebaseCoreDiagnostics
- GoogleDataTransport
- GoogleMaps
- GoogleSignIn
- GoogleUtilities
- GTMAppAuth
- GTMSessionFetcher
- nanopb
- PromisesObjC
EXTERNAL SOURCES:
firebase_auth:
:path: ".symlinks/plugins/firebase_auth/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
Flutter:
:path: Flutter
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
geocoding:
:path: ".symlinks/plugins/geocoding/ios"
geolocator_apple:
:path: ".symlinks/plugins/geolocator_apple/ios"
google_maps_flutter:
:path: ".symlinks/plugins/google_maps_flutter/ios"
google_sign_in_ios:
:path: ".symlinks/plugins/google_sign_in_ios/ios"
location:
:path: ".symlinks/plugins/location/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
SPEC CHECKSUMS:
AppAuth: 80317d99ac7ff2801a2f18ff86b48cd315ed465d
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
firebase_auth: 09005c587c0b450a3adcaad285129f1e32713142
firebase_core: aa1b92020533f5c23955e388c347c58fd64f8627
FirebaseAuth: 3e73bf8abf4fbb40f8b421f361f4cc48ee57388c
FirebaseCore: 5743c5785c074a794d35f2fff7ecc254a91e08b1
FirebaseCoreDiagnostics: 92e07a649aeb66352b319d43bdd2ee3942af84cb
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
geocoding: 32cfcdb16d38d907caaba65e2e42ad10d38bee58
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
google_maps_flutter: c59fc576c0d0c7f4dc4bd63832c862d22d5a7c6d
google_sign_in_ios: ed71c0dbddfba8b1ea9aa210dbda695f46bf51bd
GoogleDataTransport: 5fffe35792f8b96ec8d6775f5eccd83c998d5a3b
GoogleMaps: 008e2c80e38605b56b560e8deb73d4194ff30bef
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1
GTMAppAuth: 4d8f864896f3646f0c33baf38a28362f4c601e15
GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba
location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
PromisesObjC: 99b6f43f9e1044bd87a95a60beff28c2c44ddb72
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
COCOAPODS: 1.11.3

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart';
import 'package:flutter_applicationdemo/Map.dart';
import 'package:flutter_applicationdemo/venuePage.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
@ -14,8 +15,11 @@ import 'package:provider/provider.dart';
import 'Venue.dart';
import 'globals.dart' as globals;
import 'Map.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import 'package:flutter_applicationdemo/login/User.dart';
import 'HomePage.dart';
import 'Venue.dart';
import 'mysql.dart';
import 'globals.dart' as globals;
// Standard color of app
Color _backgroundColor = const Color.fromARGB(255, 190, 146, 160);
@ -33,69 +37,119 @@ class FavoritePage extends StatefulWidget {
@override
_FavoritePageState createState() => _FavoritePageState();
}
class _FavoritePageState extends State<FavoritePage> {
List likedVenuesList = globals.LOGGED_IN_USER.likedVenuesList;
List<Venue> likedVenuesList = globals.LOGGED_IN_USER.likedVenuesList;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
// No appbar provided to the Scaffold, only a body with a
// CustomScrollView.
body: CustomScrollView(
slivers: [
// Add the app bar to the CustomScrollView.
SliverAppBar(
// Provide a standard title.
title: Text("Liked places"),
// Allows the user to reveal the app bar if they begin scrolling
// back up the list of items.
pinned: true,
floating: true,
// Make the initial height of the SliverAppBar larger than normal.
expandedHeight: 50,
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()),
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text("Liked"),
backgroundColor: globals.BACKGROUNDCOLOR,
),
body: ListView.builder(
itemCount: likedVenuesList.length,
itemBuilder: (BuildContext context, int index) {
return Dismissible(
key: UniqueKey(),
background: buildDeleteBackground(MainAxisAlignment.start, true),
secondaryBackground: buildDeleteBackground(MainAxisAlignment.end, false),
confirmDismiss: (DismissDirection direction) async{
return await showDialog(
context: context,
builder: (BuildContext context){
return buildUnlikeConfirmation(index, context);
},
);
},
)
),
// Next, create a SliverList
SliverList(
// Use a delegate to build items as they're scrolled on screen.
delegate: SliverChildBuilderDelegate(
// The builder function returns a ListTile with a title that
// displays the index of the current item.
(context, index) => ListTile(
title: Text(globals.getVenueByID(likedVenuesList[index])!.venueName.toString()),
trailing: IconButton(icon: Icon(Icons.favorite, color: Colors.red),
onPressed: (){
setState(() {
});
print("tabort");
},), onTap: (){
setState(() {
});
print("gå till venue");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Map())
);
},),
// Builds 1000 ListTiles
childCount: likedVenuesList.length,
),
),
],
onDismissed: (DismissDirection direction){
removeVenueAsFavorite(likedVenuesList[index]);
setState(() {
likedVenuesList.removeAt(index);
});
},
child: SizedBox(
width: double.infinity,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Text(likedVenuesList[index].venueName),
),
onTap: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => VenuePage(likedVenuesList[index])),
);
},
),
),
),
);
},
)
),
);
}
AlertDialog buildUnlikeConfirmation(int index, BuildContext context) {
return AlertDialog(
title: Text("Delete confirmation"),
content: Text("Are you sure you want to unlike ${likedVenuesList[index].venueName}?"),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Delete")
),
TextButton(onPressed: () => Navigator.of(context).pop(false),
child: const Text("Cancel")
),
],
);
}
Container buildDeleteBackground(MainAxisAlignment maa, bool heartAtStart) {
return Container(
color: Colors.red,
child: Padding(
padding: const EdgeInsets.all(15),
child: Row(
mainAxisAlignment: maa,
children: setHeartAtBeginning(heartAtStart),
),
),
);
}
List<Widget> setHeartAtBeginning(bool heartAtStart) {
if(heartAtStart){
return <Widget>[
const Icon(Icons.heart_broken, color: Colors.white),
Text("Remove liked venue", style: TextStyle(color: Colors.white)),
];
}
return <Widget>[
const Text("Remove liked venue", style: TextStyle(color: Colors.white)),
Icon(Icons.heart_broken, color: Colors.white),
];
}
void removeVenueAsFavorite(Venue likedVenue) {
var db = mysql();
db.getConnection().then((conn){
String sql =
"DELETE from maen0574.userFavorites where user_id = '${globals.LOGGED_IN_USER.userID}' and venue_id = '${likedVenue.venueID}'";
conn.query(sql).then((results) {
for (var row in results) {
}
});
});
}
}

View File

@ -12,8 +12,6 @@ Color _colorContainerHappy = _backgroundColor;
Color _colorContainerMediumHappy = _backgroundColor;
Color _colorContainerUpset = _backgroundColor;
var timestamp;
Map<String, bool> _satisfactionBoolean = {
"VeryHappy": false,
@ -54,14 +52,13 @@ class FormForFeedbackState extends State<FormForFeedback> {
var dataBase = mysql();
Future<void> feedbackVerification(String satisfaction, String typeOfFeedback, String writtenFeedback, String timestamp ) async {
Future<void> feedbackVerification(String satisfaction, String typeOfFeedback, String writtenFeedback) async {
await dataBase.getConnection().then((conn) async {
String sql = "INSERT INTO maen0574.User_feedback (id, Satisfaction, Type_of_feedback, Written_feedback, timestamp) VALUES (null, '$satisfaction', '$typeOfFeedback', '$writtenFeedback', '$timestamp);";
String sql = "INSERT INTO maen0574.User_feedback (Satisfaction, Type_of_feedback, Written_feedback) VALUES ('$satisfaction', '$typeOfFeedback', '$writtenFeedback');";
await conn.query(sql).then((results) {
for(var row in results) {
print(row[0].toString());
setState(() {});
form(row[0].toString(), row[1].toString(), row[2].toString(), row[3]);
form(row[0].toString(), row[1].toString(), row[2].toString(), row[3].toString());
}
});
});
@ -339,31 +336,48 @@ class FormForFeedbackState extends State<FormForFeedback> {
InkWell(
onTap: () async {
if(writtenFeedback.text.contains("'")) {
print(writtenFeedback.text);
if (writtenFeedback.text.contains("'")) {
print('not allowed to use atrophies');
return;
}
timestamp = DateTime.now().millisecondsSinceEpoch.toString();
await feedbackVerification(satisfaction.text, typeOfFeedback.text, writtenFeedback.text, timestamp);
if (_formKey.currentState!.validate()) {
await feedbackVerification(satisfaction.text, typeOfFeedback.text, writtenFeedback.text);
print(satisfaction.text);
print(typeOfFeedback.text);
print(writtenFeedback.text);
print(satisfaction.text);
print(typeOfFeedback.text);
print(writtenFeedback.text);
print(timestamp);
//pop-up thank you for answering
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
BottomNavPage()), //Replace Container() with call to account-page.
);
}
showDialog<String>(
context: context,
builder: (BuildContext context) =>
AlertDialog(
title: const Text('Thank you'),
content: const Text('Thank you for your feedback, '
'you will now be sent back to the map'),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () =>
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
BottomNavPage()),
//Replace Container() with call to account-page.
),
),
],
),
);
pressedEmojiColor("clear");
pressedTypeOfFeedback("clear");
writtenFeedback.text = '';
},
child: Container(
color: _colorContainerHappy,
color: Colors.purple,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
@ -381,15 +395,11 @@ class FormForFeedbackState extends State<FormForFeedback> {
const SizedBox(height: 30),
],
),
],
),
),
),
);
);
}
}
@ -441,6 +451,17 @@ void pressedEmojiColor (String s) {
_satisfactionBoolean["Upset"] == false;
_colorContainerUpset = _backgroundColor;
}
if(s == "clear"){
_satisfactionBoolean["VeryHappy"] = false;
_colorContainerVeryHappy = _backgroundColor;
_satisfactionBoolean["MediumHappy"] == false;
_colorContainerMediumHappy = _backgroundColor;
_satisfactionBoolean["Happy"] == false;
_colorContainerHappy = _backgroundColor;
_satisfactionBoolean["Upset"] == false;
_colorContainerUpset = _backgroundColor;
}
}
void pressedTypeOfFeedback(String s) {
@ -487,4 +508,15 @@ void pressedTypeOfFeedback(String s) {
_typeOfFeedback["Compliment"] == false;
check1 = false;
}
if (s == "clear") {
_typeOfFeedback["Mistake in sun accuracy"] == false;
check4 = false;
_typeOfFeedback["Complaint"] == false;
check2 = false;
_typeOfFeedback["Bug"] == false;
check3 = false;
_typeOfFeedback["Compliment"] == false;
check1 = false;
}
}

View File

@ -2,12 +2,10 @@ class form {
late String satisfaction;
late String typeOfFeedback;
late String writtenFeedback;
late String timestamp;
form(String satisfaction, String typeOfFeedback, String writtenFeedback, String timestamp){
this.satisfaction = satisfaction;
this.typeOfFeedback = typeOfFeedback;
this.writtenFeedback = writtenFeedback;
this.timestamp = timestamp;
}
}

View File

@ -3,7 +3,11 @@ import 'package:google_fonts/google_fonts.dart';
import 'BottomNavPage.dart';
import 'login/CreateAccountPage.dart';
import 'globals.dart';
import 'login/User.dart';
import 'login/signInPage.dart';
import '../login/User.dart';
import 'mysql.dart';
import 'package:flutter_applicationdemo/login/User.dart' as User;
import 'login/user.dart';
import 'globals.dart' as globals;
@ -45,7 +49,6 @@ class _HomePageState extends State<HomePage> {
color: globals.TEXTCOLOR,
),
),
Container(
padding: EdgeInsets.fromLTRB(80, 40, 80, 80),
child: ElevatedButton(
@ -156,7 +159,7 @@ class _HomePageState extends State<HomePage> {
elevation: 100,
),
onPressed: () {
globals.LOGGED_IN_USER = user(0, "", "");
globals.LOGGED_IN_USER = User.User(0, "", "");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()), //Replace Container() with call to Map-page.

View File

@ -1,15 +1,21 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/WebScraper.dart';
import 'dart:async';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_google_places/flutter_google_places.dart';
//import 'package:google_maps_webservice/places.dart';
import 'package:google_api_headers/google_api_headers.dart';
import 'package:http/http.dart' as http;
import 'package:location/location.dart';
import 'package:geolocator/geolocator.dart';
import 'package:flutter_applicationdemo/login/User.dart';
import 'SettingsPage.dart';
import 'Venue.dart';
import 'globals.dart' as globals;
import 'globals.dart' as globals;
class Map extends StatefulWidget {
@override
@ -20,8 +26,6 @@ const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk";
final homeSacffoldKey = GlobalKey<ScaffoldState>();
List<_Marker> markers = [];
class MapState extends State<Map> {
Future getMerkerData() async {
var url = Uri.parse(
@ -31,52 +35,6 @@ class MapState extends State<Map> {
print('Response status: ${response.statusCode}');
// print('Response body: ${response.body.toString()}');
var jsonData = jsonDecode(response.body);
/* print(jsonData['features'][0]);
print(jsonData['features'][1]['properties']['Plats_1']);
print(jsonData['features'][0]['properties']['Gatunr_1']);
print(jsonData['features'][0]['properties']['Kategorityp']);
/*String data = jsonData['features'][0]['properties']['Kategorityp'];
print(data.contains('Tillfälliga bostäder'));*/
print(jsonData['features'][1]['geometry']['coordinates']);*/
//print(jsonData['features'][0]['properties']['MAIN_ATTRIBUTE_VALUE']);
// List<_Marker> markers = [];
for (var m in jsonData['features']) {
String data = m['properties']['Kategorityp'];
String typ = m['properties']['MAIN_ATTRIBUTE_VALUE'];
if (m['properties']['Kategorityp'] == "1.400I, Uteservering A-läge") {
print(m['properties']['Kategorityp']);
_Marker marker = _Marker(m['properties']['Plats_1'],
m['properties']['Gatunr_1'], m['geometry']['coordinates']);
markers.add(marker);
}
print(markers.length);
int count = 0;
for (var mar in markers) {
print(mar.Plats_1);
print(mar.Gatunr_1);
print(mar.coordinates[1]);
print(mar.coordinates[0]);
count++;
print(count);
if (count == 100) {
break;
}
}
//print(m['properties']['Kategorityp']);
}
}
final Completer<GoogleMapController> _controller = Completer();
@ -92,12 +50,14 @@ class MapState extends State<Map> {
@override
void initState() {
intilize();
_getUserLocation();
initialize();
//_getUserLocation();
super.initState();
}
void createBottomSheet() {
void createBottomSheet(String venueName) async {
var webScraper = WebScraper();
await webScraper.getWebsiteData(venueName);
Scaffold.of(context).showBottomSheet<void>(((context) {
return Container(
height: 420,
@ -106,146 +66,31 @@ class MapState extends State<Map> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
children: <Widget>[
/*const Text('BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () {Navigator.pop(context);})*/
Image(image: AssetImage('assets/images/bild.png'))
Container(
child: Text(webScraper.openingHoursThisWeek.length.toString()),
),
],
)),
);
}));
}
intilize() {
Marker marker_1;
//for(var marker in markers) {
marker_1 = Marker(
markerId: const MarkerId('id_1'),
onTap: createBottomSheet,
position: const LatLng(59.320671571444514, 18.055854162299937),
infoWindow: const InfoWindow(
title: 'Münchenbryggeriet Beer Garden',
snippet: 'Uteservering',
),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueGreen,
),
);
Marker marker_2 = Marker(
markerId: const MarkerId('id_2'),
onTap: createBottomSheet,
position: const LatLng(59.33115735285231, 18.074432570090742),
infoWindow: const InfoWindow(
title: 'Le Hibou',
snippet: 'Uteservering',
));
Marker marker_3 = Marker(
markerId: const MarkerId('id_3'),
onTap: createBottomSheet,
position: const LatLng(59.3315552932853, 18.092751076985277),
infoWindow: const InfoWindow(
title: 'Strandbryggan',
snippet: 'Uteservering',
));
Marker marker_4 = Marker(
markerId: const MarkerId('id_4'),
onTap: createBottomSheet,
position: const LatLng(59.33632582609118, 18.072980646196587),
infoWindow: const InfoWindow(
title: 'Stureplan 1',
snippet: 'Uteservering',
));
Marker marker_5 = Marker(
markerId: const MarkerId('id_5'),
onTap: createBottomSheet,
position: const LatLng(59.3240158318325, 18.070690101341437),
infoWindow: const InfoWindow(
title: 'Bågspännaren Bar & Cafe',
snippet: 'Uteservering',
));
Marker marker_6 = Marker(
markerId: const MarkerId('id_6'),
onTap: createBottomSheet,
position: const LatLng(59.31905195030728, 18.075349015415547),
infoWindow: const InfoWindow(
title: 'Mosebacketerrassen',
snippet: 'Uteservering',
));
Marker marker_7 = Marker(
markerId: const MarkerId('id_7'),
onTap: createBottomSheet,
position: const LatLng(59.31583756143469, 18.072591381467536),
infoWindow: const InfoWindow(
title: 'Snaps Bar & Bistro',
snippet: 'Uteservering',
));
Marker marker_8 = Marker(
markerId: const MarkerId('id_8'),
onTap: createBottomSheet,
position: const LatLng(59.315129508641505, 18.074243159987006),
infoWindow: const InfoWindow(
title: 'Kvarnen',
snippet: 'Uteservering',
));
Marker marker_9 = Marker(
markerId: const MarkerId('id_9'),
onTap: createBottomSheet,
position: const LatLng(59.31533181094423, 18.070972638518455),
infoWindow: const InfoWindow(
title: 'Neverland Pub & Restaurang',
snippet: 'Uteservering',
));
Marker marker_10 = Marker(
markerId: const MarkerId('id_10'),
onTap: createBottomSheet,
position: const LatLng(59.31578389646754, 18.071146819010995),
infoWindow: const InfoWindow(
title: 'Baras Imperium',
snippet: 'Uteservering',
));
Marker marker_11 = Marker(
markerId: const MarkerId('id_11'),
onTap: createBottomSheet,
position: const LatLng(59.31549103673382, 18.035425964557245),
infoWindow: const InfoWindow(
title: 'YUC Tanto',
snippet: 'Uteservering',
));
Marker marker_12 = Marker(
markerId: const MarkerId('id_12'),
onTap: createBottomSheet,
position: const LatLng(59.314826329005506, 18.03317611771755),
infoWindow: const InfoWindow(
title: 'Loopen',
snippet: 'Uteservering',
));
markersList.add(marker_1);
markersList.add(marker_2);
markersList.add(marker_3);
markersList.add(marker_4);
markersList.add(marker_5);
markersList.add(marker_6);
markersList.add(marker_7);
markersList.add(marker_8);
markersList.add(marker_9);
markersList.add(marker_10);
markersList.add(marker_11);
markersList.add(marker_12);
// }
initialize() {
List<Venue> allVenues = globals.VENUES;
for (var venue in allVenues) {
Marker marker = Marker(
markerId: MarkerId(venue.venueID.toString()),
position: venue.position,
onTap: () => createBottomSheet(venue.venueName),
icon: venue.drawIconColor(),
);
markersList.add(marker);
}
}
Future<LocationData> _getLocationPermission() async {
@ -328,8 +173,6 @@ class MapState extends State<Map> {
Icons.attach_money_outlined,
color: Colors.black,
),
],
),
),
@ -356,48 +199,6 @@ class MapState extends State<Map> {
_controller.complete(controller);
},
),
Align(
alignment: Alignment.bottomLeft,
child: Container(
margin: EdgeInsets.symmetric(vertical: 20.0),
height: 250.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(59.320671571444514, 18.055854162299937,
'Münchenbryggeriet Beer Garden'),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
59.33115735285231, 18.074432570090742, 'Le Hibou'),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
59.3315552932853, 18.092751076985277, 'Strandbryggan'),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
59.33632582609118, 18.072980646196587, 'Stureplan 1'),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(59.3240158318325, 18.070690101341437,
'Bågspännaren Bar & Cafe'),
),
],
),
),
)
// ElevatedButton(onPressed: () {} //_handelPressButton
// ,child: const Text("Search Placses"))
],
@ -432,41 +233,34 @@ class MapState extends State<Map> {
_gotoLocation(lat, lng);
},
child: Container(
child: FittedBox(
child: Material(
child: FittedBox(
child: Material(
color: Colors.white,
elevation: 14.0,
borderRadius: BorderRadius.circular(24.0),
shadowColor: Color(0x802196F3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: 250,
height: 200,
child: ClipRRect(
borderRadius: new BorderRadius.circular(24.0),
child:
const Image(image: AssetImage('assets/images/bild.png')),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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),
),
)
],
),
),
)),
]),
)),
),
);
}
Future<void> _goToCurrentPosition(LatLng latlng) async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
bearing: 192.8334901395799,
bearing: 0,
target: LatLng(latlng.latitude, latlng.longitude),
//tilt: 59.440717697143555,
zoom: 14.4746)));
@ -511,11 +305,3 @@ class MapState extends State<Map> {
googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0));
}*/
}
class _Marker {
var Plats_1;
var Gatunr_1;
var coordinates;
_Marker(this.Plats_1, this.Gatunr_1, this.coordinates);
}

View File

@ -9,15 +9,15 @@ class ShadowDetector {
List<Venue> venuesInShade = [];
ShadowDetector(Venue venue) {
evaluateShadowsForOneVenue(venue);
ShadowDetector() {
}
//Called like "new ShadowDetector.fromShadowDetector(List of venues here);"
ShadowDetector.fromShadowDetector(venues) {
evaluateShadowsForAllVenues(venues);
}
void evaluateShadowsForAllVenues (List<Venue> venues) async {
Future evaluateShadowsForAllVenues (List<Venue> venues) async {
final dateInMilliseconds = DateTime.now().millisecondsSinceEpoch.toString() + 't';
for(var venue in venues) {
LatLng pos = venue.position;
@ -50,5 +50,8 @@ class ShadowDetector {
if(responseAsString[responseAsString.length - 2] == 1) {
venue.inShade = true;
}
else {
venue.inShade = false;
}
}
}

View File

@ -11,8 +11,21 @@ class Venue {
Venue(this.venueName,
this.venueID, this.typeOfVenue, this.position);
BitmapDescriptor drawIconColor() {
if(inShade) {
return BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueAzure);
}
else {
return BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueYellow);
}
}
}
enum VenueType{
cafe, restaurant, bar
}

View File

@ -7,14 +7,15 @@ class WebScraper {
late List<String> openingHoursThisWeek;
late String openingHoursToday;
late String reviewScore;
late String priceClass;
//late String priceClass;
WebScraper() { //Must provide an URL from bing search engine.
WebScraper(String bingURL) { //Must provide an URL from bing search engine.
getWebsiteData(bingURL);
}
Future getWebsiteData(String bingURL) async {
final bingResponse = await http.get(Uri.parse(bingURL));
Future getWebsiteData(String venueName) async {
final bingURL = Uri.parse('https://www.bing.com/search?q=$venueName');
final bingResponse = await http.get(bingURL);
dom.Document htmlBing = dom.Document.html(bingResponse.body);
@ -34,7 +35,7 @@ class WebScraper {
.toList()[0]
.toString();
final tripAdvisorURL = htmlBing.querySelectorAll('div.infoModule.b_divsec.topBleed.noSeparator > div > a')
/* final tripAdvisorURL = htmlBing.querySelectorAll('div.infoModule.b_divsec.topBleed.noSeparator > div > a')
.map((e) => e.attributes['href'])
.toList()[0]
.toString();
@ -46,7 +47,7 @@ class WebScraper {
.getElementsByClassName('drUyy')
.map((e) => e.text)
.toList()[0]
.toString();
.toString();*/
}
List<String> get getOpeningHoursThisWeek => openingHoursThisWeek; //First item is monday, last item is sunday.
@ -54,6 +55,6 @@ class WebScraper {
String get getOpeningHoursToday => openingHoursToday; //Output example: "Open · Closes 01:00" (Gets automatically updated).
String get getReviewScore => reviewScore; // Output example: "Star Rating: 4 out of 5.".
String get getPriceClass => priceClass; // Output example: "$$ - $$$".
//String get getPriceClass => priceClass; // Output example: "$$ - $$$".
}

View File

@ -1,14 +1,16 @@
import 'Venue.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import '../login/user.dart';
import 'package:flutter_applicationdemo/login/User.dart';
import '../login/User.dart';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'HomePage.dart';
import 'Venue.dart';
import 'Venue.dart';
import 'main.dart';
user LOGGED_IN_USER = user(0, "", "");
User LOGGED_IN_USER = User(0, "", "");
Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160);
Color ITEMCOLOR = const Color.fromARGB(255, 0, 0, 0);
Color BUTTONCOLOR = const Color.fromARGB(204, 172, 123, 132);

View File

@ -8,7 +8,7 @@ import 'package:flutter_applicationdemo/mysql.dart';
import 'package:flutter_applicationdemo/HomePage.dart';
import '../globals.dart' as globals;
import '../reusables/InputField.dart';
import 'user.dart';
import 'User.dart';
import '../reusables/returnButton.dart';
class CreateAccountPage extends StatefulWidget {
@ -22,7 +22,7 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
TextEditingController passwordController = TextEditingController();
TextEditingController userNameController = TextEditingController();
var db = mysql();
late user loggedInUser;
late User loggedInUser;
@override
Widget build(BuildContext context) {
@ -150,7 +150,7 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
await conn.query(sql).then((results) {
for (var row in results) {
setState(() {});
loggedInUser = new user(row[0], row[1], row[2]);
loggedInUser = new User(row[0], row[1], row[2]);
globals.LOGGED_IN_USER.userID = loggedInUser.userID;
}
});

View File

@ -1,23 +1,21 @@
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_applicationdemo/Venue.dart';
import 'package:flutter_applicationdemo/mysql.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals;
class user{
class User{
late int userID;
late String username;
late String email;
late List<int> likedVenuesList;
late List<Venue> likedVenuesList;
user(int userID, String username, String email){
this.userID = userID;
this.username = username;
this.email = email;
User(this.userID, this.username, this.email){
likedVenuesList = List.empty(growable: true);
getFavoriteVenues();
}
user emptyUser(){
return user(0, "", "");
User emptyUser(){
return User(0, "", "");
}
int getID(){
return userID;
@ -29,9 +27,15 @@ class user{
String sql = "select venue_id from maen0574.userFavorites where user_id = '$userID'";
await conn.query(sql).then((results){
for(var row in results){
likedVenuesList.add(row[0]);
Venue? venue = globals.getVenueByID(row[0]);
if(venue != null){
likedVenuesList.add(venue);
}
}
});
for(Venue venue in likedVenuesList){
print(venue.venueName);
}
});
}
}

View File

@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import '../mysql.dart';
import '../HomePage.dart';
import '../main.dart';
import 'user.dart';
import 'User.dart';
import '../reusables/InputField.dart';
import '../reusables/returnButton.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart';
@ -20,8 +20,7 @@ class SignInPage extends StatefulWidget {
class _SignInPageState extends State<SignInPage> {
var db = mysql();
int loggedInID = 0;
late user loggedInUser;
late User loggedInUser;
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
@ -32,8 +31,8 @@ class _SignInPageState extends State<SignInPage> {
await conn.query(sql).then((results) {
for (var row in results) {
setState(() {});
loggedInUser = new user(row[0], row[1], row[2]);
loggedInID = loggedInUser.getID();
loggedInUser = new User(row[0], row[1], row[2]);
globals.LOGGED_IN_USER = loggedInUser;
}
});
});
@ -141,11 +140,12 @@ class _SignInPageState extends State<SignInPage> {
onPressed: () async {
if (emailController.text.contains("'") ||
passwordController.text.contains("'")) {
print("1");
loginError();
return;
}
await loginVerification(emailController.text, passwordController.text);
if (loggedInID != 0) {
if (globals.LOGGED_IN_USER.userID != 0) {
globals.LOGGED_IN_USER = loggedInUser;
Navigator.push(
context,
@ -154,6 +154,7 @@ class _SignInPageState extends State<SignInPage> {
HomePage()), //Replace Container() with call to account-page.
);
} else {
print(globals.LOGGED_IN_USER.userID);
loginError();
}
//print(loggedInUser.email + " " + loggedInUser.userID.toString());
@ -183,6 +184,8 @@ class _SignInPageState extends State<SignInPage> {
CreateAccountPage()), //Replace Container() with call to Map-page.
);
} else {
var email = provider.user?.email.toString();
await loginVerificationGmail(email!);
Navigator.push(
context,
MaterialPageRoute(
@ -192,4 +195,32 @@ class _SignInPageState extends State<SignInPage> {
}
});
}
Future<void> loginVerificationGmail(String email) async{
await db.getConnection().then((conn) async {
String sql =
"select id, email, password from maen0574.user where email = '$email'";
await conn.query(sql).then((results) {
for (var row in results) {
setState(() {});
loggedInUser = new User(row[0], row[1], row[2]);
globals.LOGGED_IN_USER = loggedInUser;
}
});
});
if(globals.LOGGED_IN_USER.userID == 0){
await db.getConnection().then((conn) async{
String sql = "INSERT INTO maen0574.user (id, email, password, username) VALUES (null, '$email', '', '');";
await conn.query(sql);
sql = "Select id, email, username from maen0574.user where email = '$email'";
await conn.query(sql).then((results) {
for (var row in results) {
setState(() {});
loggedInUser = new User(row[0], row[1], row[2]);
globals.LOGGED_IN_USER.userID = loggedInUser.userID;
}
});
});
}
}
}

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_applicationdemo/ShadowDetector.dart';
import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart';
@ -12,8 +13,8 @@ import 'Map.dart';
import 'HomePage.dart';
import 'Venue.dart';
import 'mysql.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import 'login/user.dart';
import 'package:flutter_applicationdemo/login/User.dart';
import 'login/User.dart';
import 'globals.dart' as globals;
void main() async {
@ -41,6 +42,7 @@ class MyApp extends StatelessWidget {
}
}
Future<void> loadAllVenues() async{
globals.VENUES = [];
var db = mysql();
await db.getConnection().then((conn) async {
String sql = "select venueName, venueID, latitude, longitude from maen0574.venue";
@ -50,4 +52,8 @@ Future<void> loadAllVenues() async{
}
});
});
var sd = ShadowDetector();
await sd.evaluateShadowsForAllVenues(globals.VENUES);
}

View File

@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter_applicationdemo/Venue.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
@ -149,15 +150,19 @@ class WeatherData {
}
class VenuePage extends StatefulWidget {
const VenuePage({Key? key}) : super(key: key);
const VenuePage(this.venue, {Key? key}) : super(key: key);
final Venue venue;
@override
State<VenuePage> createState() => _VenuePageState();
State<VenuePage> createState() => _VenuePageState(venue);
}
class _VenuePageState extends State<VenuePage> {
late WeatherData currentWeather;
final String imageLink = '';
late final Venue venue;
_VenuePageState(this.venue);
validateAndGetImageLink() {
if (imageLink == '') {
@ -200,10 +205,10 @@ class _VenuePageState extends State<VenuePage> {
return Scaffold(
backgroundColor: const Color(0xfffceff9),
appBar: AppBar(
title: const Text('My Venue'),
title: Text(venue.venueName),
backgroundColor: const Color(0xffac7b84),
),
body: Center(
body: Center(child: SingleChildScrollView(
child: Container(
alignment: Alignment.center,
child: Column(children: <Widget>[
@ -228,8 +233,8 @@ class _VenuePageState extends State<VenuePage> {
Row(children: [
Expanded(
child: Column(
children: const [
Text('This is the name'),
children: [
Text(venue.venueName),
Text('This is the address'),
],
)),
@ -271,14 +276,14 @@ class _VenuePageState extends State<VenuePage> {
)
]),
const AboutTheSpotTable(),
GridView.count(
/*GridView.count(
crossAxisCount: 2,
children: [],
)
)*/
]),
),
),
);
));
}
}