icons | restaurant view | services

This commit is contained in:
2020-10-30 19:40:17 +01:00
parent aa5d142a4f
commit 2ae32ac276
26 changed files with 586 additions and 122 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
img/logo_orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -27,7 +27,7 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Image.asset( Image.asset(
"img/logo_mint.png", "img/logo_orange.png",
width: 160, width: 160,
), ),
MenuiSearchBar(), MenuiSearchBar(),
@@ -47,7 +47,7 @@ class _HomePageState extends State<HomePage> {
style: TextStyle(color: Colors.grey[400]), style: TextStyle(color: Colors.grey[400]),
), ),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)), borderRadius: BorderRadius.circular(50)),
) )
], ],
), ),

View File

@@ -3,6 +3,7 @@ import '../services.dart';
class LineOfIcons extends StatelessWidget { class LineOfIcons extends StatelessWidget {
final MenuiTags tags; final MenuiTags tags;
final double edgeInsets = 6;
LineOfIcons({@required this.tags}); LineOfIcons({@required this.tags});
@@ -14,16 +15,16 @@ class LineOfIcons extends StatelessWidget {
children: <Widget>[ children: <Widget>[
if (tags.alcohol == true) if (tags.alcohol == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_alcohol.png', 'img/i_alcohol.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Alkohol', 'Alkohol',
@@ -33,16 +34,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.cardPayments == true) if (tags.cardPayments == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_card.png', 'img/i_card.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Płatność', 'Płatność',
@@ -56,16 +57,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.delivery == true) if (tags.delivery == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_delivery.png', 'img/i_delivery.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Dowozimy', 'Dowozimy',
@@ -75,16 +76,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.glutenFree == true) if (tags.glutenFree == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_glutenFree.png', 'img/i_glutenFree.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Bezglutenowe', 'Bezglutenowe',
@@ -94,16 +95,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.petFriendly == true) if (tags.petFriendly == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_pets.png', 'img/i_pets.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Lubimy', 'Lubimy',
@@ -117,16 +118,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.vegan == true) if (tags.vegan == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_vegan.png', 'img/i_vegan.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Wegańskie', 'Wegańskie',
@@ -136,16 +137,16 @@ class LineOfIcons extends StatelessWidget {
)), )),
if (tags.vegetarian == true) if (tags.vegetarian == true)
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(edgeInsets),
child: Column( child: Column(
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
'img/i_vegetarian.png', 'img/i_vegetarian.png',
width: 20, width: 18,
), ),
height: 30, height: 26,
), ),
Text( Text(
'Wegetariańskie', 'Wegetariańskie',

View File

@@ -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: <Widget>[
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,
),
],
)),
],
);
}
}

View File

