Version 1.0.0 (first build)

This commit is contained in:
2021-01-12 18:29:25 +01:00
parent 8307ea9215
commit b1320b876e
15 changed files with 803 additions and 235 deletions

13
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,13 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "menui_mobile",
"request": "launch",
"type": "dart"
}
]
}

View File

@@ -26,6 +26,14 @@ class DishCard extends StatelessWidget {
width: 80, width: 80,
height: 80, height: 80,
fit: BoxFit.cover, fit: BoxFit.cover,
errorBuilder: (BuildContext context, Object exception,
StackTrace stackTrace) {
return Container(
width: 80,
height: 80,
decoration: BoxDecoration(color: Colors.grey[900]),
);
},
), ),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(12), bottomLeft: Radius.circular(12),
@@ -41,11 +49,15 @@ class DishCard extends StatelessWidget {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Expanded(
dish.name, flex: 0,
overflow: TextOverflow.ellipsis, child: Text(
maxLines: 1, dish.name,
style: TextStyle(color: Colors.orange[600], fontSize: 15), overflow: TextOverflow.ellipsis,
maxLines: 1,
style:
TextStyle(color: Colors.orange[600], fontSize: 15),
),
), ),
Text( Text(
dish.weight, dish.weight,
@@ -55,7 +67,9 @@ class DishCard extends StatelessWidget {
), ),
], ],
), ),
Prices(prices: dish.prices) Expanded(
child: Prices(prices: dish.prices),
)
], ],
)), )),
Container( Container(
@@ -85,21 +99,25 @@ class Prices extends StatelessWidget {
if (prices.price1.priceName == "") if (prices.price1.priceName == "")
Text( Text(
'${prices.price1.price}', '${prices.price1.price}',
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 14), style: TextStyle(color: Colors.white, fontSize: 14),
), ),
if (prices.price1.priceName != "") if (prices.price1.priceName != "")
Text( Text(
'${prices.price1.priceName}: ${prices.price1.price}', '${prices.price1.priceName}: ${prices.price1.price}',
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 14), style: TextStyle(color: Colors.white, fontSize: 14),
), ),
if (prices.price2.priceName != "") if (prices.price2.priceName != "")
Text( Text(
'${prices.price2.priceName}: ${prices.price2.price}', '${prices.price2.priceName}: ${prices.price2.price}',
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 14), style: TextStyle(color: Colors.white, fontSize: 14),
), ),
if (prices.price3.priceName != "") if (prices.price3.priceName != "")
Text( Text(
'${prices.price3.priceName}: ${prices.price3.price}', '${prices.price3.priceName}: ${prices.price3.price}',
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 14), style: TextStyle(color: Colors.white, fontSize: 14),
), ),
], ],

View File

@@ -0,0 +1,132 @@
import 'package:flutter/material.dart';
import 'package:menui_mobile/settings.dart';
import '../services.dart';
import 'dishView.dart';
class DishCardAsync extends StatelessWidget {
final OrderItem item;
final Function onRemoved;
final services = new MenuiServices();
final settings = new MenuiSettings();
final int index;
DishCardAsync({@required this.item, this.onRemoved, this.index});
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: Card(
color: Colors.grey[850],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
margin: EdgeInsets.only(left: 12, top: 5, bottom: 5),
child: FutureBuilder(
future: services.fetchDish(item.id),
builder: (context, snapshot) {
if (snapshot.hasData) {
Dish dish = snapshot.data;
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DishView(dish: dish))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: Text(
'${item.quantity}x',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600),
),
),
),
Container(
child: ClipRRect(
child: Image.network(
dish.imgUrl,
width: 80,
height: 80,
fit: BoxFit.cover,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(12),
topLeft: Radius.circular(12)),
),
padding: EdgeInsets.only(right: 8),
),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 0,
child: Text(
dish.name,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Colors.orange[600],
fontSize: 15),
),
),
if (item.priceName.isNotEmpty)
Text(
item.priceName,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Colors.white, fontSize: 12),
)
],
),
Padding(
padding: EdgeInsets.only(right: 12),
child: Text(
'${item.price}',
style: TextStyle(
color: Colors.white, fontSize: 13),
),
)
],
)),
],
),
);
} else {
return Center(
child: Padding(
padding: EdgeInsets.all(24),
child: CircularProgressIndicator(),
),
);
}
},
)),
),
Expanded(
flex: 0,
child: IconButton(
icon: Icon(
Icons.delete_rounded,
color: Colors.white,
),
onPressed: () {
settings.removeFromOrder(index);
onRemoved();
},
),
)
],
);
}
}

View File

