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

View File

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

View File

@@ -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: <Widget>[
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',

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 '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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <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(
child: Icon(
Icons.arrow_right,
color: Colors.orange,
color: Colors.white,
size: 28,
),
)
],

View File

@@ -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: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
restaurant.imgUrl,
),
fit: BoxFit.cover)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 160,
),
Row(
body: Container(
decoration: BoxDecoration(color: Colors.grey[850]),
child: FutureBuilder<Restaurant>(
future: services.fetchRestaurant(id),
builder:
(BuildContext context, AsyncSnapshot<Restaurant> snapshot) {
if (snapshot.hasData) {
final Restaurant restaurant = snapshot.data;
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
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: <Widget>[
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: <Widget>[
Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[850],
borderRadius:
BorderRadius.all(Radius.circular(8))),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
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: <Widget>[
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: <Widget>[
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: <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(
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<MenuiSearchBar> {
_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<MenuiSearchBar> {
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,

View File

@@ -23,7 +23,7 @@ class SearchResults extends StatelessWidget {
height: 30,
),
Image.asset(
"img/logo_mint.png",
"img/logo_orange.png",
width: 60,
),
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 {
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<MenuiLunchMenuSet> 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,