Google Maps | Geo Search | unfinished
This commit is contained in:
@@ -48,5 +48,7 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
|
<meta-data android:name="com.google.android.geo.API_KEY"
|
||||||
|
android:value="AIzaSyDAlZSiBanP52qpZ1kaH06XkuA2zndLUd8"/>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:menui_mobile/services.dart';
|
import 'package:menui_mobile/services.dart';
|
||||||
import 'lineOfAllergens.dart';
|
import 'lineOfAllergens.dart';
|
||||||
|
import 'iconChip.dart';
|
||||||
|
|
||||||
class DishView extends StatelessWidget {
|
class DishView extends StatelessWidget {
|
||||||
final Dish dish;
|
final Dish dish;
|
||||||
@@ -22,6 +23,7 @@ class DishView extends StatelessWidget {
|
|||||||
fit: BoxFit.cover),
|
fit: BoxFit.cover),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 160,
|
height: 160,
|
||||||
@@ -32,14 +34,21 @@ class DishView extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[850],
|
color: Colors.grey[850],
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||||
child: Column(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.restaurant,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
dish.name,
|
dish.name,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Colors.orange,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.w300),
|
fontWeight: FontWeight.w300),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -50,26 +59,29 @@ class DishView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Może zawierać',
|
||||||
|
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||||
|
),
|
||||||
Allergens(allergens: dish.allergens),
|
Allergens(allergens: dish.allergens),
|
||||||
Divider(
|
Divider(
|
||||||
height: 14,
|
height: 14,
|
||||||
thickness: 4,
|
thickness: 4,
|
||||||
),
|
),
|
||||||
Text(
|
|
||||||
'Cena',
|
|
||||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
|
||||||
),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 8,
|
||||||
),
|
),
|
||||||
Prices(prices: dish.prices),
|
Prices(prices: dish.prices),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 8,
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
height: 14,
|
height: 14,
|
||||||
thickness: 4,
|
thickness: 4,
|
||||||
),
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 6,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
'Składniki',
|
'Składniki',
|
||||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||||
@@ -82,46 +94,27 @@ class DishView extends StatelessWidget {
|
|||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 6,
|
||||||
),
|
),
|
||||||
Text(
|
Divider(
|
||||||
'Porcja',
|
height: 14,
|
||||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
thickness: 4,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 6,
|
||||||
),
|
),
|
||||||
Text(
|
Wrap(
|
||||||
'${dish.weight}',
|
spacing: 10,
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
children: <Widget>[
|
||||||
),
|
IconChip(
|
||||||
SizedBox(
|
icon: Icons.battery_charging_full,
|
||||||
height: 12,
|
leading: "Wartość energetyczna",
|
||||||
),
|
value: dish.kCal),
|
||||||
Text(
|
IconChip(
|
||||||
'Wartość energetyczna',
|
icon: Icons.cake,
|
||||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
leading: "Indeks glikemiczny",
|
||||||
),
|
value: dish.glicemicIndex),
|
||||||
SizedBox(
|
],
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${dish.kCal}',
|
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Indeks glikemiczny',
|
|
||||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${dish.glicemicIndex}',
|
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
@@ -133,10 +126,26 @@ class DishView extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
Text(
|
if (dish.notes == "")
|
||||||
'${dish.notes}',
|
Text(
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
'---',
|
||||||
),
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
),
|
||||||
|
if (dish.notes != "")
|
||||||
|
Text(
|
||||||
|
'${dish.notes}',
|
||||||
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
),
|
||||||
|
if (dish.vegan)
|
||||||
|
Text(
|
||||||
|
'Danie wegańskie',
|
||||||
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
),
|
||||||
|
if (dish.vegetarian)
|
||||||
|
Text(
|
||||||
|
'Danie wegetariańskie',
|
||||||
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'searchBar.dart';
|
import 'searchBar.dart';
|
||||||
import '../settings.dart';
|
import '../settings.dart';
|
||||||
|
import 'mapView.dart';
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
final MenuiSettings settings = new MenuiSettings();
|
final MenuiSettings settings = new MenuiSettings();
|
||||||
@@ -27,7 +28,8 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
RaisedButton.icon(
|
RaisedButton.icon(
|
||||||
color: Colors.grey[850],
|
color: Colors.grey[850],
|
||||||
onPressed: () {},
|
onPressed: () => Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => MapView())),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.my_location,
|
Icons.my_location,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
|
|||||||
43
lib/components/iconChip.dart
Normal file
43
lib/components/iconChip.dart
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class IconChip extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final String leading;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
IconChip({@required this.icon, @required this.leading, @required this.value});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[800],
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
icon,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'$leading',
|
||||||
|
style: TextStyle(color: Colors.grey[300], fontSize: 11),
|
||||||
|
),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
if (value == "")
|
||||||
|
Text(
|
||||||
|
'brak danych :(',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||||
|
),
|
||||||
|
if (value != "")
|
||||||
|
Text(
|
||||||
|
'$value',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
110
lib/components/mapView.dart
Normal file
110
lib/components/mapView.dart
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import '../services.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
|
class MapView extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<MapView> createState() => MapViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MapViewState extends State<MapView> {
|
||||||
|
Completer<GoogleMapController> _controller = Completer();
|
||||||
|
MenuiServices services = new MenuiServices();
|
||||||
|
Position position;
|
||||||
|
|
||||||
|
Future<Map<MarkerId, Marker>> createMarkers() async {
|
||||||
|
Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
|
||||||
|
Position position = await Geolocator.getCurrentPosition(
|
||||||
|
desiredAccuracy: LocationAccuracy.high);
|
||||||
|
setState(() {
|
||||||
|
position = position;
|
||||||
|
});
|
||||||
|
print('position is set');
|
||||||
|
/* List<Restaurant> restaurants = await services.fetchRestaurantsByLocation(
|
||||||
|
position.latitude, position.longitude, 1000); */
|
||||||
|
List<Restaurant> restaurants =
|
||||||
|
await services.fetchRestaurantsByLocation(20.60912, 52.87728);
|
||||||
|
if (restaurants.isNotEmpty) {
|
||||||
|
for (Restaurant thisRestaurant in restaurants) {
|
||||||
|
final MarkerId markerId = MarkerId(thisRestaurant.name);
|
||||||
|
print(thisRestaurant.name);
|
||||||
|
final Marker marker = Marker(
|
||||||
|
markerId: markerId,
|
||||||
|
position: LatLng(
|
||||||
|
thisRestaurant.coordinates[0], thisRestaurant.coordinates[1]),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: '${thisRestaurant.name}',
|
||||||
|
snippet: 'Kuchnia: ${thisRestaurant.type}'));
|
||||||
|
markers[markerId] = marker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return markers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: FutureBuilder<Map<MarkerId, Marker>>(
|
||||||
|
future: createMarkers(),
|
||||||
|
builder: (BuildContext context,
|
||||||
|
AsyncSnapshot<Map<MarkerId, Marker>> snapshot) {
|
||||||
|
Map<MarkerId, Marker> markers = snapshot.data;
|
||||||
|
List<Widget> children;
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
final CameraPosition _initialPosition = CameraPosition(
|
||||||
|
target: LatLng(20, 58),
|
||||||
|
zoom: 16,
|
||||||
|
);
|
||||||
|
children = <Widget>[
|
||||||
|
GoogleMap(
|
||||||
|
mapType: MapType.normal,
|
||||||
|
initialCameraPosition: _initialPosition,
|
||||||
|
onMapCreated: (GoogleMapController controller) {
|
||||||
|
_controller.complete(controller);
|
||||||
|
},
|
||||||
|
markers: Set<Marker>.of(markers.values),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
children = <Widget>[Text('error')];
|
||||||
|
} else {
|
||||||
|
children = <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
width: 60,
|
||||||
|
height: 60,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 16),
|
||||||
|
child: Text('Awaiting result...'),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
floatingActionButton: Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: 20),
|
||||||
|
child: FloatingActionButton(
|
||||||
|
backgroundColor: Colors.grey[800],
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.arrow_back_outlined,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.startDocked,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* import 'package:flutter/material.dart';
|
|
||||||
import '../services.dart'; */
|
|
||||||
/*
|
|
||||||
class MapWithMarkers extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
62
lib/components/restaurantMapView.dart
Normal file
62
lib/components/restaurantMapView.dart
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
|
||||||
|
class RestaurantMapView extends StatefulWidget {
|
||||||
|
final List coordinates;
|
||||||
|
final String name;
|
||||||
|
final String type;
|
||||||
|
|
||||||
|
RestaurantMapView(
|
||||||
|
{@required this.coordinates, @required this.name, @required this.type});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RestaurantMapView> createState() => RestaurantMapViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class RestaurantMapViewState extends State<RestaurantMapView> {
|
||||||
|
Completer<GoogleMapController> _controller = Completer();
|
||||||
|
Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final CameraPosition _initialPosition = CameraPosition(
|
||||||
|
target: LatLng(widget.coordinates[0], widget.coordinates[1]),
|
||||||
|
zoom: 17,
|
||||||
|
);
|
||||||
|
final MarkerId markerId = MarkerId("restaurant-marker");
|
||||||
|
final Marker marker = Marker(
|
||||||
|
markerId: markerId,
|
||||||
|
position: LatLng(widget.coordinates[0], widget.coordinates[1]),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: '${widget.name}', snippet: 'Kuchnia: ${widget.type}'));
|
||||||
|
setState(() {
|
||||||
|
markers[MarkerId("restaurant-marker")] = marker;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: GoogleMap(
|
||||||
|
mapType: MapType.normal,
|
||||||
|
initialCameraPosition: _initialPosition,
|
||||||
|
onMapCreated: (GoogleMapController controller) {
|
||||||
|
_controller.complete(controller);
|
||||||
|
},
|
||||||
|
markers: Set<Marker>.of(markers.values),
|
||||||
|
),
|
||||||
|
floatingActionButton: Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: 20),
|
||||||
|
child: FloatingActionButton(
|
||||||
|
backgroundColor: Colors.grey[800],
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.arrow_back_outlined,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.startDocked,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import '../services.dart';
|
|||||||
import 'lineOfIcons.dart';
|
import 'lineOfIcons.dart';
|
||||||
import 'dishList.dart';
|
import 'dishList.dart';
|
||||||
import 'socialMedia.dart';
|
import 'socialMedia.dart';
|
||||||
|
import 'restaurantMapView.dart';
|
||||||
|
|
||||||
class RestaurantView extends StatelessWidget {
|
class RestaurantView extends StatelessWidget {
|
||||||
final String id;
|
final String id;
|
||||||
@@ -78,7 +79,16 @@ class RestaurantView extends StatelessWidget {
|
|||||||
Icons.map,
|
Icons.map,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
),
|
),
|
||||||
onPressed: () {}),
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
RestaurantMapView(
|
||||||
|
coordinates:
|
||||||
|
restaurant.coordinates,
|
||||||
|
name: restaurant.name,
|
||||||
|
type: restaurant.type,
|
||||||
|
)))),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ class MenuiSearchBarState extends State<MenuiSearchBar> {
|
|||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
print('12345');
|
|
||||||
if (!currentFocus.hasPrimaryFocus) {
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
currentFocus.unfocus();
|
currentFocus.unfocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import './settings.dart';
|
||||||
|
|
||||||
class MenuiServices {
|
class MenuiServices {
|
||||||
final String backendURL = 'https://api.menui.pl/';
|
final String backendURL = 'https://api.menui.pl/';
|
||||||
|
final MenuiSettings settings = new MenuiSettings();
|
||||||
|
|
||||||
Future<List<String>> fetchAutocomplete(String text) async {
|
Future<List<String>> fetchAutocomplete(String text) async {
|
||||||
final response =
|
final response =
|
||||||
@@ -113,7 +115,7 @@ class MenuiServices {
|
|||||||
city: decoded['city'],
|
city: decoded['city'],
|
||||||
adress: decoded['adress'],
|
adress: decoded['adress'],
|
||||||
type: decoded['type'],
|
type: decoded['type'],
|
||||||
coordinates: decoded['coordinates'],
|
coordinates: decoded['location']['coordinates'],
|
||||||
phone: decoded['phone'],
|
phone: decoded['phone'],
|
||||||
imgUrl: decoded['imgUrl'],
|
imgUrl: decoded['imgUrl'],
|
||||||
placesId: decoded['placesId'],
|
placesId: decoded['placesId'],
|
||||||
@@ -140,11 +142,69 @@ class MenuiServices {
|
|||||||
lunchHours: decoded['lunchHours'],
|
lunchHours: decoded['lunchHours'],
|
||||||
lunchMenu: lunchMenu,
|
lunchMenu: lunchMenu,
|
||||||
dishes: decoded['dishes']);
|
dishes: decoded['dishes']);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Restaurant>> fetchRestaurantsByLocation(
|
||||||
|
double lat, double lng) async {
|
||||||
|
final radius = await settings.getRadius();
|
||||||
|
final response = await http
|
||||||
|
.get('${backendURL}search/location?lon=$lng&lat=$lat&radius=$radius');
|
||||||
|
if (response.statusCode == 200 || response.statusCode == 304) {
|
||||||
|
final List decoded = jsonDecode(response.body);
|
||||||
|
List<Restaurant> results = [];
|
||||||
|
for (var restaurant in decoded) {
|
||||||
|
final workingHours = restaurant['workingHours'];
|
||||||
|
final tags = restaurant['tags'];
|
||||||
|
final List responseLunchMenu = restaurant['lunchMenu'];
|
||||||
|
List<MenuiLunchMenuSet> lunchMenu = [];
|
||||||
|
if (responseLunchMenu != null) {
|
||||||
|
for (var lunchSet in responseLunchMenu) {
|
||||||
|
final MenuiLunchMenuSet thisSet = new MenuiLunchMenuSet(
|
||||||
|
lunchSet['lunchSetName'],
|
||||||
|
lunchSet['lunchSetPrice'],
|
||||||
|
lunchSet['lunchSetDishes']);
|
||||||
|
lunchMenu.add(thisSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final result = new Restaurant(
|
||||||
|
id: restaurant['_id'],
|
||||||
|
name: restaurant['name'],
|
||||||
|
city: restaurant['city'],
|
||||||
|
adress: restaurant['adress'],
|
||||||
|
type: restaurant['type'],
|
||||||
|
coordinates: restaurant['location']['coordinates'],
|
||||||
|
imgUrl: restaurant['imgUrl'],
|
||||||
|
placesId: restaurant['placesId'],
|
||||||
|
workingHours: new MenuiWorkingHours(
|
||||||
|
workingHours['pn'],
|
||||||
|
workingHours['wt'],
|
||||||
|
workingHours['sr'],
|
||||||
|
workingHours['cz'],
|
||||||
|
workingHours['pt'],
|
||||||
|
workingHours['sb'],
|
||||||
|
workingHours['nd']),
|
||||||
|
description: restaurant['description'],
|
||||||
|
tags: new MenuiTags(
|
||||||
|
tags['cardPayments'],
|
||||||
|
tags['petFriendly'],
|
||||||
|
tags['glutenFree'],
|
||||||
|
tags['vegan'],
|
||||||
|
tags['vegetarian'],
|
||||||
|
tags['alcohol'],
|
||||||
|
tags['delivery']),
|
||||||
|
lunchHours: restaurant['lunchHours'],
|
||||||
|
lunchMenu: lunchMenu,
|
||||||
|
dishes: restaurant['dishes']);
|
||||||
|
results.add(result);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Restaurant>> fetchSearchByString(String text) async {
|
Future<List<Restaurant>> fetchSearchByString(String text) async {
|
||||||
final response = await http.get('${backendURL}search?string=$text');
|
final response = await http.get('${backendURL}search?string=$text');
|
||||||
if (response.statusCode == 200 || response.statusCode == 304) {
|
if (response.statusCode == 200 || response.statusCode == 304) {
|
||||||
@@ -313,6 +373,15 @@ class Dish {
|
|||||||
this.vegetarian});
|
this.vegetarian});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MenuiMarker {
|
||||||
|
final List coordinates;
|
||||||
|
final String title;
|
||||||
|
final String type;
|
||||||
|
|
||||||
|
MenuiMarker(
|
||||||
|
{@required this.coordinates, @required this.title, @required this.type});
|
||||||
|
}
|
||||||
|
|
||||||
class MenuiPrices {
|
class MenuiPrices {
|
||||||
MenuiPrice price1;
|
MenuiPrice price1;
|
||||||
MenuiPrice price2;
|
MenuiPrice price2;
|
||||||
|
|||||||
30
pubspec.lock
30
pubspec.lock
@@ -76,6 +76,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.11"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -107,6 +114,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
|
google_maps_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: google_maps_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.6"
|
||||||
|
google_maps_flutter_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_maps_flutter_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.5"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -266,6 +287,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.1"
|
version: "2.1.0-nullsafety.1"
|
||||||
|
stream_transform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stream_transform
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -317,4 +345,4 @@ packages:
|
|||||||
version: "0.1.2"
|
version: "0.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.10.0-110 <2.11.0"
|
dart: ">=2.10.0-110 <2.11.0"
|
||||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
flutter: ">=1.22.0 <2.0.0"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
shared_preferences: ^0.5.12
|
shared_preferences: ^0.5.12
|
||||||
|
google_maps_flutter: ^1.0.6
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|||||||
Reference in New Issue
Block a user