shas6395 #24

Merged
shas6395 merged 12 commits from shas6395 into master 2022-05-22 13:20:51 +02:00
11 changed files with 167 additions and 61 deletions
Showing only changes of commit 50a3d59445 - Show all commits

View File

@ -602,7 +602,7 @@
"languageVersion": "2.16"
}
],
"generated": "2022-05-17T07:01:31.366070Z",
"generated": "2022-05-17T08:24:36.005738Z",
"generator": "pub",
"generatorVersion": "2.16.2"
}

View File

@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2022-05-17 09:01:31.340139.
# Generated by pub on 2022-05-17 10:24:35.878079.
archive:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/archive-3.3.0/lib/
args:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.3.0/lib/
async:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.8.2/lib/

View File

@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:google_maps_flutter_platform_interface/src/types/camera.dart';
import 'Map.dart';
import 'FavoritePage.dart';
import 'SettingsPage.dart';
class BottomNavPage extends StatefulWidget {
@override
State<BottomNavPage> createState() => BottomNavPageState();
}

View File

@ -1,10 +1,95 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/GoogleSignInProvider.dart';
import 'package:flutter_applicationdemo/Map.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';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:settings_ui/settings_ui.dart';
import 'ManageAccountPage.dart';
import 'GoogleSignInProvider.dart';
import 'package:provider/provider.dart';
import 'Venue.dart';
import 'globals.dart';
import 'Map.dart';
import 'user.dart';
import 'HomePage.dart';
class FavoritePage extends StatelessWidget {
@override
// Standard color of app
Color _backgroundColor = const Color.fromARGB(255, 190, 146, 160);
// Color status of priceRange
Color _colorContainerLow = Colors.yellow;
Color _colorContainerMedium = _backgroundColor;
Color _colorContainerHigh = _backgroundColor;
// Standard
@override
class FavoritePage extends StatefulWidget {
const FavoritePage({Key? key}) : super(key: key);
@override
_FavoritePageState createState() => _FavoritePageState();
}
class _FavoritePageState extends State<FavoritePage> {
List likedVenuesList = LOGGED_IN_USER.likedVenuesList;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text('FavoritePage',style: TextStyle(fontSize: 60),)),
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()),
);
},
)
),
// 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('Item #$index'), trailing: IconButton(icon: Icon(Icons.favorite, color: Colors.red), onPressed: (){
setState(() {
});
print("tabort");
},), onTap: (){
setState(() {
});
print("gå till venue");
},),
// Builds 1000 ListTiles
childCount: 20,
),
),
],
),
),
);
}
}

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'BottomNavPage.dart';
import 'package:flutter_applicationdemo/CreateAccountPage.dart';
import 'Venue.dart';
import 'globals.dart';
import 'mysql.dart';
import 'signInPage.dart';
import 'user.dart';
import 'globals.dart' as globals;
@ -19,7 +22,6 @@ class _HomePageState extends State<HomePage> {
Color textColor = const Color.fromARGB(255, 79, 98, 114);
@override
Widget build(BuildContext context) {
print(LOGGED_IN_USER.userID);
return Scaffold(
backgroundColor: pinkBackgroundColor,
body: SafeArea(
@ -187,4 +189,6 @@ class _HomePageState extends State<HomePage> {
),
);
}
}

View File

@ -7,6 +7,8 @@ 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 'user.dart';
import 'Venue.dart';
@ -29,23 +31,14 @@ class MapState extends State<Map> {
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 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'][1]['geometry']['coordinates']);*/
//print(jsonData['features'][0]['properties']['MAIN_ATTRIBUTE_VALUE']);
@ -55,25 +48,13 @@ class MapState extends State<Map> {
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']);
//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(markers.length);
//print(m['properties']['Kategorityp']);
}
@ -97,6 +78,7 @@ class MapState extends State<Map> {
}
intilize() {
List<Venue> venues;
Marker marker_1;
//for(var marker in markers) {
marker_1 = const Marker(
@ -105,7 +87,7 @@ class MapState extends State<Map> {
infoWindow: InfoWindow(
title: 'Münchenbryggeriet Beer Garden',
snippet: 'Uteservering',
)
),
);
Marker marker_2 = const Marker(
@ -215,7 +197,7 @@ class MapState extends State<Map> {
markersList.add(marker_6);
markersList.add(marker_7);
markersList.add(marker_8);
markersList.add(marker_9);
markersList.add(marker_9);
markersList.add(marker_10);
markersList.add(marker_11);
markersList.add(marker_12);
@ -246,7 +228,7 @@ class MapState extends State<Map> {
textCapitalization: TextCapitalization.words,
decoration: const InputDecoration(hintText: 'Find your place'),
onChanged: (value) {
print(value);
//print(value);
},
),
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
@ -308,6 +290,7 @@ class MapState extends State<Map> {
}
}
class _Marker {
var Plats_1;

16
lib/Venue.dart Normal file
View File

@ -0,0 +1,16 @@
import 'package:google_maps_flutter/google_maps_flutter.dart';
class Venue {
late String venueName;
late int venueID;
late VenueType typeOfVenue;
late LatLng position;
late InfoWindow infoWindow;
Venue(this.venueName,
this.venueID, this.typeOfVenue, this.position);
}
enum VenueType{
cafe, restaurant, bar
}

View File

@ -1,5 +1,7 @@
import 'Venue.dart';
import 'user.dart';
import 'HomePage.dart';
import 'main.dart';
user LOGGED_IN_USER = user(0, "", "");
late List<Venue> VENUES;

View File

@ -4,16 +4,20 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_applicationdemo/GoogleSignInProvider.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart';
import 'Map.dart';
import 'HomePage.dart';
import 'Venue.dart';
import 'mysql.dart';
import 'user.dart';
import 'globals.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await loadAllVenues();
runApp(MyApp());
}
@ -34,26 +38,15 @@ class MyApp extends StatelessWidget {
);
}
}
/*
class HomePage extends StatefulWidget {
@override
State<HomePage> createState() => HomePageState();
}
class HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Map()));
},
label: const Text('To Karta'),
icon: const Icon(Icons.directions_boat),
),
);
}
}*/
Future<void> loadAllVenues() async{
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){
VENUES.add(Venue(row[0], row[1], VenueType.restaurant, LatLng(row[2], row[3])));
}
});
});
}

View File

@ -23,7 +23,7 @@ class _SignInPageState extends State<SignInPage> {
Future<void> loginVerification(String email, String password) async{
await db.getConnection().then((conn) async {
String sql = "select id, email, password from maen0574.user where email = '$email' and password = '$password'";
String sql = "select id, username, email from maen0574.user where email = '$email' and password = '$password'";
await conn.query(sql).then((results){
for(var row in results){
setState(() {

View File

@ -1,12 +1,20 @@
import 'package:flutter_applicationdemo/user.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'Venue.dart';
import 'mysql.dart';
class user{
late int userID;
late String username;
late String email;
late List<int> likedVenuesList;
user(int userID, String username, String email){
this.userID = userID;
this.username = username;
this.email = email;
likedVenuesList = List.empty(growable: true);
getFavoriteVenues();
}
user emptyUser(){
@ -15,4 +23,17 @@ class user{
int getID(){
return userID;
}
}
Future<void> getFavoriteVenues() async{
var db = mysql();
await db.getConnection().then((conn) async {
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]);
}
});
});
}
}