@@ -13,10 +13,22 @@ class DishView extends StatelessWidget {
final Dish dish; final Dish dish;
DishView({@required this.dish}); DishView({@required this.dish});
final MenuiSettings settings = new MenuiSettings(); final MenuiSettings settings = new MenuiSettings();
final SnackBar snackbarAdded = new SnackBar(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
backgroundColor: Colors.orange,
duration: Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
content: Text(
"Dodano do zamówienia :)",
style: TextStyle(color: Colors.grey[850]),
),
);
final _scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
key: _scaffoldKey,
body: Container( body: Container(
decoration: BoxDecoration(color: Colors.grey[850]), decoration: BoxDecoration(color: Colors.grey[850]),
child: ListView( child: ListView(
@@ -260,7 +272,17 @@ class DishView extends StatelessWidget {
icon: Icons.note_add_rounded, icon: Icons.note_add_rounded,
text: "Do zamówienia", text: "Do zamówienia",
onPressed: () { onPressed: () {
settings.addToOrder(dish.id); showDialog(
context: context,
builder: (context) {
return AddToOrderDialog(
dish: dish,
onSubmit: () {
_scaffoldKey.currentState.showSnackBar(snackbarAdded);
Navigator.pop(context);
},
);
});
}, },
), ),
], ],
@@ -269,6 +291,245 @@ class DishView extends StatelessWidget {
} }
} }
class AddToOrderDialog extends StatefulWidget {
final Dish dish;
final Function onSubmit;
final MenuiSettings settings = new MenuiSettings();
AddToOrderDialog({@required this.dish, @required this.onSubmit});
@override
State<AddToOrderDialog> createState() => AddToOrderDialogState();
}
class AddToOrderDialogState extends State<AddToOrderDialog> {
int quantity = 1;
String price;
String priceName;
int selectedVariant = 1;
@override
void initState() {
super.initState();
price = widget.dish.prices.price1.price;
priceName = widget.dish.prices.price1.priceName;
}
@override
Widget build(BuildContext context) {
return SimpleDialog(
title: Text(
'Dodaj do zamówienia',
style: TextStyle(color: Colors.white, fontSize: 16),
textAlign: TextAlign.center,
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
backgroundColor: Colors.grey[850],
children: [
Text(
'Ilość',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
iconSize: 16,
icon: Icon(
Icons.remove,
color: Colors.white,
),
onPressed: () {
if (quantity > 1) {
setState(() {
quantity = quantity - 1;
});
}
},
),
Text(
"$quantity",
style: TextStyle(color: Colors.orange, fontSize: 16),
),
IconButton(
iconSize: 16,
icon: Icon(
Icons.add,
color: Colors.white,
),
onPressed: () {
setState(() {
quantity = quantity + 1;
});
},
)
],
),
if (widget.dish.prices.price1.priceName != "")
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text(
'Wariant',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
),
if (widget.dish.prices.price1.priceName != "")
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(4),
child: ButtonTheme(
minWidth: 20,
child: RaisedButton(
onPressed: () {
setState(() {
selectedVariant = 1;
price = widget.dish.prices.price1.price;
priceName = widget.dish.prices.price1.priceName;
});
},
color: (() {
if (selectedVariant == 1) {
return Colors.grey[600];
} else {
return Colors.grey[800];
}
}()),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14)),
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 12, horizontal: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'(${widget.dish.prices.price1.priceName})',
style:
TextStyle(color: Colors.white, fontSize: 11),
),
Text(
'${widget.dish.prices.price1.price}',
style:
TextStyle(color: Colors.white, fontSize: 14),
),
]),
),
),
),
),
Padding(
padding: EdgeInsets.all(4),
child: ButtonTheme(
minWidth: 20,
child: RaisedButton(
onPressed: () {
setState(() {
selectedVariant = 2;
price = widget.dish.prices.price2.price;
priceName = widget.dish.prices.price2.priceName;
});
},
color: (() {
if (selectedVariant == 2) {
return Colors.grey[600];
} else {
return Colors.grey[800];
}
}()),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14)),
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 12, horizontal: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'(${widget.dish.prices.price2.priceName})',
style:
TextStyle(color: Colors.white, fontSize: 11),
),
Text(
'${widget.dish.prices.price2.price}',
style:
TextStyle(color: Colors.white, fontSize: 14),
),
]),
),
),
),
),
Padding(
padding: EdgeInsets.all(4),
child: ButtonTheme(
minWidth: 20,
child: RaisedButton(
onPressed: () {
setState(() {
selectedVariant = 3;
price = widget.dish.prices.price3.price;
priceName = widget.dish.prices.price3.priceName;
});
},
color: (() {
if (selectedVariant == 3) {
return Colors.grey[600];
} else {
return Colors.grey[800];
}
}()),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14)),
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 12, horizontal: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'(${widget.dish.prices.price3.priceName})',
style:
TextStyle(color: Colors.white, fontSize: 11),
),
Text(
'${widget.dish.prices.price3.price}',
style:
TextStyle(color: Colors.white, fontSize: 14),
),
]),
),
),
),
)
],
),
Padding(
padding: EdgeInsets.only(top: 12),
child: Center(
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14)),
onPressed: () {
widget.settings.addToOrder(new OrderItem(
id: widget.dish.id,
quantity: quantity,
price: price,
priceName: priceName));
widget.onSubmit();
},
child: Text('Dodaj'),
),
),
)
],
);
}
}
class Prices extends StatelessWidget { class Prices extends StatelessWidget {
final MenuiPrices prices; final MenuiPrices prices;

View File

@@ -43,7 +43,10 @@ class _FavoritesViewState extends State<FavoritesView> {
}, },
); );
} else { } else {
return null; return Container(
width: 0,
height: 0,
);
} }
}, },
)), )),

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:menui_mobile/services.dart';
enum Tags { enum Tags {
cardPayments, cardPayments,
@@ -11,13 +12,7 @@ enum Tags {
} }
class Filters { class Filters {
bool cardPayments = false; List<Tags> tags = [];
bool petFriendly = false;
bool glutenFree = false;
bool vegan = false;
bool vegetarian = false;
bool alcohol = false;
bool delivery = false;
bool onlyOpen = false; bool onlyOpen = false;
List<String> selectedTypes = []; List<String> selectedTypes = [];
final List<String> availableTypes = [ final List<String> availableTypes = [
@@ -43,6 +38,41 @@ class Filters {
'mieszane', 'mieszane',
'inna' 'inna'
]; ];
List<Restaurant> filterByTypes(
List<Restaurant> restaurants, List<String> types) {
if (types.isEmpty) {
return restaurants;
} else {
List<Restaurant> result = restaurants.where((restaurant) {
return types.contains(restaurant.type);
}).toList();
return result;
}
}
List<Restaurant> filterByTags(List<Restaurant> restaurants, Filters filters) {
if (filters.tags.isEmpty) {
return restaurants;
} else {
List<Restaurant> result = [];
restaurants.forEach((restaurant) => {
if (filters.tags.every((tag) {
return restaurant.tags.contains(tag);
}))
{result.add(restaurant)}
});
return result;
}
}
List<Restaurant> filterRestaurants(
List<Restaurant> restaurants, Filters filters) {
List<Restaurant> result = [];
result = filterByTypes(restaurants, filters.selectedTypes);
result = filterByTags(result, filters);
return result;
}
} }
class RestaurantFilters extends StatelessWidget { class RestaurantFilters extends StatelessWidget {
@@ -112,45 +142,52 @@ class RestaurantFilters extends StatelessWidget {
children: [ children: [
RestaurantTag( RestaurantTag(
name: "Płatność kartą", name: "Płatność kartą",
active: filters.cardPayments,
img: 'img/i_card_black.png', img: 'img/i_card_black.png',
onTapped: () => onSelectTag(Tags.cardPayments), onTapped: () => onSelectTag(Tags.cardPayments),
filters: filters,
filterTag: Tags.cardPayments,
), ),
RestaurantTag( RestaurantTag(
name: "Lubimy zwierzaki", name: "Lubimy zwierzaki",
active: filters.petFriendly,
img: 'img/i_pets_black.png', img: 'img/i_pets_black.png',
onTapped: () => onSelectTag(Tags.petFriendly), onTapped: () => onSelectTag(Tags.petFriendly),
filters: filters,
filterTag: Tags.petFriendly,
), ),
RestaurantTag( RestaurantTag(
name: "Bez glutenu", name: "Bez glutenu",
active: filters.glutenFree,
img: 'img/i_glutenFree_black.png', img: 'img/i_glutenFree_black.png',
onTapped: () => onSelectTag(Tags.glutenFree), onTapped: () => onSelectTag(Tags.glutenFree),
filters: filters,
filterTag: Tags.glutenFree,
), ),
RestaurantTag( RestaurantTag(
name: "Wegańskie", name: "Wegańskie",
active: filters.vegan,
img: 'img/i_vegan_black.png', img: 'img/i_vegan_black.png',
onTapped: () => onSelectTag(Tags.vegan), onTapped: () => onSelectTag(Tags.vegan),
filters: filters,
filterTag: Tags.vegan,
), ),
RestaurantTag( RestaurantTag(
name: "Wegetariańskie", name: "Wegetariańskie",
active: filters.vegetarian,
img: 'img/i_vegetarian_black.png', img: 'img/i_vegetarian_black.png',
onTapped: () => onSelectTag(Tags.vegetarian), onTapped: () => onSelectTag(Tags.vegetarian),
filters: filters,
filterTag: Tags.vegetarian,
), ),
RestaurantTag( RestaurantTag(
name: "Alkohol", name: "Alkohol",
active: filters.alcohol,
img: 'img/i_alcohol_black.png', img: 'img/i_alcohol_black.png',
onTapped: () => onSelectTag(Tags.alcohol), onTapped: () => onSelectTag(Tags.alcohol),
filters: filters,
filterTag: Tags.alcohol,
), ),
RestaurantTag( RestaurantTag(
name: "Dowozimy", name: "Dowozimy",
active: filters.delivery,
img: 'img/i_delivery_black.png', img: 'img/i_delivery_black.png',
onTapped: () => onSelectTag(Tags.delivery), onTapped: () => onSelectTag(Tags.delivery),
filters: filters,
filterTag: Tags.delivery,
), ),
], ],
) )
@@ -163,13 +200,20 @@ class RestaurantFilters extends StatelessWidget {
class RestaurantTag extends StatelessWidget { class RestaurantTag extends StatelessWidget {
final String name; final String name;
final String img; final String img;
final bool active;
final Function onTapped; final Function onTapped;
final Filters filters;
final Tags filterTag;
RestaurantTag({this.name, this.active, this.img, this.onTapped}); RestaurantTag(
{this.name, this.img, this.onTapped, this.filters, this.filterTag});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool active = false;
if (filters.tags.contains(filterTag)) {
active = true;
}
return ButtonTheme( return ButtonTheme(
height: 26, height: 26,
minWidth: 60, minWidth: 60,

View File

@@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../services.dart'; import 'filters.dart';
class LineOfIcons extends StatelessWidget { class LineOfIcons extends StatelessWidget {
final MenuiTags tags; final List<Tags> tags;
final double edgeInsets = 3; final double edgeInsets = 3;
final double imagesWidth = 14; final double imagesWidth = 14;
final double fontSize = 8; final double fontSize = 8;
@@ -17,7 +17,7 @@ class LineOfIcons extends StatelessWidget {
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
direction: Axis.horizontal, direction: Axis.horizontal,
children: <Widget>[ children: <Widget>[
if (tags.alcohol == true) if (tags.contains(Tags.alcohol))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -38,7 +38,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.cardPayments == true) if (tags.contains(Tags.cardPayments))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -65,7 +65,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.delivery == true) if (tags.contains(Tags.delivery))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -86,7 +86,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.glutenFree == true) if (tags.contains(Tags.glutenFree))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -107,7 +107,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.petFriendly == true) if (tags.contains(Tags.petFriendly))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -133,7 +133,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.vegan == true) if (tags.contains(Tags.vegan))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
@@ -154,7 +154,7 @@ class LineOfIcons extends StatelessWidget {
) )
], ],
)), )),
if (tags.vegetarian == true) if (tags.contains(Tags.vegetarian))
Container( Container(
margin: EdgeInsets.all(edgeInsets), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(

View File

@@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../services.dart'; import 'filters.dart';
class LineOfIconsSmall extends StatelessWidget { class LineOfIconsSmall extends StatelessWidget {
final MenuiTags tags; final List<Tags> tags;
LineOfIconsSmall({@required this.tags}); LineOfIconsSmall({@required this.tags});
@@ -12,7 +12,7 @@ class LineOfIconsSmall extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
if (tags.alcohol == true) if (tags.contains(Tags.alcohol))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -27,7 +27,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.cardPayments == true) if (tags.contains(Tags.cardPayments))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -42,7 +42,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.delivery == true) if (tags.contains(Tags.delivery))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -57,7 +57,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.glutenFree == true) if (tags.contains(Tags.glutenFree))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -72,7 +72,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.petFriendly == true) if (tags.contains(Tags.petFriendly))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -87,7 +87,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.vegan == true) if (tags.contains(Tags.vegan))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(
@@ -102,7 +102,7 @@ class LineOfIconsSmall extends StatelessWidget {
), ),
], ],
)), )),
if (tags.vegetarian == true) if (tags.contains(Tags.vegetarian))
Container( Container(
margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), margin: EdgeInsets.only(top: 4, bottom: 4, right: 9),
child: Column( child: Column(

View File

@@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:menui_mobile/components/filters.dart';
import 'package:menui_mobile/settings.dart'; import 'package:menui_mobile/settings.dart';
import '../services.dart'; import '../services.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
@@ -14,19 +15,54 @@ class MapView extends StatefulWidget {
State<MapView> createState() => MapViewState(); State<MapView> createState() => MapViewState();
} }
class MapViewState extends State<MapView> { class MapViewState extends State<MapView> with SingleTickerProviderStateMixin {
Filters filters = new Filters();
Completer<GoogleMapController> _controller = Completer(); Completer<GoogleMapController> _controller = Completer();
bool expand;
AnimationController animationController;
Animation<double> animation;
MenuiServices services = new MenuiServices(); MenuiServices services = new MenuiServices();
final MenuiSettings settings = new MenuiSettings(); final MenuiSettings settings = new MenuiSettings();
Position position; Position position;
void prepareAnimations() {
animationController =
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
animation = CurvedAnimation(
parent: animationController, curve: Curves.fastOutSlowIn);
}
void checkExpand() {
if (expand) {
animationController.forward();
} else {
animationController.reverse();
}
}
@override
void initState() {
super.initState();
expand = false;
prepareAnimations();
checkExpand();
}
@override
void dispose() {
animationController.dispose();
super.dispose();
}
Future<MarkersAndLocation> createMarkers() async { Future<MarkersAndLocation> createMarkers() async {
Map<MarkerId, Marker> markers = <MarkerId, Marker>{}; Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
Position position = await Geolocator.getCurrentPosition( Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high); desiredAccuracy: LocationAccuracy.high);
LatLng location = new LatLng(position.latitude, position.longitude); LatLng location = new LatLng(position.latitude, position.longitude);
List<Restaurant> restaurants = await services.fetchRestaurantsByLocation( List<Restaurant> fetchedRestaurants = await services
position.latitude, position.longitude); .fetchRestaurantsByLocation(position.latitude, position.longitude);
List<Restaurant> restaurants =
filters.filterRestaurants(fetchedRestaurants, filters);
if (restaurants.isNotEmpty) { if (restaurants.isNotEmpty) {
for (Restaurant thisRestaurant in restaurants) { for (Restaurant thisRestaurant in restaurants) {
final MarkerId markerId = MarkerId(thisRestaurant.name); final MarkerId markerId = MarkerId(thisRestaurant.name);
@@ -51,6 +87,7 @@ class MapViewState extends State<MapView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
checkExpand();
return Scaffold( return Scaffold(
body: FutureBuilder<MarkersAndLocation>( body: FutureBuilder<MarkersAndLocation>(
future: createMarkers(), future: createMarkers(),
@@ -107,7 +144,10 @@ class MapViewState extends State<MapView> {
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 12, horizontal: 4), vertical: 12, horizontal: 4),
onPressed: () { onPressed: () {
Navigator.pop(context); showRadiusSelectionDialog(context, settings,
() {
setState(() {});
});
}, },
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -120,13 +160,22 @@ class MapViewState extends State<MapView> {
'Promień', 'Promień',
style: TextStyle( style: TextStyle(
color: Colors.grey[200], color: Colors.grey[200],
fontSize: 12, fontSize: 11,
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
), ),
Text( FutureBuilder(
'600m', future: settings.getRadius(),
style: TextStyle( builder: (context, snapshot) {
color: Colors.grey, fontSize: 10), if (snapshot.hasData) {
return Text(
'${snapshot.data}m',
style: TextStyle(
color: Colors.grey, fontSize: 10),
);
} else {
return null;
}
},
) )
], ],
), ),
@@ -137,37 +186,9 @@ class MapViewState extends State<MapView> {
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 12, horizontal: 4), vertical: 12, horizontal: 4),
onPressed: () { onPressed: () {
Navigator.pop(context); setState(() {
}, expand = !expand;
child: Column( });
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(
Icons.map_rounded,
color: Colors.orange,
),
Text(
'Kuchnia',
style: TextStyle(
color: Colors.grey[200],
fontSize: 12,
fontWeight: FontWeight.w400),
),
Text(
'Wszystkie',
style: TextStyle(
color: Colors.grey, fontSize: 10),
)
],
),
),
RaisedButton(
color: Colors.grey[900],
elevation: 0,
padding: EdgeInsets.symmetric(
vertical: 12, horizontal: 4),
onPressed: () {
Navigator.pop(context);
}, },
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -180,20 +201,49 @@ class MapViewState extends State<MapView> {
'Filtry', 'Filtry',
style: TextStyle( style: TextStyle(
color: Colors.grey[200], color: Colors.grey[200],
fontSize: 12, fontSize: 11,
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
), ),
Text(
'Brak',
style: TextStyle(
color: Colors.grey, fontSize: 10),
)
], ],
), ),
), ),
], ],
), ),
), ),
SizeTransition(
sizeFactor: animation,
child: RestaurantFilters(
filters: filters,
onSelectType: (value) {
if (filters.selectedTypes.contains(value)) {
final List<String> result =
List.from(filters.selectedTypes);
result.remove(value);
setState(() {
filters.selectedTypes = result;
});
} else {
final List<String> result =
List.from(filters.selectedTypes);
result.add(value);
setState(() {
filters.selectedTypes = result;
});
}
},
onSelectTag: (tag) {
List<Tags> result = List<Tags>.from(filters.tags);
if (filters.tags.contains(tag)) {
result.remove(tag);
} else {
result.add(tag);
}
setState(() {
filters.tags = result;
});
},
),
),
Container( Container(
decoration: BoxDecoration(color: Colors.grey[800]), decoration: BoxDecoration(color: Colors.grey[800]),
child: Row( child: Row(

View File

@@ -1,12 +1,18 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:menui_mobile/components/dishCardAsync.dart';
import '../settings.dart'; import '../settings.dart';
import 'homeScreen.dart'; import 'homeScreen.dart';
import 'favoritesView.dart'; import 'favoritesView.dart';
import 'menuiButton.dart'; import 'menuiButton.dart';
class OrderView extends StatelessWidget { class OrderView extends StatefulWidget {
final settings = new MenuiSettings(); final settings = new MenuiSettings();
@override
State<OrderView> createState() => OrderViewState();
}
class OrderViewState extends State<OrderView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -16,21 +22,46 @@ class OrderView extends StatelessWidget {
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)), image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( FutureBuilder(
decoration: BoxDecoration(color: Colors.grey[800]), future: widget.settings.getOrder(),
child: Row( builder: (context, snapshot) {
mainAxisAlignment: MainAxisAlignment.center, if (snapshot.hasData) {
children: [ List<OrderItem> order = snapshot.data;
Icon( if (order.isNotEmpty) {
Icons.attach_money_rounded, return Expanded(
color: Colors.orange, child: ListView.builder(
), itemCount: order.length,
Text( itemBuilder: (context, index) {
'Suma: 0zł', return DishCardAsync(
style: TextStyle(color: Colors.white, fontSize: 12), item: order[index],
), index: index,
], onRemoved: () {
), setState(() {});
},
);
},
),
);
} else {
return Container(
child: Center(
child: Padding(
padding: EdgeInsets.only(top: 50),
child: Text(
"Zamówienie jest puste.",
style: TextStyle(color: Colors.grey),
),
)),
);
}
} else {
return Container(
child: Center(
child: CircularProgressIndicator(),
),
);
}
},
) )
], ],
), ),
@@ -66,7 +97,7 @@ class OrderView extends StatelessWidget {
icon: Icons.settings, icon: Icons.settings,
text: "Ustawienia", text: "Ustawienia",
onPressed: () { onPressed: () {
showSettings(context, settings); showSettings(context, widget.settings);
}, },
), ),
], ],
@@ -75,8 +106,7 @@ class OrderView extends StatelessWidget {
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
'Zamówienie', 'Zamówienie',
style: TextStyle( style: TextStyle(color: Colors.white, fontWeight: FontWeight.w400),
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 14),
), ),
backgroundColor: Colors.grey[900], backgroundColor: Colors.grey[900],
leading: IconButton( leading: IconButton(
@@ -90,7 +120,8 @@ class OrderView extends StatelessWidget {
MenuiButton( MenuiButton(
color: Colors.orange, color: Colors.orange,
onPressed: () { onPressed: () {
settings.clearOrder(); widget.settings.clearOrder();
setState(() {});
}, },
text: "Wyczyść", text: "Wyczyść",
icon: Icons.delete_forever_rounded, icon: Icons.delete_forever_rounded,

View File

@@ -128,7 +128,10 @@ class RestaurantCardAsync extends StatelessWidget {
)); ));
} else { } else {
return Center( return Center(
child: CircularProgressIndicator(), child: Padding(
padding: EdgeInsets.all(24),
child: CircularProgressIndicator(),
),
); );
} }
}, },

