Google Maps | Geo Search | unfinished
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:menui_mobile/services.dart';
|
||||
import 'lineOfAllergens.dart';
|
||||
import 'iconChip.dart';
|
||||
|
||||
class DishView extends StatelessWidget {
|
||||
final Dish dish;
|
||||
@@ -22,6 +23,7 @@ class DishView extends StatelessWidget {
|
||||
fit: BoxFit.cover),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 160,
|
||||
@@ -32,14 +34,21 @@ class DishView extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[850],
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.restaurant,
|
||||
color: Colors.orange,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text(
|
||||
dish.name,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.orange,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w300),
|
||||
),
|
||||
],
|
||||
@@ -50,26 +59,29 @@ class DishView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
'Może zawierać',
|
||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||
),
|
||||
Allergens(allergens: dish.allergens),
|
||||
Divider(
|
||||
height: 14,
|
||||
thickness: 4,
|
||||
),
|
||||
Text(
|
||||
'Cena',
|
||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
height: 8,
|
||||
),
|
||||
Prices(prices: dish.prices),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
height: 8,
|
||||
),
|
||||
Divider(
|
||||
height: 14,
|
||||
thickness: 4,
|
||||
),
|
||||
SizedBox(
|
||||
height: 6,
|
||||
),
|
||||
Text(
|
||||
'Składniki',
|
||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||
@@ -82,46 +94,27 @@ class DishView extends StatelessWidget {
|
||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
height: 6,
|
||||
),
|
||||
Text(
|
||||
'Porcja',
|
||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||
Divider(
|
||||
height: 14,
|
||||
thickness: 4,
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
height: 6,
|
||||
),
|
||||
Text(
|
||||
'${dish.weight}',
|
||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Text(
|
||||
'Wartość energetyczna',
|
||||
style: TextStyle(color: Colors.orange, fontSize: 14),
|
||||
),
|
||||
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),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: <Widget>[
|
||||
IconChip(
|
||||
icon: Icons.battery_charging_full,
|
||||
leading: "Wartość energetyczna",
|
||||
value: dish.kCal),
|
||||
IconChip(
|
||||
icon: Icons.cake,
|
||||
leading: "Indeks glikemiczny",
|
||||
value: dish.glicemicIndex),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
@@ -133,10 +126,26 @@ class DishView extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Text(
|
||||
'${dish.notes}',
|
||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||
),
|
||||
if (dish.notes == "")
|
||||
Text(
|
||||
'---',
|
||||
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 'searchBar.dart';
|
||||
import '../settings.dart';
|
||||
import 'mapView.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
final MenuiSettings settings = new MenuiSettings();
|
||||
@@ -27,7 +28,8 @@ class HomePage extends StatelessWidget {
|
||||
),
|
||||
RaisedButton.icon(
|
||||
color: Colors.grey[850],
|
||||
onPressed: () {},
|
||||
onPressed: () => Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => MapView())),
|
||||
icon: Icon(
|
||||
Icons.my_location,
|
||||
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 'dishList.dart';
|
||||
import 'socialMedia.dart';
|
||||
import 'restaurantMapView.dart';
|
||||
|
||||
class RestaurantView extends StatelessWidget {
|
||||
final String id;
|
||||
@@ -78,7 +79,16 @@ class RestaurantView extends StatelessWidget {
|
||||
Icons.map,
|
||||
color: Colors.orange,
|
||||
),
|
||||
onPressed: () {}),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
RestaurantMapView(
|
||||
coordinates:
|
||||
restaurant.coordinates,
|
||||
name: restaurant.name,
|
||||
type: restaurant.type,
|
||||
)))),
|
||||
)
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
||||
@@ -78,7 +78,6 @@ class MenuiSearchBarState extends State<MenuiSearchBar> {
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
print('12345');
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.unfocus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user