diff --git a/img/i_alcohol.png b/img/i_alcohol.png index 7b11a72..818fdb0 100644 Binary files a/img/i_alcohol.png and b/img/i_alcohol.png differ diff --git a/img/i_card.png b/img/i_card.png index 327561c..cfa41e8 100644 Binary files a/img/i_card.png and b/img/i_card.png differ diff --git a/img/i_delivery.png b/img/i_delivery.png index 660a98f..86f3354 100644 Binary files a/img/i_delivery.png and b/img/i_delivery.png differ diff --git a/img/i_eggs.png b/img/i_eggs.png index 7dfa8c7..8431475 100644 Binary files a/img/i_eggs.png and b/img/i_eggs.png differ diff --git a/img/i_gluten.png b/img/i_gluten.png index a8fbf1d..63a2c30 100644 Binary files a/img/i_gluten.png and b/img/i_gluten.png differ diff --git a/img/i_glutenFree.png b/img/i_glutenFree.png index fd8f0eb..199a905 100644 Binary files a/img/i_glutenFree.png and b/img/i_glutenFree.png differ diff --git a/img/i_lactose.png b/img/i_lactose.png index 564dd2c..438b13a 100644 Binary files a/img/i_lactose.png and b/img/i_lactose.png differ diff --git a/img/i_lactoseFree.png b/img/i_lactoseFree.png index cd9418c..bbed657 100644 Binary files a/img/i_lactoseFree.png and b/img/i_lactoseFree.png differ diff --git a/img/i_peanuts.png b/img/i_peanuts.png index f12c6b8..a54d520 100644 Binary files a/img/i_peanuts.png and b/img/i_peanuts.png differ diff --git a/img/i_pets.png b/img/i_pets.png index 4d10998..dfccdc6 100644 Binary files a/img/i_pets.png and b/img/i_pets.png differ diff --git a/img/i_seaFood.png b/img/i_seaFood.png index 751d948..28ca38a 100644 Binary files a/img/i_seaFood.png and b/img/i_seaFood.png differ diff --git a/img/i_sesame.png b/img/i_sesame.png index e230b6a..72ea29d 100644 Binary files a/img/i_sesame.png and b/img/i_sesame.png differ diff --git a/img/i_soy.png b/img/i_soy.png index 2274fa0..effa147 100644 Binary files a/img/i_soy.png and b/img/i_soy.png differ diff --git a/img/i_vegan.png b/img/i_vegan.png index bdef8ed..90015a1 100644 Binary files a/img/i_vegan.png and b/img/i_vegan.png differ diff --git a/img/i_vegetarian.png b/img/i_vegetarian.png index ff8e16f..1238e9d 100644 Binary files a/img/i_vegetarian.png and b/img/i_vegetarian.png differ diff --git a/img/logo_mint.png b/img/logo_mint.png deleted file mode 100644 index 73b0740..0000000 Binary files a/img/logo_mint.png and /dev/null differ diff --git a/img/logo_orange.png b/img/logo_orange.png new file mode 100644 index 0000000..89748e7 Binary files /dev/null and b/img/logo_orange.png differ diff --git a/img/logo_white.png b/img/logo_white.png deleted file mode 100644 index c77970f..0000000 Binary files a/img/logo_white.png and /dev/null differ diff --git a/lib/components/homeScreen.dart b/lib/components/homeScreen.dart index 26645b9..1c755b5 100644 --- a/lib/components/homeScreen.dart +++ b/lib/components/homeScreen.dart @@ -27,7 +27,7 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( - "img/logo_mint.png", + "img/logo_orange.png", width: 160, ), MenuiSearchBar(), @@ -47,7 +47,7 @@ class _HomePageState extends State { style: TextStyle(color: Colors.grey[400]), ), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + borderRadius: BorderRadius.circular(50)), ) ], ), diff --git a/lib/components/lineOfIcons.dart b/lib/components/lineOfIcons.dart index fae692c..bee2b58 100644 --- a/lib/components/lineOfIcons.dart +++ b/lib/components/lineOfIcons.dart @@ -3,6 +3,7 @@ import '../services.dart'; class LineOfIcons extends StatelessWidget { final MenuiTags tags; + final double edgeInsets = 6; LineOfIcons({@required this.tags}); @@ -14,16 +15,16 @@ class LineOfIcons extends StatelessWidget { children: [ if (tags.alcohol == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_alcohol.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Alkohol', @@ -33,16 +34,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.cardPayments == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_card.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Płatność', @@ -56,16 +57,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.delivery == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_delivery.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Dowozimy', @@ -75,16 +76,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.glutenFree == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_glutenFree.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Bezglutenowe', @@ -94,16 +95,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.petFriendly == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_pets.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Lubimy', @@ -117,16 +118,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.vegan == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_vegan.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Wegańskie', @@ -136,16 +137,16 @@ class LineOfIcons extends StatelessWidget { )), if (tags.vegetarian == true) Container( - margin: EdgeInsets.all(8), + margin: EdgeInsets.all(edgeInsets), child: Column( children: [ Container( alignment: Alignment.center, child: Image.asset( 'img/i_vegetarian.png', - width: 20, + width: 18, ), - height: 30, + height: 26, ), Text( 'Wegetariańskie', diff --git a/lib/components/lineOfIconsSmall.dart b/lib/components/lineOfIconsSmall.dart new file mode 100644 index 0000000..76881e3 --- /dev/null +++ b/lib/components/lineOfIconsSmall.dart @@ -0,0 +1,123 @@ +import 'package:flutter/material.dart'; +import '../services.dart'; + +class LineOfIconsSmall extends StatelessWidget { + final MenuiTags tags; + + LineOfIconsSmall({@required this.tags}); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (tags.alcohol == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_alcohol.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.cardPayments == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_card.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.delivery == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_delivery.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.glutenFree == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_glutenFree.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.petFriendly == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_pets.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.vegan == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_vegan.png', + width: 14, + ), + height: 14, + ), + ], + )), + if (tags.vegetarian == true) + Container( + margin: EdgeInsets.only(top: 4, bottom: 4, right: 9), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Image.asset( + 'img/i_vegetarian.png', + width: 14, + ), + height: 14, + ), + ], + )), + ], + ); + } +} diff --git a/lib/components/restaurantCard.dart b/lib/components/restaurantCard.dart index 4ad5950..e9dc681 100644 --- a/lib/components/restaurantCard.dart +++ b/lib/components/restaurantCard.dart @@ -1,62 +1,110 @@ import 'package:flutter/material.dart'; import 'restaurantView.dart'; import 'package:menui_mobile/services.dart'; +import 'lineOfIconsSmall.dart'; class RestaurantCard extends StatelessWidget { RestaurantCard({@required this.restaurant}); - + final _services = new MenuiServices(); final Restaurant restaurant; @override Widget build(BuildContext context) { + String _openHours = _services.getTodayHours(restaurant.workingHours); return Card( child: InkWell( onTap: () => Navigator.push( context, MaterialPageRoute( - builder: (context) => RestaurantView(restaurant: restaurant))), + builder: (context) => RestaurantView(id: restaurant.id))), child: Row( - crossAxisAlignment: CrossAxisAlignment.baseline, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( child: ClipRRect( child: Image.network( restaurant.imgUrl, - width: 80, - height: 80, + width: 100, + height: 100, fit: BoxFit.cover, ), - borderRadius: BorderRadius.all(Radius.circular(8)), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(12), + topLeft: Radius.circular(12)), ), - padding: EdgeInsets.all(8), + padding: EdgeInsets.only(right: 8), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( restaurant.name, overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Colors.orange[600], fontSize: 16, height: 1.6), + maxLines: 1, + style: TextStyle(color: Colors.orange[600], fontSize: 16), ), Container( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'Miasto: ${restaurant.city}', - overflow: TextOverflow.ellipsis, - style: TextStyle(color: Colors.grey, fontSize: 14), - ), - Text( - restaurant.description, - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle(color: Colors.grey, fontSize: 14), - ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.location_city, + size: 14, + color: Colors.white, + ), + Padding( + padding: EdgeInsets.only(left: 4), + child: Text( + '${restaurant.city}, ${restaurant.adress}', + style: + TextStyle(color: Colors.grey, fontSize: 12), + ), + ), + ]), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.restaurant, + size: 14, + color: Colors.white, + ), + Padding( + padding: EdgeInsets.only(left: 4), + child: Text( + '${restaurant.type}', + style: + TextStyle(color: Colors.grey, fontSize: 12), + ), + ), + ]), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.timer, + size: 14, + color: Colors.white, + ), + Padding( + padding: EdgeInsets.only(left: 4), + child: Text( + '$_openHours', + style: + TextStyle(color: Colors.grey, fontSize: 12), + ), + ), + ]), + Padding( + child: LineOfIconsSmall(tags: restaurant.tags), + padding: EdgeInsets.only(top: 4), + ) ], )), ], @@ -64,7 +112,8 @@ class RestaurantCard extends StatelessWidget { Container( child: Icon( Icons.arrow_right, - color: Colors.orange, + color: Colors.white, + size: 28, ), ) ], diff --git a/lib/components/restaurantView.dart b/lib/components/restaurantView.dart index 94730b9..bc47ac0 100644 --- a/lib/components/restaurantView.dart +++ b/lib/components/restaurantView.dart @@ -3,91 +3,287 @@ import '../services.dart'; import 'lineOfIcons.dart'; class RestaurantView extends StatelessWidget { - final Restaurant restaurant; + final String id; + final MenuiServices services = new MenuiServices(); - RestaurantView({@required this.restaurant}); + RestaurantView({@required this.id}); @override Widget build(BuildContext context) { return Scaffold( - body: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - restaurant.imgUrl, - ), - fit: BoxFit.cover)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 160, - ), - Row( + body: Container( + decoration: BoxDecoration(color: Colors.grey[850]), + child: FutureBuilder( + future: services.fetchRestaurant(id), + builder: + (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + final Restaurant restaurant = snapshot.data; + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Container( - padding: EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.grey[850], - borderRadius: BorderRadius.all(Radius.circular(8))), + image: DecorationImage( + image: NetworkImage( + restaurant.imgUrl, + ), + fit: BoxFit.cover)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - restaurant.name, - style: TextStyle( - fontSize: 24, - color: Colors.orange, - fontWeight: FontWeight.w300), + SizedBox( + height: 160, ), - Text( - restaurant.city, - style: TextStyle(color: Colors.grey), + Row( + children: [ + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[850], + borderRadius: + BorderRadius.all(Radius.circular(8))), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + restaurant.name, + style: TextStyle( + fontSize: 24, + color: Colors.orange, + fontWeight: FontWeight.w300), + ), + Text( + restaurant.city, + style: TextStyle(color: Colors.grey), + ) + ], + ), + margin: EdgeInsets.all(12), + ), + Container( + margin: EdgeInsets.only(right: 12), + decoration: BoxDecoration( + color: Colors.grey[850], + borderRadius: BorderRadius.circular(30)), + child: IconButton( + icon: Icon( + Icons.map, + color: Colors.orange, + ), + onPressed: () {}), + ) + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, ) ], ), - margin: EdgeInsets.all(12), ), Container( - margin: EdgeInsets.only(right: 12), - decoration: BoxDecoration( - color: Colors.grey[850], - borderRadius: BorderRadius.circular(30)), - child: IconButton( - icon: Icon( - Icons.map, - color: Colors.orange, + decoration: BoxDecoration(color: Colors.grey[850]), + child: Column( + children: [ + LineOfIcons( + tags: restaurant.tags, ), - onPressed: () {}), + Divider( + height: 14, + thickness: 4, + ), + Padding( + padding: EdgeInsets.symmetric( + vertical: 4, horizontal: 12), + child: Text( + restaurant.description, + style: TextStyle( + fontSize: 12, color: Colors.grey[300]), + textAlign: TextAlign.center, + ), + ), + Divider( + height: 14, + thickness: 4, + ), + Text( + 'Informacje', + style: + TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + MenuiDoubleColorText( + leading: 'Adres: ', + following: + '${restaurant.city}, ${restaurant.adress}', + ), + MenuiDoubleColorText( + leading: 'Kontakt: ', + following: '${restaurant.phone}', + ), + SizedBox( + height: 12, + ), + Text( + 'Godziny otwarcia', + style: + TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + WorkingHoursList( + workingHours: restaurant.workingHours), + SizedBox( + height: 12, + ), + ], + ), ) ], - mainAxisAlignment: MainAxisAlignment.spaceBetween, - ) - ], - ), - ), - Container( - decoration: BoxDecoration(color: Colors.grey[850]), - child: Column( - children: [ - LineOfIcons( - tags: restaurant.tags, - ), - Text('1234') - ], - ), - ) - ], - ), + ); + } else { + return Center( + child: CircularProgressIndicator(), + ); + } + }, + )), + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButton: FloatingActionButton.extended( + onPressed: () { + showMenu(context); + }, + label: Text( + 'Pokaż menu', + style: TextStyle(color: Colors.white), + ), + icon: Icon( + Icons.arrow_upward_rounded, + color: Colors.orange, + ), + backgroundColor: Colors.grey[900], + )); + } + + showMenu(BuildContext context) { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)), + child: Text('qweqweqweqweqweqw'), + ); + }); + } +} + +class MenuiDoubleColorText extends StatelessWidget { + final String leading; + final String following; + + MenuiDoubleColorText({@required this.leading, @required this.following}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(2), + child: RichText( + text: TextSpan(children: [ + TextSpan( + text: leading, + style: TextStyle(color: Colors.grey, fontSize: 12)), + TextSpan( + text: following, + style: TextStyle(color: Colors.grey[300], fontSize: 12)) + ]), ), ); } } + +class WorkingHoursDay extends StatelessWidget { + final String day; + final String workingHours; + final int index; + + WorkingHoursDay(this.day, this.workingHours, this.index); + + String formatTodayHours(String hours) { + if (hours == "") { + return 'nieczynne'; + } else { + return hours; + } + } + + background() { + final DateTime now = DateTime.now(); + if (now.weekday == this.index) { + return Colors.orange; + } else { + return Colors.grey[700]; + } + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(6), + child: Container( + padding: EdgeInsets.all(6), + decoration: BoxDecoration( + color: background(), + borderRadius: BorderRadius.all(Radius.circular(8))), + child: Column( + children: [ + Text( + day, + style: TextStyle(fontWeight: FontWeight.w300), + ), + Divider( + height: 4, + thickness: 2, + color: Colors.white, + ), + Text( + formatTodayHours(workingHours), + style: TextStyle(color: Colors.white, fontSize: 11), + ) + ], + ), + )); + } +} + +class WorkingHoursList extends StatelessWidget { + final MenuiWorkingHours workingHours; + WorkingHoursList({@required this.workingHours}); + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + WorkingHoursDay('Pn', workingHours.pn, 1), + WorkingHoursDay('Wt', workingHours.wt, 2), + WorkingHoursDay('Śr', workingHours.sr, 3), + WorkingHoursDay('Cz', workingHours.cz, 4), + ], + ), + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + WorkingHoursDay('Pt', workingHours.pt, 5), + WorkingHoursDay('So', workingHours.sb, 6), + WorkingHoursDay('Nd', workingHours.nd, 7), + ]) + ], + ); + } +} diff --git a/lib/components/searchBar.dart b/lib/components/searchBar.dart index 40a902b..ba68988 100644 --- a/lib/components/searchBar.dart +++ b/lib/components/searchBar.dart @@ -83,13 +83,14 @@ class MenuiSearchBarState extends State { child: Stack( children: [ Positioned( - width: size.width, + width: size.width * 0.94, child: CompositedTransformFollower( - offset: Offset(0.0, size.height + 5.0), + offset: Offset(size.width * 0.03, size.height), link: layerLink, showWhenUnlinked: false, child: Material( - color: Colors.grey[800], + color: Colors.grey[850], + borderRadius: BorderRadius.circular(20), elevation: 4.0, child: ConstrainedBox( constraints: new BoxConstraints(maxHeight: 200), @@ -103,9 +104,13 @@ class MenuiSearchBarState extends State { _controller.text = suggestions[index]; searchRestaurantsByString(); }, + leading: Icon( + Icons.search_rounded, + color: Colors.grey, + ), title: Text( suggestions[index], - style: TextStyle(color: Colors.orange), + style: TextStyle(color: Colors.grey), ), ); }), @@ -135,18 +140,17 @@ class MenuiSearchBarState extends State { padding: const EdgeInsets.all(12), child: TextFormField( controller: _controller, - //onChanged: (text) => fetchAutocomplete(text), style: TextStyle(color: Colors.orange), decoration: InputDecoration( hintStyle: TextStyle(color: Colors.grey), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(12)), + borderRadius: BorderRadius.circular(16)), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.orange, width: 2.0), - borderRadius: BorderRadius.circular(12)), + borderRadius: BorderRadius.circular(20)), hintText: 'Wyszukaj miasto lub nazwę restauracji.', suffixIcon: Icon( Icons.search, diff --git a/lib/components/searchResults.dart b/lib/components/searchResults.dart index c9a4fa5..528294e 100644 --- a/lib/components/searchResults.dart +++ b/lib/components/searchResults.dart @@ -23,7 +23,7 @@ class SearchResults extends StatelessWidget { height: 30, ), Image.asset( - "img/logo_mint.png", + "img/logo_orange.png", width: 60, ), MenuiSearchBar(), diff --git a/lib/services.dart b/lib/services.dart index 829b98f..90dd37a 100644 --- a/lib/services.dart +++ b/lib/services.dart @@ -38,6 +38,62 @@ class MenuiServices { } } + Future fetchRestaurant(String id) async { + final response = await http.get('${backendURL}restaurant?restaurantId=$id'); + if (response.statusCode == 200 || response.statusCode == 304) { + final decoded = jsonDecode(response.body); + final workingHours = decoded['workingHours']; + final tags = decoded['tags']; + final links = decoded['links']; + final List responseLunchMenu = decoded['lunchMenu']; + List 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: decoded['_id'], + name: decoded['name'], + city: decoded['city'], + adress: decoded['adress'], + type: decoded['type'], + coordinates: decoded['coordinates'], + phone: decoded['phone'], + imgUrl: decoded['imgUrl'], + placesId: decoded['placesId'], + workingHours: new MenuiWorkingHours( + workingHours['pn'], + workingHours['wt'], + workingHours['sr'], + workingHours['cz'], + workingHours['pt'], + workingHours['sb'], + workingHours['nd']), + description: decoded['description'], + links: new MenuiLinks( + links['facebook'], links['instagram'], links['www']), + categories: decoded['categories'], + tags: new MenuiTags( + tags['cardPayments'], + tags['petFriendly'], + tags['glutenFree'], + tags['vegan'], + tags['vegetarian'], + tags['alcohol'], + tags['delivery']), + lunchHours: decoded['lunchHours'], + lunchMenu: lunchMenu, + dishes: decoded['dishes']); + + return result; + } + } + Future> fetchSearchByString(String text) async { final response = await http.get('${backendURL}search?string=$text'); if (response.statusCode == 200 || response.statusCode == 304) { @@ -46,7 +102,6 @@ class MenuiServices { for (var restaurant in decoded) { final workingHours = restaurant['workingHours']; final tags = restaurant['tags']; - final links = restaurant['links']; final List responseLunchMenu = restaurant['lunchMenu']; List lunchMenu = []; if (responseLunchMenu != null) { @@ -63,6 +118,7 @@ class MenuiServices { name: restaurant['name'], city: restaurant['city'], adress: restaurant['adress'], + type: restaurant['type'], coordinates: restaurant['coordinates'], imgUrl: restaurant['imgUrl'], placesId: restaurant['placesId'], @@ -83,10 +139,6 @@ class MenuiServices { tags['vegetarian'], tags['alcohol'], tags['delivery']), - links: new MenuiLinks( - links['facebook'], links['instagram'], links['www']), - phone: restaurant['phone'], - categories: restaurant['categories'], lunchHours: restaurant['lunchHours'], lunchMenu: lunchMenu, dishes: restaurant['dishes']); @@ -97,6 +149,43 @@ class MenuiServices { return []; } } + + String getTodayHours(MenuiWorkingHours workingHours) { + final DateTime now = DateTime.now(); + String todayHours; + switch (now.weekday) { + case 1: + todayHours = formatTodayHours(workingHours.pn); + break; + case 2: + todayHours = formatTodayHours(workingHours.wt); + break; + case 3: + todayHours = formatTodayHours(workingHours.sr); + break; + case 4: + todayHours = formatTodayHours(workingHours.cz); + break; + case 5: + todayHours = formatTodayHours(workingHours.pt); + break; + case 6: + todayHours = formatTodayHours(workingHours.sb); + break; + case 7: + todayHours = formatTodayHours(workingHours.nd); + break; + } + return todayHours; + } + + String formatTodayHours(String hours) { + if (hours == "") { + return 'nieczynne'; + } else { + return hours; + } + } } // DATA TYPES @@ -106,6 +195,7 @@ class Restaurant { String name; String city; String adress; + String type; List coordinates; String placesId; String imgUrl; @@ -124,6 +214,7 @@ class Restaurant { @required this.name, @required this.city, @required this.adress, + @required this.type, @required this.coordinates, this.placesId, @required this.imgUrl,