View File

@@ -27,13 +27,11 @@ class _RestaurantViewState extends State<RestaurantView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<String> categories = [];
return FutureBuilder<Restaurant>( return FutureBuilder<Restaurant>(
future: services.fetchRestaurant(widget.id), future: services.fetchRestaurant(widget.id),
builder: (BuildContext context, AsyncSnapshot<Restaurant> snapshot) { builder: (BuildContext context, AsyncSnapshot<Restaurant> snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
restaurant = snapshot.data; restaurant = snapshot.data;
categories = restaurant.categories;
return Scaffold( return Scaffold(
body: Container( body: Container(
decoration: BoxDecoration(color: Colors.grey[850]), decoration: BoxDecoration(color: Colors.grey[850]),

View File

@@ -24,7 +24,6 @@ class SearchResults extends StatefulWidget {
class _SearchResultsState extends State<SearchResults> class _SearchResultsState extends State<SearchResults>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
GlobalKey<ScaffoldState> _drawerKey = GlobalKey();
bool expand; bool expand;
AnimationController animationController; AnimationController animationController;
Animation<double> animation; Animation<double> animation;
@@ -62,8 +61,9 @@ class _SearchResultsState extends State<SearchResults>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
checkExpand(); checkExpand();
List<Restaurant> filteredRestaurants =
filters.filterRestaurants(widget.restaurants, filters);
return Scaffold( return Scaffold(
key: _drawerKey,
body: Container( body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
@@ -93,57 +93,15 @@ class _SearchResultsState extends State<SearchResults>
} }
}, },
onSelectTag: (tag) { onSelectTag: (tag) {
switch (tag) { List<Tags> result = List<Tags>.from(filters.tags);
case Tags.alcohol: if (filters.tags.contains(tag)) {
{ result.remove(tag);
setState(() { } else {
filters.alcohol = !filters.alcohol; result.add(tag);
});
}
break;
case Tags.cardPayments:
{
setState(() {
filters.cardPayments = !filters.cardPayments;
});
}
break;
case Tags.delivery:
{
setState(() {
filters.delivery = !filters.delivery;
});
}
break;
case Tags.glutenFree:
{
setState(() {
filters.glutenFree = !filters.glutenFree;
});
}
break;
case Tags.petFriendly:
{
setState(() {
filters.petFriendly = !filters.petFriendly;
});
}
break;
case Tags.vegan:
{
setState(() {
filters.vegan = !filters.vegan;
});
}
break;
case Tags.vegetarian:
{
setState(() {
filters.vegetarian = !filters.vegetarian;
});
}
break;
} }
setState(() {
filters.tags = result;
});
}, },
)), )),
Container( Container(
@@ -161,10 +119,10 @@ class _SearchResultsState extends State<SearchResults>
), ),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: widget.restaurants.length, itemCount: filteredRestaurants.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return RestaurantCard( return RestaurantCard(
restaurant: widget.restaurants[index], restaurant: filteredRestaurants[index],
); );
}, },
)) ))
@@ -211,7 +169,7 @@ class _SearchResultsState extends State<SearchResults>
), ),
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
'Znaleziono: ${widget.restaurants.length}', 'Znaleziono: ${filteredRestaurants.length}',
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 14, fontWeight: FontWeight.w400), color: Colors.white, fontSize: 14, fontWeight: FontWeight.w400),
), ),
@@ -236,23 +194,6 @@ class _SearchResultsState extends State<SearchResults>
), ),
], ],
), ),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(color: Colors.grey[850]),
child: Text(
'Filtry',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
color: Colors.orange),
),
)
],
),
),
); );
} }
} }

