From f840ade2c87f97cc79a9a0caf9281aa719f231de Mon Sep 17 00:00:00 2001 From: Jonasz Bigda Date: Fri, 4 Dec 2020 21:40:44 +0100 Subject: [PATCH] Dish view --- lib/components/dishCard.dart | 4 +- lib/components/dishView.dart | 252 ++++++++++++++++++++++++++++ lib/components/lineOfAllergens.dart | 152 +++++++++++++++++ lib/components/restaurantView.dart | 17 ++ lib/components/socialMedia.dart | 44 +++++ pubspec.lock | 7 + pubspec.yaml | 1 + 7 files changed, 476 insertions(+), 1 deletion(-) create mode 100644 lib/components/dishView.dart create mode 100644 lib/components/lineOfAllergens.dart create mode 100644 lib/components/socialMedia.dart diff --git a/lib/components/dishCard.dart b/lib/components/dishCard.dart index 6d09573..89ee7dd 100644 --- a/lib/components/dishCard.dart +++ b/lib/components/dishCard.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import '../services.dart'; +import 'dishView.dart'; class DishCard extends StatelessWidget { final Dish dish; @@ -13,7 +14,8 @@ class DishCard extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), margin: EdgeInsets.symmetric(horizontal: 12, vertical: 5), child: InkWell( - onTap: () {}, + onTap: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => DishView(dish: dish))), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ diff --git a/lib/components/dishView.dart b/lib/components/dishView.dart new file mode 100644 index 0000000..bcb479e --- /dev/null +++ b/lib/components/dishView.dart @@ -0,0 +1,252 @@ +import 'package:flutter/material.dart'; +import 'package:menui_mobile/services.dart'; +import 'lineOfAllergens.dart'; + +class DishView extends StatelessWidget { + final Dish dish; + DishView({@required this.dish}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + decoration: BoxDecoration(color: Colors.grey[850]), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + dish.imgUrl, + ), + fit: BoxFit.cover), + ), + child: Column( + children: [ + SizedBox( + height: 160, + width: double.infinity, + ), + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[850], + borderRadius: BorderRadius.all(Radius.circular(8))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + dish.name, + style: TextStyle( + fontSize: 24, + color: Colors.orange, + fontWeight: FontWeight.w300), + ), + ], + ), + margin: EdgeInsets.all(12), + ) + ], + ), + ), + SizedBox(height: 8), + Allergens(allergens: dish.allergens), + Divider( + height: 14, + thickness: 4, + ), + Text( + 'Cena', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + Prices(prices: dish.prices), + SizedBox( + height: 12, + ), + Divider( + height: 14, + thickness: 4, + ), + Text( + 'Składniki', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + Text( + '${dish.ingredients}', + style: TextStyle(color: Colors.grey[200], fontSize: 12), + ), + SizedBox( + height: 12, + ), + Text( + 'Porcja', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + 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), + ), + SizedBox( + height: 12, + ), + Text( + 'Uwagi', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + Text( + '${dish.notes}', + style: TextStyle(color: Colors.grey[200], fontSize: 12), + ), + ], + ), + ), + ); + } +} + +class Prices extends StatelessWidget { + final MenuiPrices prices; + + Prices({@required this.prices}); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + if (prices.price1.priceName == "") + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[800], + borderRadius: BorderRadius.all(Radius.circular(12))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.attach_money, + color: Colors.orange, + ), + SizedBox(height: 8), + Text( + '${prices.price1.price} zł', + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ]), + ), + if (prices.price1.priceName != "") + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[800], + borderRadius: BorderRadius.all(Radius.circular(12))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.attach_money, + color: Colors.orange, + ), + SizedBox(height: 8), + Text( + '(${prices.price1.priceName})', + style: TextStyle(color: Colors.white, fontSize: 11), + ), + Text( + '${prices.price1.price} zł', + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ]), + ), + if (prices.price2.priceName != "") + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[800], + borderRadius: BorderRadius.all(Radius.circular(12))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.attach_money, + color: Colors.orange, + ), + SizedBox(height: 8), + Text( + '(${prices.price2.priceName})', + style: TextStyle(color: Colors.white, fontSize: 11), + ), + Text( + '${prices.price2.price} zł', + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ]), + ), + if (prices.price3.priceName != "") + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[800], + borderRadius: BorderRadius.all(Radius.circular(12))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.attach_money, + color: Colors.orange, + ), + SizedBox(height: 8), + Text( + '(${prices.price3.priceName})', + style: TextStyle(color: Colors.white, fontSize: 11), + ), + Text( + '${prices.price3.price} zł', + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ]), + ), + ], + ); + } +} diff --git a/lib/components/lineOfAllergens.dart b/lib/components/lineOfAllergens.dart new file mode 100644 index 0000000..0d92fa5 --- /dev/null +++ b/lib/components/lineOfAllergens.dart @@ -0,0 +1,152 @@ +import 'package:flutter/material.dart'; +import '../services.dart'; + +class Allergens extends StatelessWidget { + final MenuiAllergens allergens; + final double edgeInsets = 6; + + Allergens({@required this.allergens}); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (allergens.eggs == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_eggs.png', + width: 18, + ), + height: 26, + ), + Text( + 'Jaja', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.gluten == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_gluten.png', + width: 18, + ), + height: 26, + ), + Text( + 'Gluten', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.lactose == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_lactose.png', + width: 18, + ), + height: 26, + ), + Text( + 'Laktoza', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.peanuts == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_peanuts.png', + width: 18, + ), + height: 26, + ), + Text( + 'Orzechy', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.seaFood == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_seaFood.png', + width: 18, + ), + height: 26, + ), + Text( + 'Owoce morza', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.sesame == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_sesame.png', + width: 18, + ), + height: 26, + ), + Text( + 'Sezam', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + if (allergens.soy == true) + Container( + margin: EdgeInsets.all(edgeInsets), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_soy.png', + width: 18, + ), + height: 26, + ), + Text( + 'Soja', + style: TextStyle(fontSize: 10, color: Colors.grey), + ) + ], + )), + ], + ); + } +} diff --git a/lib/components/restaurantView.dart b/lib/components/restaurantView.dart index 8335f6c..34e39fe 100644 --- a/lib/components/restaurantView.dart +++ b/lib/components/restaurantView.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import '../services.dart'; import 'lineOfIcons.dart'; import 'dishList.dart'; +import 'socialMedia.dart'; class RestaurantView extends StatelessWidget { final String id; @@ -118,6 +119,10 @@ class RestaurantView extends StatelessWidget { SizedBox( height: 12, ), + MenuiDoubleColorText( + leading: 'Kuchnia: ', + following: '${restaurant.type}', + ), MenuiDoubleColorText( leading: 'Adres: ', following: @@ -143,6 +148,18 @@ class RestaurantView extends StatelessWidget { SizedBox( height: 12, ), + Text( + 'Social media', + style: + TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + SocialMedia(links: restaurant.links), + SizedBox( + height: 12, + ), ], ), ) diff --git a/lib/components/socialMedia.dart b/lib/components/socialMedia.dart new file mode 100644 index 0000000..136187b --- /dev/null +++ b/lib/components/socialMedia.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:menui_mobile/services.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class SocialMedia extends StatelessWidget { + final MenuiLinks links; + SocialMedia({@required this.links}); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (links.facebook != "") + IconButton( + icon: FaIcon( + FontAwesomeIcons.facebook, + color: Colors.white, + ), + onPressed: () { + print(links.facebook); + }), + if (links.instagram != "") + IconButton( + icon: FaIcon( + FontAwesomeIcons.instagram, + color: Colors.white, + ), + onPressed: () { + print(links.instagram); + }), + if (links.www != "") + IconButton( + icon: FaIcon( + FontAwesomeIcons.globe, + color: Colors.white, + ), + onPressed: () { + print(links.www); + }) + ], + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 3404b71..5f3e1fc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -86,6 +86,13 @@ packages: description: flutter source: sdk version: "0.0.0" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "8.10.0" geolocator: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a766548..0da43bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ environment: dependencies: http: ^0.12.2 geolocator: ^6.1.0 + font_awesome_flutter: ^8.10.0 flutter: sdk: flutter shared_preferences: ^0.5.12