Venues from server #44
345
lib/Map.dart
345
lib/Map.dart
@ -1,7 +1,10 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_applicationdemo/WeatherData.dart';
|
||||||
import 'package:flutter_applicationdemo/WebScraper.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 'dart:async';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:flutter_google_places/flutter_google_places.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 'package:flutter_applicationdemo/login/User.dart';
|
||||||
import 'SettingsPage.dart';
|
import 'SettingsPage.dart';
|
||||||
|
import 'WeatherData.dart';
|
||||||
|
import 'venuePage.dart';
|
||||||
import 'Venue.dart';
|
import 'Venue.dart';
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
|
|
||||||
|
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
|
|
||||||
|
|
||||||
class Map extends StatefulWidget {
|
class Map extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
State<Map> createState() => MapState();
|
State<Map> createState() => MapState();
|
||||||
@ -28,29 +31,27 @@ const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk";
|
|||||||
|
|
||||||
final homeSacffoldKey = GlobalKey<ScaffoldState>();
|
final homeSacffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
|
||||||
class MapState extends State<Map> {
|
class MapState extends State<Map> {
|
||||||
|
bool _bottomSheetIsOpen = false;
|
||||||
|
|
||||||
Future getMerkerData() async {
|
/* 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 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);
|
var response = await http.get(url);
|
||||||
|
|
||||||
print('Response status: ${response.statusCode}');
|
print('Response status: ${response.statusCode}');
|
||||||
// print('Response body: ${response.body.toString()}');
|
// print('Response body: ${response.body.toString()}');
|
||||||
var jsonData = jsonDecode(response.body);
|
var jsonData = jsonDecode(response.body);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
final Completer<GoogleMapController> _controller = Completer();
|
final Completer<GoogleMapController> _controller = Completer();
|
||||||
|
|
||||||
LocationData? _currentPosition;
|
LocationData? _currentPosition;
|
||||||
|
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
static const CameraPosition _kGooglePlex = CameraPosition(
|
static const CameraPosition _stockholmCity = CameraPosition(
|
||||||
target: LatLng(59.325027,18.068516),
|
target: LatLng(59.325027, 18.068516),
|
||||||
zoom: 14.4746,
|
zoom: 14.4746,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -63,48 +64,48 @@ class MapState extends State<Map> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void createBottomSheet(String venueName) async {
|
|
||||||
var webScraper = WebScraper();
|
|
||||||
await webScraper.getWebsiteData(venueName);
|
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
|
||||||
((context) {
|
|
||||||
return Container(
|
|
||||||
height: 420,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
/*const Text('BottomSheet'),
|
|
||||||
ElevatedButton(
|
|
||||||
child: const Text('Close BottomSheet'),
|
|
||||||
onPressed: () {Navigator.pop(context);})*/
|
|
||||||
Container(
|
|
||||||
child: Text(webScraper.openingHoursThisWeek.length.toString()),
|
|
||||||
),
|
|
||||||
|
|
||||||
],
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
List<Venue> allVenues = globals.VENUES;
|
List<Venue> allVenues = globals.VENUES;
|
||||||
for(var venue in allVenues) {
|
for (var venue in allVenues) {
|
||||||
Marker marker = Marker(
|
Marker marker = Marker(
|
||||||
markerId: MarkerId(venue.venueID.toString()),
|
markerId: MarkerId(venue.venueID.toString()),
|
||||||
position: venue.position,
|
position: venue.position,
|
||||||
onTap: () => createBottomSheet(venue.venueName),
|
/*infoWindow: InfoWindow(
|
||||||
icon: venue.drawIconColor(),
|
title: venue.venueName,
|
||||||
);
|
snippet: venue.venueAddress,
|
||||||
|
),*/
|
||||||
|
// onTap: () => createBottomSheet(venue.venueName),
|
||||||
|
onTap: () => createBottomDrawer(venue),
|
||||||
|
icon: venue.drawIconColor(),
|
||||||
|
);
|
||||||
markersList.add(marker);
|
markersList.add(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createBottomSheet(String venueName) async {
|
||||||
|
var webScraper = WebScraper();
|
||||||
|
await webScraper.getWebsiteData(venueName);
|
||||||
|
Scaffold.of(context).showBottomSheet<void>(((context) {
|
||||||
|
return Container(
|
||||||
|
height: 420,
|
||||||
|
color: Colors.white,
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
/*const Text('BottomSheet'),
|
||||||
|
ElevatedButton(
|
||||||
|
child: const Text('Close BottomSheet'),
|
||||||
|
onPressed: () {Navigator.pop(context);})*/
|
||||||
|
Container(
|
||||||
|
child: Text(webScraper.openingHoursThisWeek.length.toString()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
Future<LocationData> _getLocationPermission() async {
|
Future<LocationData> _getLocationPermission() async {
|
||||||
Location location = Location();
|
Location location = Location();
|
||||||
@ -145,9 +146,10 @@ class MapState extends State<Map> {
|
|||||||
final Mode _mode = Mode.fullscreen;
|
final Mode _mode = Mode.fullscreen;
|
||||||
|
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
final screens =[
|
final screens = [
|
||||||
Map(),
|
Map(),
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -155,8 +157,10 @@ class MapState extends State<Map> {
|
|||||||
key: homeSacffoldKey,
|
key: homeSacffoldKey,
|
||||||
//leading: IconButton(icon: Icon(Icons.search), onPressed:() {},),
|
//leading: IconButton(icon: Icon(Icons.search), onPressed:() {},),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
IconButton(icon: const Icon(Icons.search), onPressed:() {
|
IconButton(
|
||||||
},),
|
icon: const Icon(Icons.search),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
title: TextFormField(
|
title: TextFormField(
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
@ -168,78 +172,79 @@ class MapState extends State<Map> {
|
|||||||
),
|
),
|
||||||
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
||||||
),
|
),
|
||||||
body: Stack (
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
GoogleMap(
|
GoogleMap(
|
||||||
mapType: MapType.normal,
|
mapType: MapType.normal,
|
||||||
initialCameraPosition: _kGooglePlex,
|
myLocationEnabled: true,
|
||||||
|
initialCameraPosition: _stockholmCity,
|
||||||
markers: markersList.map((e) => e).toSet(),
|
markers: markersList.map((e) => e).toSet(),
|
||||||
onMapCreated: (GoogleMapController controller) {
|
onMapCreated: (GoogleMapController controller) {
|
||||||
_controller.complete(controller);
|
_controller.complete(controller);
|
||||||
},
|
},
|
||||||
|
onTap: (LatLng) {
|
||||||
|
closeBottomSheetIfOpen();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
// ElevatedButton(onPressed: () {} //_handelPressButton
|
// ElevatedButton(onPressed: () {} //_handelPressButton
|
||||||
// ,child: const Text("Search Placses"))
|
// ,child: const Text("Search Placses"))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
floatingActionButton: Padding(
|
||||||
floatingActionButton: Padding(
|
padding: const EdgeInsets.only(top: 100.0),
|
||||||
padding: const EdgeInsets.only(top: 100.0),
|
child: FloatingActionButton(
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(context,
|
||||||
context,
|
MaterialPageRoute(builder: (context) => const SettingsPage()));
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const SettingsPage()));
|
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.purple,
|
backgroundColor: Colors.purple,
|
||||||
child: const Icon(Icons.filter_alt),
|
child: const Icon(Icons.filter_alt),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> _gotoLocation(double lat, double lng) async {
|
Future<void> _gotoLocation(double lat, double lng) async {
|
||||||
final GoogleMapController controller = await _controller.future;
|
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) {
|
Widget _boxes(double lat, double lng, String resturantName) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () { _gotoLocation(lat, lng);},
|
onTap: () {
|
||||||
|
_gotoLocation(lat, lng);
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
elevation: 14.0,
|
elevation: 14.0,
|
||||||
borderRadius: BorderRadius.circular(24.0),
|
borderRadius: BorderRadius.circular(24.0),
|
||||||
shadowColor: Color(0x802196F3),
|
shadowColor: Color(0x802196F3),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
width: 250,
|
width: 250,
|
||||||
height: 200,
|
height: 200,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: new BorderRadius.circular(24.0),
|
borderRadius: new BorderRadius.circular(24.0),
|
||||||
child: const Image(
|
child:
|
||||||
image: AssetImage('assets/images/bild.png')
|
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<Map> {
|
|||||||
zoom: 14.4746)));
|
zoom: 14.4746)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Future<void> _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<void>(((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: <Widget>[
|
||||||
|
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<void> _handelPressButton() async {
|
||||||
|
|
||||||
Prediction? p = await PlacesAutocomplete.show(
|
Prediction? p = await PlacesAutocomplete.show(
|
||||||
context: context,
|
context: context,
|
||||||
@ -291,4 +429,3 @@ class MapState extends State<Map> {
|
|||||||
googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0));
|
googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0));
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ShadowDetector {
|
|||||||
|
|
||||||
List<Venue> get listWithVenuesInShade => venuesInShade; //Get all venues with their shadow status updated.
|
List<Venue> 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;
|
LatLng pos= venue.position;
|
||||||
final lat = pos.latitude.toString();
|
final lat = pos.latitude.toString();
|
||||||
final lng = pos.longitude.toString();
|
final lng = pos.longitude.toString();
|
||||||
|
@ -25,12 +25,12 @@ class Venue {
|
|||||||
LatLng tempPosition = LatLng(double.parse(splitArr[1]), double.parse(splitArr[0]));
|
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('Coordinates: ' + tempCoordinates);
|
||||||
print('Parsed: ' + double.parse(splitArr[0]).toString());
|
print('Parsed: ' + double.parse(splitArr[0]).toString());
|
||||||
print(LatLng(double.parse(splitArr[1]), double.parse(splitArr[0])));
|
print(LatLng(double.parse(splitArr[1]), double.parse(splitArr[0])));
|
||||||
print(tempAddress + tempName);
|
print(tempAddress + tempName);
|
||||||
print(tempPosition.latitude.toString() + " " + splitArr[0]);
|
print(tempPosition.latitude.toString() + " " + splitArr[0]);*/
|
||||||
|
|
||||||
// print('Json-Object:');
|
// print('Json-Object:');
|
||||||
// print(json);
|
// print(json);
|
||||||
@ -91,7 +91,7 @@ class Venue {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return 'ID: ' +
|
return 'ID: ' +
|
||||||
venueID.toString() +
|
venueID.toString() +
|
||||||
' ' +
|
', ' +
|
||||||
'name: ' +
|
'name: ' +
|
||||||
venueName +
|
venueName +
|
||||||
', ' +
|
', ' +
|
||||||
|
@ -140,4 +140,7 @@ class WeatherData {
|
|||||||
return const FaIcon(FontAwesomeIcons.times);
|
return const FaIcon(FontAwesomeIcons.times);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:flutter_applicationdemo/WeatherData.dart';
|
||||||
|
|
||||||
import 'Venue.dart';
|
import 'Venue.dart';
|
||||||
import 'package:flutter_applicationdemo/login/User.dart';
|
import 'package:flutter_applicationdemo/login/User.dart';
|
||||||
import '../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 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);
|
||||||
late List<Venue> VENUES = [];
|
late List<Venue> VENUES = [];
|
||||||
|
late WeatherData forecast;
|
||||||
|
|
||||||
Venue? getVenueByID(int searchedVenueID){
|
Venue? getVenueByID(int searchedVenueID){
|
||||||
for(var V in VENUES){
|
for(var V in VENUES){
|
||||||
|
@ -13,6 +13,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import 'Map.dart';
|
import 'Map.dart';
|
||||||
|
import 'WeatherData.dart';
|
||||||
import 'HomePage.dart';
|
import 'HomePage.dart';
|
||||||
import 'Venue.dart';
|
import 'Venue.dart';
|
||||||
import 'mysql.dart';
|
import 'mysql.dart';
|
||||||
@ -24,10 +25,29 @@ void main() async {
|
|||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
await loadAllVenues();
|
await loadAllVenues();
|
||||||
|
await fetchWeather();
|
||||||
|
|
||||||
runApp(MyApp());
|
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 {
|
class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -46,32 +66,39 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future loadAllVenues() async {
|
Future loadAllVenues() async {
|
||||||
|
|
||||||
Uri venueDataURI = Uri.parse(
|
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/weather-0.0.4-SNAPSHOT.war/venue');
|
||||||
|
|
||||||
final response = await http.get(venueDataURI);
|
final response = await http.get(venueDataURI);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var data = json.decode(response.body);
|
addVenues(response);
|
||||||
var _allVenuesTemp = [];
|
|
||||||
|
|
||||||
addValidVenues(data, _allVenuesTemp);
|
// var sd = ShadowDetector();
|
||||||
|
// await sd.evaluateShadowsForAllVenues(seventyFiveVenues);
|
||||||
var count = 0;
|
|
||||||
for (Venue vdata in _allVenuesTemp) {
|
|
||||||
count++;
|
|
||||||
//print(count.toString() + ': ' + vdata.toString());
|
|
||||||
globals.VENUES.add(vdata);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw const HttpException("Problem fetching the weather data");
|
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<dynamic> _allVenuesTemp) {
|
void addValidVenues(data, List<dynamic> _allVenuesTemp) {
|
||||||
for (var i = 0; i < data.values.first.length; i++) {
|
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('¥') &&
|
!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<dynamic> _allVenuesTemp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
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";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -165,6 +165,8 @@ class _VenuePageState extends State<VenuePage> {
|
|||||||
|
|
||||||
_VenuePageState(this.venue);
|
_VenuePageState(this.venue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
validateAndGetImageLink() {
|
validateAndGetImageLink() {
|
||||||
if (imageLink == '') {
|
if (imageLink == '') {
|
||||||
return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg';
|
return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user