View File

@@ -3,6 +3,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
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'; import './settings.dart';
import './components/filters.dart';
class MenuiServices { class MenuiServices {
final String backendURL = 'https://api.menui.pl/'; final String backendURL = 'https://api.menui.pl/';
@@ -29,11 +30,39 @@ class MenuiServices {
final response = await http.get('${backendURL}dish?dishId=$id'); final response = await http.get('${backendURL}dish?dishId=$id');
if (response.statusCode == 200 || response.statusCode == 304) { if (response.statusCode == 200 || response.statusCode == 304) {
final decoded = jsonDecode(response.body); final decoded = jsonDecode(response.body);
final thisAllergens = decoded['allergens'];
final thisPrices = decoded['prices'];
final thisPrice1 = thisPrices['price1'];
final thisPrice2 = thisPrices['price2'];
final thisPrice3 = thisPrices['price3'];
final result = new Dish( final result = new Dish(
id: decoded['_id'], id: decoded['_id'],
restaurantId: decoded['restaurantId'], restaurantId: decoded['restaurantId'],
name: decoded['name'], name: decoded['name'],
category: decoded['category']); category: decoded['category'],
prices: new MenuiPrices(
price1:
new MenuiPrice(thisPrice1['priceName'], thisPrice1['price']),
price2:
new MenuiPrice(thisPrice2['priceName'], thisPrice2['price']),
price3:
new MenuiPrice(thisPrice3['priceName'], thisPrice3['price'])),
notes: decoded['notes'],
imgUrl: decoded['imgUrl'],
weight: decoded['weight'],
ingredients: decoded['ingredients'],
vegetarian: decoded['vegetarian'],
vegan: decoded['vegan'],
glicemicIndex: decoded['glicemicIndex'],
kCal: decoded['kCal'],
allergens: new MenuiAllergens(
thisAllergens['gluten'],
thisAllergens['lactose'],
thisAllergens['soy'],
thisAllergens['eggs'],
thisAllergens['seaFood'],
thisAllergens['peanuts'],
thisAllergens['sesame']));
return result; return result;
} else { } else {
throw "Nie udało się pobrać"; throw "Nie udało się pobrać";
@@ -87,6 +116,8 @@ class MenuiServices {
} }
} }
return dishes; return dishes;
} else {
return List<Dish>();
} }
} }
@@ -131,18 +162,13 @@ class MenuiServices {
links: new MenuiLinks( links: new MenuiLinks(
links['facebook'], links['instagram'], links['www']), links['facebook'], links['instagram'], links['www']),
categories: categories, categories: categories,
tags: new MenuiTags( tags: decodeTags(tags),
tags['cardPayments'],
tags['petFriendly'],
tags['glutenFree'],
tags['vegan'],
tags['vegetarian'],
tags['alcohol'],
tags['delivery']),
lunchHours: decoded['lunchHours'], lunchHours: decoded['lunchHours'],
lunchMenu: lunchMenu, lunchMenu: lunchMenu,
dishes: decoded['dishes']); dishes: decoded['dishes']);
return result; return result;
} else {
return null;
} }
} }
@@ -186,14 +212,7 @@ class MenuiServices {
workingHours['sb'], workingHours['sb'],
workingHours['nd']), workingHours['nd']),
description: restaurant['description'], description: restaurant['description'],
tags: new MenuiTags( tags: decodeTags(tags),
tags['cardPayments'],
tags['petFriendly'],
tags['glutenFree'],
tags['vegan'],
tags['vegetarian'],
tags['alcohol'],
tags['delivery']),
lunchHours: restaurant['lunchHours'], lunchHours: restaurant['lunchHours'],
lunchMenu: lunchMenu, lunchMenu: lunchMenu,
dishes: restaurant['dishes']); dishes: restaurant['dishes']);
@@ -242,14 +261,7 @@ class MenuiServices {
workingHours['sb'], workingHours['sb'],
workingHours['nd']), workingHours['nd']),
description: restaurant['description'], description: restaurant['description'],
tags: new MenuiTags( tags: decodeTags(tags),
tags['cardPayments'],
tags['petFriendly'],
tags['glutenFree'],
tags['vegan'],
tags['vegetarian'],
tags['alcohol'],
tags['delivery']),
lunchHours: restaurant['lunchHours'], lunchHours: restaurant['lunchHours'],
lunchMenu: lunchMenu, lunchMenu: lunchMenu,
dishes: restaurant['dishes']); dishes: restaurant['dishes']);
@@ -297,6 +309,18 @@ class MenuiServices {
return hours; return hours;
} }
} }
List<Tags> decodeTags(dynamic tags) {
List<Tags> result = [];
if (tags['cardPayments']) result.add(Tags.cardPayments);
if (tags['petFriendly']) result.add(Tags.petFriendly);
if (tags['glutenFree']) result.add(Tags.glutenFree);
if (tags['vegan']) result.add(Tags.vegan);
if (tags['vegetarian']) result.add(Tags.vegetarian);
if (tags['alcohol']) result.add(Tags.alcohol);
if (tags['delivery']) result.add(Tags.delivery);
return result;
}
} }
// DATA TYPES // DATA TYPES
@@ -312,7 +336,7 @@ class Restaurant {
String imgUrl; String imgUrl;
MenuiWorkingHours workingHours; MenuiWorkingHours workingHours;
String description; String description;
MenuiTags tags; List<Tags> tags;
MenuiLinks links; MenuiLinks links;
String phone; String phone;
List<String> categories; List<String> categories;
@@ -450,19 +474,6 @@ class MenuiLinks {
MenuiLinks(this.facebook, this.instagram, this.www); MenuiLinks(this.facebook, this.instagram, this.www);
} }
class MenuiTags {
bool cardPayments;
bool petFriendly;
bool glutenFree;
bool vegan;
bool vegetarian;
bool alcohol;
bool delivery;
MenuiTags(this.cardPayments, this.petFriendly, this.glutenFree, this.vegan,
this.vegetarian, this.alcohol, this.delivery);
}
class MenuiWorkingHours { class MenuiWorkingHours {
String pn; String pn;
String wt; String wt;

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
@@ -86,33 +88,70 @@ class MenuiSettings {
} }
} }
// ADD DISH TO ORDER --- TODO // DECODE ORDER
void addToOrder(String id) async { List<OrderItem> decodeOrder(String orderJson) {
print(orderJson);
final List decoded = jsonDecode(orderJson);
List<OrderItem> order = [];
decoded.forEach((item) => {
order.add(new OrderItem(
id: item['id'],
quantity: item['quantity'],
price: item['price'],
priceName: item['priceName']))
});
return order;
}
// ENCODE ORDER
String encodeOrder(List<OrderItem> order) {
return jsonEncode(order);
}
// ADD DISH TO ORDER
void addToOrder(OrderItem item) async {
final settings = await SharedPreferences.getInstance(); final settings = await SharedPreferences.getInstance();
if (settings.containsKey('order')) { if (settings.containsKey('order')) {
List<String> order = settings.getStringList('order'); String rawOrder = settings.getString('order');
order.add(id); List<OrderItem> order = decodeOrder(rawOrder);
order.add(item);
String encodedOrder = encodeOrder(order);
settings.setString('order', encodedOrder);
} else { } else {
final List<String> order = new List<String>(); final List<OrderItem> order = new List<OrderItem>();
order.add(id); order.add(item);
String encodedOrder = encodeOrder(order);
settings.setString('order', encodedOrder);
} }
} }
// REMOVE FROM ORDER
void removeFromOrder(int index) async {
final settings = await SharedPreferences.getInstance();
String rawOrder = settings.getString('order');
List<OrderItem> order = decodeOrder(rawOrder);
order.removeAt(index);
String encodedOrder = encodeOrder(order);
settings.setString('order', encodedOrder);
}
// GET ORDER // GET ORDER
Future<List<String>> getOrder() async { Future<List<OrderItem>> getOrder() async {
final settings = await SharedPreferences.getInstance(); final settings = await SharedPreferences.getInstance();
if (settings.containsKey('order')) { if (settings.containsKey('order')) {
List<String> order = settings.getStringList('order'); String rawOrder = settings.getString('order');
List<OrderItem> order = decodeOrder(rawOrder);
return order; return order;
} else { } else {
return new List<String>(); return new List<OrderItem>();
} }
} }
// CLEAR ORDER // CLEAR ORDER
void clearOrder() async { void clearOrder() async {
final settings = await SharedPreferences.getInstance(); final settings = await SharedPreferences.getInstance();
settings.setStringList('order', new List<String>()); String cleanOrder = encodeOrder(new List<OrderItem>());
settings.setString('order', cleanOrder);
} }
// ADD TO FAVORITES (OR REMOVE) // ADD TO FAVORITES (OR REMOVE)
@@ -211,7 +250,7 @@ void showSettings(BuildContext context, MenuiSettings settings) async {
), ),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
showRadiusSelectionDialog(context, settings); showRadiusSelectionDialog(context, settings, () {});
}), }),
ListTile( ListTile(
title: Text( title: Text(
@@ -390,13 +429,14 @@ void showAppInfoDialog(BuildContext context) async {
// SELECT RADIUS // SELECT RADIUS
void showRadiusSelectionDialog( void showRadiusSelectionDialog(
BuildContext context, MenuiSettings settings) async { BuildContext context, MenuiSettings settings, Function onSaved) async {
final int currentRadius = await settings.getRadius(); final int currentRadius = await settings.getRadius();
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return RadiusSlider( return RadiusSlider(
initialValue: currentRadius.toDouble(), initialValue: currentRadius.toDouble(),
onSaved: onSaved,
); );
}); });
} }
@@ -411,7 +451,9 @@ Color getOptionColor(targetOption, thisOption) {
class RadiusSlider extends StatefulWidget { class RadiusSlider extends StatefulWidget {
final double initialValue; final double initialValue;
RadiusSlider({Key key, @required this.initialValue}) : super(key: key); final Function onSaved;
RadiusSlider({Key key, @required this.initialValue, this.onSaved})
: super(key: key);
@override @override
_RadiusSliderState createState() => _RadiusSliderState createState() =>
@@ -449,6 +491,9 @@ class _RadiusSliderState extends State<RadiusSlider> {
onPressed: () async { onPressed: () async {
final MenuiSettings settings = new MenuiSettings(); final MenuiSettings settings = new MenuiSettings();
settings.setRadius(sliderValue.toInt()); settings.setRadius(sliderValue.toInt());
if (widget.onSaved != null) {
widget.onSaved();
}
Navigator.pop(context); Navigator.pop(context);
}, },
child: const Text( child: const Text(
@@ -470,3 +515,21 @@ class _RadiusSliderState extends State<RadiusSlider> {
} }
} }
} }
class OrderItem {
final int quantity;
final String price;
final String priceName;
final String id;
OrderItem({this.id, this.price, this.priceName, this.quantity});
Map<String, dynamic> toJson() {
return {
"quantity": quantity,
"price": price,
"priceName": priceName,
"id": id
};
}
}