diff --git a/lib/components/dishList.dart b/lib/components/dishList.dart index 8320d06..804ebab 100644 --- a/lib/components/dishList.dart +++ b/lib/components/dishList.dart @@ -62,23 +62,23 @@ class DishList extends StatelessWidget { Positioned.fill( bottom: 20, child: Align( - alignment: Alignment.bottomCenter, - child: FloatingActionButton.extended( - backgroundColor: Colors.grey[900], - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.keyboard_arrow_down_rounded, - color: Colors.orange, - ), - label: Text( - 'Zamknij', - style: - TextStyle(color: Colors.white, fontWeight: FontWeight.w400), - ), - ), - )) + alignment: Alignment.bottomCenter, + child: RaisedButton.icon( + splashColor: Colors.orange, + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25)), + color: Colors.grey[900], + icon: Icon( + Icons.keyboard_arrow_down_rounded, + color: Colors.orange, + ), + label: Text( + "Zwiń", + style: TextStyle(color: Colors.white), + ), + onPressed: () => Navigator.pop(context), + ))) ]); } @@ -92,61 +92,3 @@ class DishList extends StatelessWidget { return result; } } - -/* -class DishList extends StatelessWidget { - final String id; - final List categories; - DishList({@required this.id, @required this.categories}); - - final MenuiServices services = new MenuiServices(); - - @override - Widget build(BuildContext context) { - return ListView(children: [ - FutureBuilder>( - future: services.fetchAllDishes(id), - builder: (BuildContext context, AsyncSnapshot> snapshot) { - if (snapshot.hasData) { - final List dishes = snapshot.data; - return ListView.builder( - controller: ScrollController(), - shrinkWrap: true, - itemCount: categories.length, - itemBuilder: (context, index) { - final filteredDishes = - filterDishesByCategory(dishes, categories[index]); - return ExpansionTile( - leading: Icon( - Icons.fastfood_rounded, - color: Colors.orange, - ), - title: Text( - categories[index], - style: TextStyle(color: Colors.grey[300]), - ), - children: [ - ListView.builder( - primary: false, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: filteredDishes.length, - itemBuilder: (context, index) { - return Container( - child: DishCard(dish: filteredDishes[index]), - ); - }, - ) - ], - ); - }, - ); - } else { - return Center( - child: CircularProgressIndicator(), - ); - } - }), - - ]); - } */ diff --git a/lib/components/dishView.dart b/lib/components/dishView.dart index e3a6b90..66dcc46 100644 --- a/lib/components/dishView.dart +++ b/lib/components/dishView.dart @@ -2,232 +2,270 @@ import 'package:flutter/material.dart'; import 'package:menui_mobile/services.dart'; import 'lineOfAllergens.dart'; import 'iconChip.dart'; +import 'orderView.dart'; +import 'favoritesView.dart'; +import '../settings.dart'; +import 'homeScreen.dart'; +import 'package:share/share.dart'; +import 'menuiButton.dart'; class DishView extends StatelessWidget { final Dish dish; DishView({@required this.dish}); + final MenuiSettings settings = new MenuiSettings(); @override Widget build(BuildContext context) { return Scaffold( - body: Container( - decoration: BoxDecoration(color: Colors.grey[850]), - child: ListView( - children: [ - Column( - children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - dish.imgUrl, - ), - fit: BoxFit.cover), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 160, - width: double.infinity, + body: Container( + decoration: BoxDecoration(color: Colors.grey[850]), + child: ListView( + children: [ + Column( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + dish.imgUrl, ), - Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.grey[850], - borderRadius: - BorderRadius.all(Radius.circular(8))), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.restaurant, - color: Colors.orange, - ), - SizedBox( - width: 8, - ), - Text( - dish.name, - style: TextStyle( - fontSize: 24, - color: Colors.white, - fontWeight: FontWeight.w300), - ), - ], - ), - margin: EdgeInsets.all(12), - ) - ], - ), + fit: BoxFit.cover), ), - SizedBox( - height: 6, - ), - if (dish.allergens.hasAllergens()) SizedBox(height: 8), - if (dish.allergens.hasAllergens()) - Text( - 'Może zawierać', - style: TextStyle(color: Colors.orange, fontSize: 14), - ), - Allergens(allergens: dish.allergens), - if (dish.allergens.hasAllergens()) - Divider( - height: 14, - thickness: 4, - ), - SizedBox( - height: 8, - ), - Prices(prices: dish.prices), - SizedBox( - height: 8, - ), - Divider( - height: 14, - thickness: 4, - ), - SizedBox( - height: 6, - ), - Text( - 'Składniki', - style: TextStyle(color: Colors.orange, fontSize: 14), - ), - SizedBox( - height: 12, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Text( - '${dish.ingredients}', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - textAlign: TextAlign.center, - ), - ), - SizedBox( - height: 6, - ), - Divider( - height: 14, - thickness: 4, - ), - SizedBox( - height: 6, - ), - Wrap( - spacing: 10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - IconChip( - icon: Icons.battery_charging_full, - leading: "Wartość energetyczna", - value: (() { - if (dish.kCal != "") { - return dish.kCal + " kcal"; - } else { - return ""; - } - }())), - IconChip( - icon: Icons.cake, - leading: "Indeks glikemiczny", - value: dish.glicemicIndex), + SizedBox( + height: 160, + width: double.infinity, + ), + Container( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[900], + borderRadius: + BorderRadius.all(Radius.circular(8))), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.restaurant, + color: Colors.orange, + ), + SizedBox( + width: 8, + ), + Text( + dish.name, + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.w300), + ), + ], + ), + margin: EdgeInsets.all(12), + ) ], ), - SizedBox( - height: 12, + ), + SizedBox( + height: 6, + ), + if (dish.allergens.hasAllergens()) SizedBox(height: 8), + if (dish.allergens.hasAllergens()) + Text( + 'Może zawierać', + style: TextStyle(color: Colors.orange, fontSize: 14), ), - if (dish.notes != "") - Text( - 'Uwagi', - style: TextStyle(color: Colors.orange, fontSize: 14), - ), - SizedBox( - height: 12, + Allergens(allergens: dish.allergens), + if (dish.allergens.hasAllergens()) + Divider( + height: 14, + thickness: 4, ), - if (dish.notes != "") - Text( - '${dish.notes}', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ), - if (dish.vegan) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.info_rounded, - color: Colors.grey, - ), - SizedBox( - width: 6, - ), - Text( - 'Danie wegańskie', - style: TextStyle( - color: Colors.grey[200], fontSize: 12), - ), - ], - ), - if (dish.vegetarian) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.info_rounded, - color: Colors.grey, - ), - SizedBox( - width: 6, - ), - Text( - 'Danie wegetariańskie', - style: TextStyle( - color: Colors.grey[200], fontSize: 12), - ), - ], - ), - ], - ), - SizedBox( - height: 28, - ) - ], - )), - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: Stack( + SizedBox( + height: 8, + ), + Prices(prices: dish.prices), + SizedBox( + height: 8, + ), + Divider( + height: 14, + thickness: 4, + ), + SizedBox( + height: 6, + ), + Text( + 'Składniki', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Text( + '${dish.ingredients}', + style: TextStyle(color: Colors.grey[200], fontSize: 12), + textAlign: TextAlign.center, + ), + ), + SizedBox( + height: 6, + ), + Divider( + height: 14, + thickness: 4, + ), + SizedBox( + height: 6, + ), + Wrap( + spacing: 10, + children: [ + IconChip( + icon: Icons.battery_charging_full, + leading: "Wartość energetyczna", + value: (() { + if (dish.kCal != "") { + return dish.kCal + " kcal"; + } else { + return ""; + } + }())), + IconChip( + icon: Icons.cake, + leading: "Indeks glikemiczny", + value: dish.glicemicIndex), + ], + ), + SizedBox( + height: 12, + ), + if (dish.notes != "") + Text( + 'Uwagi', + style: TextStyle(color: Colors.orange, fontSize: 14), + ), + SizedBox( + height: 12, + ), + if (dish.notes != "") + Text( + '${dish.notes}', + style: TextStyle(color: Colors.grey[200], fontSize: 12), + ), + if (dish.vegan) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.info_rounded, + color: Colors.grey, + ), + SizedBox( + width: 6, + ), + Text( + 'Danie wegańskie', + style: + TextStyle(color: Colors.grey[200], fontSize: 12), + ), + ], + ), + if (dish.vegetarian) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.info_rounded, + color: Colors.grey, + ), + SizedBox( + width: 6, + ), + Text( + 'Danie wegetariańskie', + style: + TextStyle(color: Colors.grey[200], fontSize: 12), + ), + ], + ), + ], + ), + SizedBox( + height: 28, + ) + ], + )), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButton: Container( + decoration: BoxDecoration(color: Colors.grey[900]), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Align( - alignment: Alignment.bottomLeft, - child: Padding( - padding: EdgeInsets.only(left: 18), - child: FloatingActionButton( - heroTag: null, - backgroundColor: Colors.grey[900], - child: Icon( - Icons.arrow_back_rounded, - color: Colors.orange, - ), - onPressed: () => Navigator.pop(context), - ), - ), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", + onPressed: () => Navigator.push( + context, MaterialPageRoute(builder: (context) => HomePage())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => OrderView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => FavoritesView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", + onPressed: () { + showSettings(context, settings); + }, ), - Align( - alignment: Alignment.bottomRight, - child: Padding( - padding: EdgeInsets.only(right: 18), - child: FloatingActionButton( - heroTag: null, - backgroundColor: Colors.grey[900], - child: Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - onPressed: () {}, - ), - ), - ) ], - )); + ), + ), + appBar: AppBar( + backgroundColor: Colors.grey[900], + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios_rounded, + color: Colors.orange, + ), + onPressed: () => Navigator.pop(context), + ), + actions: [ + MenuiButton( + color: Colors.grey, + icon: Icons.share_rounded, + text: "Udostępnij", + onPressed: () => Share.share('https://www.menui.pl/dish/${dish.id}', + subject: '${dish.name}'), + ), + MenuiButton( + color: Colors.grey, + icon: Icons.note_add_rounded, + text: "Do zamówienia", + onPressed: () { + settings.addToOrder(dish.id); + }, + ), + ], + ), + ); } } diff --git a/lib/components/favoriteButton.dart b/lib/components/favoriteButton.dart new file mode 100644 index 0000000..b9d3458 --- /dev/null +++ b/lib/components/favoriteButton.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; +import '../settings.dart'; +import 'menuiButton.dart'; + +class FavoriteButton extends StatefulWidget { + final String id; + + FavoriteButton({@required this.id, Key key}) : super(key: key); + + @override + _FavoriteButtonState createState() => _FavoriteButtonState(); +} + +class _FavoriteButtonState extends State { + final MenuiSettings settings = new MenuiSettings(); + Future isInFavorites; + bool inFavorites = false; + + @override + void initState() { + super.initState(); + isInFavorites = settings.isInFavorites(widget.id); + } + + @override + Widget build(BuildContext context) => FutureBuilder( + initialData: false, + future: isInFavorites, + builder: (context, snapshot) { + if (snapshot.hasData) { + inFavorites = snapshot.data; + if (inFavorites) { + return MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Usuń", + onPressed: () { + settings.addToFavorites(widget.id); + setState(() { + isInFavorites = settings.isInFavorites(widget.id); + }); + }, + ); + } else { + return MenuiButton( + color: Colors.grey, + icon: Icons.favorite_rounded, + text: "Dodaj", + onPressed: () { + settings.addToFavorites(widget.id); + setState(() { + isInFavorites = settings.isInFavorites(widget.id); + }); + }, + ); + } + } else { + return MenuiButton( + color: Colors.grey, + icon: Icons.favorite_rounded, + text: "Dodaj", + onPressed: () {}, + ); + } + }, + ); +} diff --git a/lib/components/favoritesView.dart b/lib/components/favoritesView.dart index b75fb42..f882ff2 100644 --- a/lib/components/favoritesView.dart +++ b/lib/components/favoritesView.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import '../settings.dart'; import 'homeScreen.dart'; import 'orderView.dart'; +import 'menuiButton.dart'; class FavoritesView extends StatelessWidget { final settings = new MenuiSettings(); @@ -16,19 +17,19 @@ class FavoritesView extends StatelessWidget { child: Column( children: [ Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Column( children: [ SizedBox( height: 20, ), Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ RaisedButton( - color: Colors.grey[850], + color: Colors.grey[900], elevation: 0, padding: EdgeInsets.symmetric(vertical: 12, horizontal: 4), @@ -45,7 +46,9 @@ class FavoritesView extends StatelessWidget { Text( 'Cofnij', style: TextStyle( - color: Colors.grey[200], fontSize: 12), + color: Colors.grey[200], + fontSize: 12, + fontWeight: FontWeight.w400), ) ], ), @@ -64,90 +67,38 @@ class FavoritesView extends StatelessWidget { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", onPressed: () => Navigator.push( context, MaterialPageRoute(builder: (context) => HomePage())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => OrderView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", onPressed: () { showSettings(context, settings); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ) + ), ], ), ), diff --git a/lib/components/homeScreen.dart b/lib/components/homeScreen.dart index 2061ad2..ee4d6b7 100644 --- a/lib/components/homeScreen.dart +++ b/lib/components/homeScreen.dart @@ -4,6 +4,7 @@ import '../settings.dart'; import 'mapView.dart'; import 'orderView.dart'; import 'favoritesView.dart'; +import 'menuiButton.dart'; class HomePage extends StatelessWidget { final MenuiSettings settings = new MenuiSettings(); @@ -29,7 +30,7 @@ class HomePage extends StatelessWidget { style: TextStyle(color: Colors.grey[500]), ), RaisedButton.icon( - color: Colors.grey[850], + color: Colors.grey[900], onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => MapView())), icon: Icon( @@ -38,7 +39,7 @@ class HomePage extends StatelessWidget { ), label: Text( 'Pokaż w pobliżu', - style: TextStyle(color: Colors.grey[400]), + style: TextStyle(color: Colors.grey[300]), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50)), @@ -49,102 +50,38 @@ class HomePage extends StatelessWidget { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle( - color: Colors.grey[200], - fontSize: 12, - fontWeight: FontWeight.w400), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => OrderView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle( - color: Colors.grey[200], - fontSize: 12, - fontWeight: FontWeight.w400), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => FavoritesView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle( - color: Colors.grey[200], - fontSize: 12, - fontWeight: FontWeight.w400), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", onPressed: () { showSettings(context, settings); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle( - color: Colors.grey[200], - fontSize: 12, - fontWeight: FontWeight.w400), - ) - ], - ), - ) + ), ], ), ), diff --git a/lib/components/mapView.dart b/lib/components/mapView.dart index ddc3b29..155d667 100644 --- a/lib/components/mapView.dart +++ b/lib/components/mapView.dart @@ -1,9 +1,13 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:menui_mobile/settings.dart'; import '../services.dart'; import 'package:geolocator/geolocator.dart'; import 'restaurantView.dart'; +import 'menuiButton.dart'; +import 'orderView.dart'; +import 'favoritesView.dart'; class MapView extends StatefulWidget { @override @@ -13,6 +17,7 @@ class MapView extends StatefulWidget { class MapViewState extends State { Completer _controller = Completer(); MenuiServices services = new MenuiServices(); + final MenuiSettings settings = new MenuiSettings(); Position position; Future createMarkers() async { @@ -68,15 +73,15 @@ class MapViewState extends State { height: 20, ), Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( - color: Colors.grey[850], + color: Colors.grey[900], elevation: 0, - padding: - EdgeInsets.symmetric(vertical: 12, horizontal: 4), + padding: EdgeInsets.symmetric( + vertical: 12, horizontal: 4), onPressed: () { Navigator.pop(context); }, @@ -90,21 +95,23 @@ class MapViewState extends State { Text( 'Promień', style: TextStyle( - color: Colors.grey[200], fontSize: 12), + color: Colors.grey[200], + fontSize: 12, + fontWeight: FontWeight.w400), ), Text( '600m', - style: - TextStyle(color: Colors.grey, fontSize: 10), + style: TextStyle( + color: Colors.grey, fontSize: 10), ) ], ), ), RaisedButton( - color: Colors.grey[850], + color: Colors.grey[900], elevation: 0, - padding: - EdgeInsets.symmetric(vertical: 12, horizontal: 4), + padding: EdgeInsets.symmetric( + vertical: 12, horizontal: 4), onPressed: () { Navigator.pop(context); }, @@ -118,21 +125,23 @@ class MapViewState extends State { Text( 'Kuchnia', style: TextStyle( - color: Colors.grey[200], fontSize: 12), + color: Colors.grey[200], + fontSize: 12, + fontWeight: FontWeight.w400), ), Text( 'Wszystkie', - style: - TextStyle(color: Colors.grey, fontSize: 10), + style: TextStyle( + color: Colors.grey, fontSize: 10), ) ], ), ), RaisedButton( - color: Colors.grey[850], + color: Colors.grey[900], elevation: 0, - padding: - EdgeInsets.symmetric(vertical: 12, horizontal: 4), + padding: EdgeInsets.symmetric( + vertical: 12, horizontal: 4), onPressed: () { Navigator.pop(context); }, @@ -146,12 +155,14 @@ class MapViewState extends State { Text( 'Filtry', style: TextStyle( - color: Colors.grey[200], fontSize: 12), + color: Colors.grey[200], + fontSize: 12, + fontWeight: FontWeight.w400), ), Text( 'Brak', - style: - TextStyle(color: Colors.grey, fontSize: 10), + style: TextStyle( + color: Colors.grey, fontSize: 10), ) ], ), @@ -160,9 +171,7 @@ class MapViewState extends State { ), ), Container( - decoration: BoxDecoration( - color: Colors.grey[700] - ), + decoration: BoxDecoration(color: Colors.grey[800]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -172,7 +181,8 @@ class MapViewState extends State { ), Text( 'Znaleziono: ${data.markers.length}', - style: TextStyle(color: Colors.white, fontSize: 12), + style: + TextStyle(color: Colors.white, fontSize: 12), ), ], ), @@ -191,88 +201,42 @@ class MapViewState extends State { ), ), Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", + onPressed: () => Navigator.pop(context), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrderView())), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FavoritesView())), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", onPressed: () { - //showSettings(context); + showSettings(context, settings); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ) + ), ], ), ), diff --git a/lib/components/menuiButton.dart b/lib/components/menuiButton.dart new file mode 100644 index 0000000..8ea39be --- /dev/null +++ b/lib/components/menuiButton.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +class MenuiButton extends StatelessWidget { + final Color color; + final String text; + final IconData icon; + final Function onPressed; + + MenuiButton( + {@required this.color, + @required this.icon, + @required this.text, + @required this.onPressed}); + + @override + Widget build(BuildContext context) { + return RaisedButton( + splashColor: Colors.orange, + color: Colors.grey[900], + elevation: 0, + padding: EdgeInsets.all(8), + onPressed: onPressed, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + icon, + color: color, + ), + Text( + text, + style: TextStyle( + color: Colors.grey[200], + fontSize: 10, + fontWeight: FontWeight.w400), + ) + ], + ), + ); + } +} diff --git a/lib/components/orderView.dart b/lib/components/orderView.dart index 5e92e62..3afc70b 100644 --- a/lib/components/orderView.dart +++ b/lib/components/orderView.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import '../settings.dart'; import 'homeScreen.dart'; import 'favoritesView.dart'; +import 'menuiButton.dart'; class OrderView extends StatelessWidget { final settings = new MenuiSettings(); @@ -23,57 +24,25 @@ class OrderView extends StatelessWidget { height: 20, ), Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: - EdgeInsets.symmetric(vertical: 12, horizontal: 4), - onPressed: () { - Navigator.pop(context); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.arrow_back_rounded, - color: Colors.orange, - ), - Text( - 'Cofnij', - style: TextStyle( - color: Colors.grey[200], fontSize: 12), - ) - ], - ), + MenuiButton( + color: Colors.orange, + onPressed: () => Navigator.pop(context), + text: "Cofnij", + icon: Icons.arrow_back_rounded, ), Row( children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.symmetric( - vertical: 12, horizontal: 4), + MenuiButton( + color: Colors.orange, onPressed: () { settings.clearOrder(); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.delete_forever_rounded, - color: Colors.orange, - ), - Text( - 'Wyczyść', - style: TextStyle( - color: Colors.grey[200], fontSize: 12), - ), - ], - ), + text: "Wyczyść", + icon: Icons.delete_forever_rounded, ), ], ) @@ -81,7 +50,7 @@ class OrderView extends StatelessWidget { ), ), Container( - decoration: BoxDecoration(color: Colors.grey[700]), + decoration: BoxDecoration(color: Colors.grey[800]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -104,90 +73,38 @@ class OrderView extends StatelessWidget { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", onPressed: () => Navigator.push( context, MaterialPageRoute(builder: (context) => HomePage())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => FavoritesView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", onPressed: () { showSettings(context, settings); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ) + ), ], ), ), diff --git a/lib/components/restaurantCard.dart b/lib/components/restaurantCard.dart index 4728919..cd56a6a 100644 --- a/lib/components/restaurantCard.dart +++ b/lib/components/restaurantCard.dart @@ -37,80 +37,79 @@ class RestaurantCard extends StatelessWidget { padding: EdgeInsets.only(right: 8), ), Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Text( - restaurant.name, - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle(color: Colors.orange[600], fontSize: 16), - ), - Container( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - Icons.location_city, - size: 14, - color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 4), + child: Text( + restaurant.name, + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: + TextStyle(color: Colors.orange[600], 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: 11), ), - 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: 11), ), - ]), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - Icons.restaurant, - size: 14, - color: Colors.white, + ), + ]), + 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: 11), ), - 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), - ) - ], - )), - ], - )), + ), + ]), + Padding( + padding: EdgeInsets.only(top: 2), + child: LineOfIconsSmall(tags: restaurant.tags), + ) + ], + ), + ), Container( child: Icon( Icons.arrow_right, @@ -121,8 +120,8 @@ class RestaurantCard extends StatelessWidget { ], ), ), - color: Color.fromRGBO(50, 50, 50, 0.8), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + color: Colors.grey[900], + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(11)), margin: EdgeInsets.symmetric(horizontal: 12), ), ); diff --git a/lib/components/restaurantMapView.dart b/lib/components/restaurantMapView.dart index fd43498..6113dd6 100644 --- a/lib/components/restaurantMapView.dart +++ b/lib/components/restaurantMapView.dart @@ -1,6 +1,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:menui_mobile/settings.dart'; +import 'orderView.dart'; +import 'favoritesView.dart'; +import 'homeScreen.dart'; +import 'menuiButton.dart'; class RestaurantMapView extends StatefulWidget { final List coordinates; @@ -15,6 +20,7 @@ class RestaurantMapView extends StatefulWidget { } class RestaurantMapViewState extends State { + final MenuiSettings settings = new MenuiSettings(); Completer _controller = Completer(); Map markers = {}; @@ -43,20 +49,54 @@ class RestaurantMapViewState extends State { }, markers: Set.of(markers.values), ), - floatingActionButton: Padding( - padding: EdgeInsets.only(bottom: 20), - child: FloatingActionButton( - backgroundColor: Colors.grey[800], - onPressed: () { - Navigator.pop(context); - }, - child: Icon( - Icons.arrow_back_outlined, - color: Colors.orange, - ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButton: Container( + decoration: BoxDecoration(color: Colors.grey[900]), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", + onPressed: () => Navigator.push( + context, MaterialPageRoute(builder: (context) => HomePage())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => OrderView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => FavoritesView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", + onPressed: () { + showSettings(context, settings); + }, + ), + ], + ), + ), + appBar: AppBar( + backgroundColor: Colors.grey[900], + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios_rounded, + color: Colors.orange, + ), + onPressed: () => Navigator.pop(context), ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.startDocked, ); } } diff --git a/lib/components/restaurantView.dart b/lib/components/restaurantView.dart index 5a58286..247909c 100644 --- a/lib/components/restaurantView.dart +++ b/lib/components/restaurantView.dart @@ -8,30 +8,36 @@ import 'orderView.dart'; import 'favoritesView.dart'; import '../settings.dart'; import 'homeScreen.dart'; +import 'package:share/share.dart'; +import 'favoriteButton.dart'; +import 'menuiButton.dart'; -class RestaurantView extends StatelessWidget { +class RestaurantView extends StatefulWidget { final String id; + + RestaurantView({@required this.id, Key key}) : super(key: key); + + _RestaurantViewState createState() => _RestaurantViewState(); +} + +class _RestaurantViewState extends State { final MenuiServices services = new MenuiServices(); final MenuiSettings settings = new MenuiSettings(); - - RestaurantView({@required this.id}); + Restaurant restaurant = new Restaurant.empty(); @override Widget build(BuildContext context) { - services.fetchAllDishes(id); List categories = []; - Restaurant restaurant; - return Scaffold( - body: Container( - decoration: BoxDecoration(color: Colors.grey[850]), - child: FutureBuilder( - future: services.fetchRestaurant(id), - builder: - (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { - restaurant = snapshot.data; - categories = restaurant.categories; - return ListView( + return FutureBuilder( + future: services.fetchRestaurant(widget.id), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + restaurant = snapshot.data; + categories = restaurant.categories; + return Scaffold( + body: Container( + decoration: BoxDecoration(color: Colors.grey[850]), + child: ListView( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, @@ -55,7 +61,7 @@ class RestaurantView extends StatelessWidget { Container( padding: EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.grey[850], + color: Colors.grey[900], borderRadius: BorderRadius.all( Radius.circular(8))), child: Column( @@ -171,204 +177,130 @@ class RestaurantView extends StatelessWidget { ], ) ], - ); - } else { - return Center( - child: CircularProgressIndicator(), - ); - } - }, - )), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - floatingActionButton: Container( - decoration: BoxDecoration(color: Colors.grey[850]), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push( - context, MaterialPageRoute(builder: (context) => HomePage())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push(context, - MaterialPageRoute(builder: (context) => OrderView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push(context, - MaterialPageRoute(builder: (context) => FavoritesView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () { - showSettings(context, settings); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ) - ], - ), - ), - appBar: AppBar( - backgroundColor: Colors.grey[850], - leading: IconButton( - icon: Icon( - Icons.arrow_back_ios_rounded, - color: Colors.orange, - ), - onPressed: () => Navigator.pop(context), - ), - actions: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => RestaurantMapView( - coordinates: restaurant.coordinates, - name: restaurant.name, - type: restaurant.type, - ))), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.map_rounded, - color: Colors.orange, ), - Text( - 'Mapa', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push( - context, MaterialPageRoute(builder: (context) => OrderView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.share_rounded, - color: Colors.orange, + ), + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, + floatingActionButton: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RaisedButton.icon( + splashColor: Colors.orange, + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25)), + color: Colors.grey[900], + icon: Icon( + Icons.keyboard_arrow_up_rounded, + color: Colors.orange, + ), + label: Text( + "Karta dań", + style: TextStyle(color: Colors.white), + ), + onPressed: () => + showMenu(context, restaurant.categories), + ) + ], + ), + ), + Container( + decoration: BoxDecoration(color: Colors.grey[900]), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => HomePage())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrderView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FavoritesView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", + onPressed: () { + showSettings(context, settings); + }, + ), + ], + ), + ), + ], + ), + appBar: AppBar( + backgroundColor: Colors.grey[900], + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios_rounded, + color: Colors.orange, + ), + onPressed: () => Navigator.pop(context), ), - Text( - 'Udostępnij', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () => Navigator.push( - context, MaterialPageRoute(builder: (context) => OrderView())), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Dodaj', - style: TextStyle( - color: Colors.grey[200], - fontSize: 10, - fontWeight: FontWeight.w400), - ) - ], - ), - ), - ], - ), - ); + actions: [ + MenuiButton( + color: Colors.grey, + icon: Icons.map_rounded, + text: "Mapa", + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => RestaurantMapView( + coordinates: restaurant.coordinates, + name: restaurant.name, + type: restaurant.type, + ))), + ), + MenuiButton( + color: Colors.grey, + icon: Icons.share_rounded, + text: "Udostępnij", + onPressed: () => Share.share( + 'https://www.menui.pl/restaurant/${restaurant.id}', + subject: '${restaurant.name}'), + ), + FavoriteButton( + id: restaurant.id, + ) + ], + ), + ); + } else { + return Scaffold( + body: Container( + decoration: BoxDecoration(color: Colors.grey[850]), + child: Center( + child: CircularProgressIndicator(), + ), + )); + } + }); } showMenu(BuildContext context, List categories) { @@ -380,7 +312,7 @@ class RestaurantView extends StatelessWidget { builder: (BuildContext context) { return DishList( categories: categories, - id: id, + id: widget.id, ); }); } @@ -456,7 +388,7 @@ class WorkingHoursDay extends StatelessWidget { Divider( height: 4, thickness: 1, - color: Colors.grey[850], + color: Colors.white, ), SizedBox( height: 4, diff --git a/lib/components/searchResults.dart b/lib/components/searchResults.dart index 9b2941d..b9bb88d 100644 --- a/lib/components/searchResults.dart +++ b/lib/components/searchResults.dart @@ -2,9 +2,15 @@ import '../services.dart'; import 'package:flutter/material.dart'; import 'package:menui_mobile/components/restaurantCard.dart'; import 'searchBar.dart'; +import 'menuiButton.dart'; +import 'homeScreen.dart'; +import 'orderView.dart'; +import 'favoritesView.dart'; +import '../settings.dart'; class SearchResults extends StatelessWidget { final List restaurants; + final MenuiSettings settings = new MenuiSettings(); SearchResults({@required this.restaurants}); @@ -51,88 +57,39 @@ class SearchResults extends StatelessWidget { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: Container( - decoration: BoxDecoration(color: Colors.grey[850]), + decoration: BoxDecoration(color: Colors.grey[900]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.symmetric(vertical: 12, horizontal: 4), + MenuiButton( + color: Colors.orange, + icon: Icons.home_rounded, + text: "Szukaj", + onPressed: () => Navigator.push( + context, MaterialPageRoute(builder: (context) => HomePage())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.note_rounded, + text: "Zamównienie", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => OrderView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.favorite_rounded, + text: "Ulubione", + onPressed: () => Navigator.push(context, + MaterialPageRoute(builder: (context) => FavoritesView())), + ), + MenuiButton( + color: Colors.orange, + icon: Icons.settings, + text: "Ustawienia", onPressed: () { - Navigator.pop(context); + showSettings(context, settings); }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.home_rounded, - color: Colors.orange, - ), - Text( - 'Szukaj', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.note_rounded, - color: Colors.orange, - ), - Text( - 'Zamówienie', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.favorite_rounded, - color: Colors.orange, - ), - Text( - 'Ulubione', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ), - RaisedButton( - color: Colors.grey[850], - elevation: 0, - padding: EdgeInsets.all(8), - onPressed: () {}, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.settings, - color: Colors.orange, - ), - Text( - 'Ustawienia', - style: TextStyle(color: Colors.grey[200], fontSize: 12), - ) - ], - ), - ) ], ), ), diff --git a/lib/services.dart b/lib/services.dart index 7c1ff5f..53ec403 100644 --- a/lib/services.dart +++ b/lib/services.dart @@ -338,6 +338,15 @@ class Restaurant { this.lunchHours, this.lunchMenu, this.dishes}); + + Restaurant.empty( + {this.adress = "", + this.city = "", + this.coordinates = const [], + this.id = "", + this.imgUrl = "", + this.name = "", + this.type = ""}); } class Dish { diff --git a/lib/settings.dart b/lib/settings.dart index 3a79e01..5571462 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -114,9 +114,53 @@ class MenuiSettings { final settings = await SharedPreferences.getInstance(); settings.setStringList('order', new List()); } + + // ADD TO FAVORITES (OR REMOVE) + void addToFavorites(String id) async { + final settings = await SharedPreferences.getInstance(); + if (settings.containsKey('favorites')) { + List favorites = settings.getStringList('favorites'); + if (favorites.contains(id)) { + favorites.remove(id); + settings.setStringList('favorites', favorites); + } else { + favorites.add(id); + settings.setStringList('favorites', favorites); + } + } else { + List favorites = new List(); + favorites.add(id); + settings.setStringList('favorites', favorites); + } + } + + // GET FAVORITES + Future> getFavs() async { + final settings = await SharedPreferences.getInstance(); + if (settings.containsKey('favorites')) { + return settings.getStringList('favorites'); + } else { + return []; + } + } + + // CHECK IF ID IS IN FAVORITES + Future isInFavorites(String id) async { + final settings = await SharedPreferences.getInstance(); + if (settings.containsKey('favorites')) { + List favorites = settings.getStringList('favorites'); + if (favorites.contains(id)) { + return true; + } else { + return false; + } + } else { + return false; + } + } } -showSettings(BuildContext context, MenuiSettings settings) async { +void showSettings(BuildContext context, MenuiSettings settings) async { FocusManager.instance.primaryFocus.unfocus(); final String languageCode = await settings.getLanguage(); final String language = settings.decodeLanguage(languageCode); diff --git a/pubspec.lock b/pubspec.lock index 1e9af48..1983468 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -163,6 +163,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.3" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7" package_info: dependency: "direct main" description: @@ -226,6 +233,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.13" + share: + dependency: "direct main" + description: + name: share + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.5+4" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index cf8914c..c2a5d56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,6 +21,7 @@ environment: sdk: ">=2.7.0 <3.0.0" dependencies: + share: '>=0.6.5+4 <2.0.0' http: ^0.12.2 geolocator: ^6.1.0 font_awesome_flutter: ^8.10.0