Multi price

This commit is contained in:
2020-12-01 19:50:24 +01:00
parent d3f990aecc
commit ab1e47dfee
2 changed files with 66 additions and 8 deletions

View File

@@ -53,10 +53,7 @@ class DishCard extends StatelessWidget {
), ),
], ],
), ),
Text( Prices(prices: dish.prices)
'${dish.price}',
style: TextStyle(color: Colors.white, fontSize: 14),
),
], ],
)), )),
Container( Container(
@@ -72,3 +69,38 @@ class DishCard extends StatelessWidget {
); );
} }
} }
class Prices extends StatelessWidget {
final MenuiPrices prices;
Prices({@required this.prices});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
if (prices.price1.priceName == "")
Text(
'${prices.price1.price}',
style: TextStyle(color: Colors.white, fontSize: 14),
),
if (prices.price1.priceName != "")
Text(
'${prices.price1.priceName}: ${prices.price1.price}',
style: TextStyle(color: Colors.white, fontSize: 14),
),
if (prices.price2.priceName != "")
Text(
'${prices.price2.priceName}: ${prices.price2.price}',
style: TextStyle(color: Colors.white, fontSize: 14),
),
if (prices.price3.priceName != "")
Text(
'${prices.price3.priceName}: ${prices.price3.price}',
style: TextStyle(color: Colors.white, fontSize: 14),
),
],
);
}
}

View File

@@ -3,7 +3,7 @@ import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
class MenuiServices { class MenuiServices {
final String backendURL = 'https://menui.azurewebsites.net/'; final String backendURL = 'https://api.menui.pl/';
Future<List<String>> fetchAutocomplete(String text) async { Future<List<String>> fetchAutocomplete(String text) async {
final response = final response =
@@ -49,12 +49,22 @@ class MenuiServices {
if (decodedResponse.isNotEmpty && decodedResponse != null) { if (decodedResponse.isNotEmpty && decodedResponse != null) {
for (var dish in decodedResponse) { for (var dish in decodedResponse) {
final thisAllergens = dish['allergens']; final thisAllergens = dish['allergens'];
final thisPrices = dish['prices'];
final thisPrice1 = thisPrices['price1'];
final thisPrice2 = thisPrices['price2'];
final thisPrice3 = thisPrices['price3'];
final Dish thisDish = new Dish( final Dish thisDish = new Dish(
id: dish['_id'], id: dish['_id'],
restaurantId: dish['restaurantId'], restaurantId: dish['restaurantId'],
name: dish['name'], name: dish['name'],
category: dish['category'], category: dish['category'],
price: dish['price'], 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: dish['notes'], notes: dish['notes'],
imgUrl: dish['imgUrl'], imgUrl: dish['imgUrl'],
weight: dish['weight'], weight: dish['weight'],
@@ -275,7 +285,7 @@ class Dish {
String restaurantId; String restaurantId;
String name; String name;
String category; String category;
String price; MenuiPrices prices;
String notes; String notes;
String imgUrl; String imgUrl;
String weight; String weight;
@@ -291,7 +301,7 @@ class Dish {
@required this.restaurantId, @required this.restaurantId,
@required this.name, @required this.name,
@required this.category, @required this.category,
this.price, this.prices,
this.notes, this.notes,
this.imgUrl, this.imgUrl,
this.weight, this.weight,
@@ -303,6 +313,22 @@ class Dish {
this.vegetarian}); this.vegetarian});
} }
class MenuiPrices {
MenuiPrice price1;
MenuiPrice price2;
MenuiPrice price3;
MenuiPrices(
{@required this.price1, @required this.price2, @required this.price3});
}
class MenuiPrice {
String priceName;
String price;
MenuiPrice(this.priceName, this.price);
}
class MenuiAllergens { class MenuiAllergens {
bool gluten; bool gluten;
bool lactose; bool lactose;