@@ -1,62 +1,110 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'restaurantView.dart'; import 'restaurantView.dart';
import 'package:menui_mobile/services.dart'; import 'package:menui_mobile/services.dart';
import 'lineOfIconsSmall.dart';
class RestaurantCard extends StatelessWidget { class RestaurantCard extends StatelessWidget {
RestaurantCard({@required this.restaurant}); RestaurantCard({@required this.restaurant});
final _services = new MenuiServices();
final Restaurant restaurant; final Restaurant restaurant;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String _openHours = _services.getTodayHours(restaurant.workingHours);
return Card( return Card(
child: InkWell( child: InkWell(
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => RestaurantView(restaurant: restaurant))), builder: (context) => RestaurantView(id: restaurant.id))),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Container( Container(
child: ClipRRect( child: ClipRRect(
child: Image.network( child: Image.network(
restaurant.imgUrl, restaurant.imgUrl,
width: 80, width: 100,
height: 80, height: 100,
fit: BoxFit.cover, 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( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Text( Text(
restaurant.name, restaurant.name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( maxLines: 1,
color: Colors.orange[600], fontSize: 16, height: 1.6), style: TextStyle(color: Colors.orange[600], fontSize: 16),
), ),
Container( Container(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Row(
'Miasto: ${restaurant.city}', crossAxisAlignment: CrossAxisAlignment.center,
overflow: TextOverflow.ellipsis, children: <Widget>[
style: TextStyle(color: Colors.grey, fontSize: 14), Icon(
Icons.location_city,
size: 14,
color: Colors.white,
), ),
Text( Padding(
restaurant.description, padding: EdgeInsets.only(left: 4),
overflow: TextOverflow.ellipsis, child: Text(
maxLines: 2, '${restaurant.city}, ${restaurant.adress}',
style: TextStyle(color: Colors.grey, fontSize: 14), style:
TextStyle(color: Colors.grey, fontSize: 12),
), ),
),
]),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
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: <Widget>[
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( Container(
child: Icon( child: Icon(
Icons.arrow_right, Icons.arrow_right,
color: Colors.orange, color: Colors.white,
size: 28,
), ),
) )
], ],

View File

@@ -3,18 +3,23 @@ import '../services.dart';
import 'lineOfIcons.dart'; import 'lineOfIcons.dart';
class RestaurantView extends StatelessWidget { class RestaurantView extends StatelessWidget {
final Restaurant restaurant; final String id;
final MenuiServices services = new MenuiServices();
RestaurantView({@required this.restaurant}); RestaurantView({@required this.id});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.grey[850]),
image: DecorationImage( child: FutureBuilder<Restaurant>(
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)), future: services.fetchRestaurant(id),
child: Column( builder:
(BuildContext context, AsyncSnapshot<Restaurant> snapshot) {
if (snapshot.hasData) {
final Restaurant restaurant = snapshot.data;
return Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
@@ -37,9 +42,11 @@ class RestaurantView extends StatelessWidget {
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[850], color: Colors.grey[850],
borderRadius: BorderRadius.all(Radius.circular(8))), borderRadius:
BorderRadius.all(Radius.circular(8))),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
restaurant.name, restaurant.name,
@@ -81,13 +88,202 @@ class RestaurantView extends StatelessWidget {
LineOfIcons( LineOfIcons(
tags: restaurant.tags, tags: restaurant.tags,
), ),
Text('1234') 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,
),
], ],
), ),
) )
], ],
);
} 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: <Widget>[
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: <Widget>[
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),
])
],
);
}
}

View File

@@ -83,13 +83,14 @@ class MenuiSearchBarState extends State<MenuiSearchBar> {
child: Stack( child: Stack(
children: [ children: [
Positioned( Positioned(
width: size.width, width: size.width * 0.94,
child: CompositedTransformFollower( child: CompositedTransformFollower(
offset: Offset(0.0, size.height + 5.0), offset: Offset(size.width * 0.03, size.height),
link: layerLink, link: layerLink,
showWhenUnlinked: false, showWhenUnlinked: false,
child: Material( child: Material(
color: Colors.grey[800], color: Colors.grey[850],
borderRadius: BorderRadius.circular(20),
elevation: 4.0, elevation: 4.0,
child: ConstrainedBox( child: ConstrainedBox(
constraints: new BoxConstraints(maxHeight: 200), constraints: new BoxConstraints(maxHeight: 200),
@@ -103,9 +104,13 @@ class MenuiSearchBarState extends State<MenuiSearchBar> {
_controller.text = suggestions[index]; _controller.text = suggestions[index];
searchRestaurantsByString(); searchRestaurantsByString();
}, },
leading: Icon(
Icons.search_rounded,
color: Colors.grey,
),
title: Text( title: Text(
suggestions[index], suggestions[index],
style: TextStyle(color: Colors.orange), style: TextStyle(color: Colors.grey),
), ),
); );
}), }),
@@ -135,18 +140,17 @@ class MenuiSearchBarState extends State<MenuiSearchBar> {
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: TextFormField( child: TextFormField(
controller: _controller, controller: _controller,
//onChanged: (text) => fetchAutocomplete(text),
style: TextStyle(color: Colors.orange), style: TextStyle(color: Colors.orange),
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: borderSide:
BorderSide(color: Colors.grey, width: 1.0), BorderSide(color: Colors.grey, width: 1.0),
borderRadius: BorderRadius.circular(12)), borderRadius: BorderRadius.circular(16)),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: borderSide:
BorderSide(color: Colors.orange, width: 2.0), BorderSide(color: Colors.orange, width: 2.0),
borderRadius: BorderRadius.circular(12)), borderRadius: BorderRadius.circular(20)),
hintText: 'Wyszukaj miasto lub nazwę restauracji.', hintText: 'Wyszukaj miasto lub nazwę restauracji.',
suffixIcon: Icon( suffixIcon: Icon(
Icons.search, Icons.search,

View File

@@ -23,7 +23,7 @@ class SearchResults extends StatelessWidget {
height: 30, height: 30,
), ),
Image.asset( Image.asset(
"img/logo_mint.png", "img/logo_orange.png",
width: 60, width: 60,
), ),
MenuiSearchBar(), MenuiSearchBar(),

View File

@@ -38,6 +38,62 @@ class MenuiServices {
} }
} }
Future<Restaurant> 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<MenuiLunchMenuSet> 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<List<Restaurant>> fetchSearchByString(String text) async { Future<List<Restaurant>> fetchSearchByString(String text) async {
final response = await http.get('${backendURL}search?string=$text'); final response = await http.get('${backendURL}search?string=$text');
if (response.statusCode == 200 || response.statusCode == 304) { if (response.statusCode == 200 || response.statusCode == 304) {
@@ -46,7 +102,6 @@ class MenuiServices {
for (var restaurant in decoded) { for (var restaurant in decoded) {
final workingHours = restaurant['workingHours']; final workingHours = restaurant['workingHours'];
final tags = restaurant['tags']; final tags = restaurant['tags'];
final links = restaurant['links'];
final List responseLunchMenu = restaurant['lunchMenu']; final List responseLunchMenu = restaurant['lunchMenu'];
List<MenuiLunchMenuSet> lunchMenu = []; List<MenuiLunchMenuSet> lunchMenu = [];
if (responseLunchMenu != null) { if (responseLunchMenu != null) {
@@ -63,6 +118,7 @@ class MenuiServices {
name: restaurant['name'], name: restaurant['name'],
city: restaurant['city'], city: restaurant['city'],
adress: restaurant['adress'], adress: restaurant['adress'],
type: restaurant['type'],
coordinates: restaurant['coordinates'], coordinates: restaurant['coordinates'],
imgUrl: restaurant['imgUrl'], imgUrl: restaurant['imgUrl'],
placesId: restaurant['placesId'], placesId: restaurant['placesId'],
@@ -83,10 +139,6 @@ class MenuiServices {
tags['vegetarian'], tags['vegetarian'],
tags['alcohol'], tags['alcohol'],
tags['delivery']), tags['delivery']),
links: new MenuiLinks(
links['facebook'], links['instagram'], links['www']),
phone: restaurant['phone'],
categories: restaurant['categories'],
lunchHours: restaurant['lunchHours'], lunchHours: restaurant['lunchHours'],
lunchMenu: lunchMenu, lunchMenu: lunchMenu,
dishes: restaurant['dishes']); dishes: restaurant['dishes']);
@@ -97,6 +149,43 @@ class MenuiServices {
return []; 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 // DATA TYPES
@@ -106,6 +195,7 @@ class Restaurant {
String name; String name;
String city; String city;
String adress; String adress;
String type;
List coordinates; List coordinates;
String placesId; String placesId;
String imgUrl; String imgUrl;
@@ -124,6 +214,7 @@ class Restaurant {
@required this.name, @required this.name,
@required this.city, @required this.city,
@required this.adress, @required this.adress,
@required this.type,
@required this.coordinates, @required this.coordinates,
this.placesId, this.placesId,
@required this.imgUrl, @required this.imgUrl,