bottom and top bars
This commit is contained in:
156
lib/components/favoritesView.dart
Normal file
156
lib/components/favoritesView.dart
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../settings.dart';
|
||||||
|
import 'homeScreen.dart';
|
||||||
|
import 'orderView.dart';
|
||||||
|
|
||||||
|
class FavoritesView extends StatelessWidget {
|
||||||
|
final settings = new MenuiSettings();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
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: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_back_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Cofnij',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200], fontSize: 12),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
|
floatingActionButton: Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: () => Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => OrderView())),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: () {
|
||||||
|
showSettings(context, settings);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.settings,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Ustawienia',
|
||||||
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'searchBar.dart';
|
import 'searchBar.dart';
|
||||||
import '../settings.dart';
|
import '../settings.dart';
|
||||||
import 'mapView.dart';
|
import 'mapView.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'orderView.dart';
|
||||||
|
import 'favoritesView.dart';
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
final MenuiSettings settings = new MenuiSettings();
|
final MenuiSettings settings = new MenuiSettings();
|
||||||
@@ -66,7 +67,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Szukaj',
|
'Szukaj',
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -75,9 +79,8 @@ class HomePage extends StatelessWidget {
|
|||||||
color: Colors.grey[850],
|
color: Colors.grey[850],
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
onPressed: () {
|
onPressed: () => Navigator.push(context,
|
||||||
showSettings(context);
|
MaterialPageRoute(builder: (context) => OrderView())),
|
||||||
},
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -87,7 +90,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Zamówienie',
|
'Zamówienie',
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -96,9 +102,8 @@ class HomePage extends StatelessWidget {
|
|||||||
color: Colors.grey[850],
|
color: Colors.grey[850],
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
onPressed: () {
|
onPressed: () => Navigator.push(context,
|
||||||
showSettings(context);
|
MaterialPageRoute(builder: (context) => FavoritesView())),
|
||||||
},
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -108,7 +113,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Ulubione',
|
'Ulubione',
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -118,7 +126,7 @@ class HomePage extends StatelessWidget {
|
|||||||
elevation: 0,
|
elevation: 0,
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showSettings(context);
|
showSettings(context, settings);
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -129,7 +137,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Ustawienia',
|
'Ustawienia',
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -139,317 +150,4 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHOW SETTINGS
|
|
||||||
|
|
||||||
showSettings(BuildContext context) async {
|
|
||||||
FocusManager.instance.primaryFocus.unfocus();
|
|
||||||
final String languageCode = await settings.getLanguage();
|
|
||||||
final String language = settings.decodeLanguage(languageCode);
|
|
||||||
final int radius = await settings.getRadius();
|
|
||||||
final bool recommendationsValue = await settings.getRecommendations();
|
|
||||||
final recommendations = settings.decodeBool(recommendationsValue);
|
|
||||||
|
|
||||||
showModalBottomSheet(
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(24), topRight: Radius.circular(24))),
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return ListView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: NeverScrollableScrollPhysics(),
|
|
||||||
children: <Widget>[
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Język',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
language,
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
leading: Icon(
|
|
||||||
Icons.language,
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
showLanguageSelectionDialog(context);
|
|
||||||
}),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Promień lokalizacji',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle:
|
|
||||||
Text('${radius}m', style: TextStyle(color: Colors.grey)),
|
|
||||||
leading: Icon(
|
|
||||||
Icons.location_searching_rounded,
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
showRadiusSelectionDialog(context);
|
|
||||||
}),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Proponuj restauracje',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(recommendations,
|
|
||||||
style: TextStyle(color: Colors.grey)),
|
|
||||||
leading: Icon(
|
|
||||||
Icons.notifications,
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
showRecommendationsDialog(context);
|
|
||||||
}),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'O aplikacji',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
leading: Icon(
|
|
||||||
Icons.info,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
showAppInfoDialog(context);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// SELECT LANGUAGE
|
|
||||||
|
|
||||||
void showLanguageSelectionDialog(BuildContext context) async {
|
|
||||||
final currentLanguage = await settings.getLanguage();
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: Text(
|
|
||||||
'Język',
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
children: <Widget>[
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
settings.setLanguage('pl');
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'Polski',
|
|
||||||
style:
|
|
||||||
TextStyle(color: getOptionColor(currentLanguage, 'pl')),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
settings.setLanguage('en');
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'English',
|
|
||||||
style:
|
|
||||||
TextStyle(color: getOptionColor(currentLanguage, 'en')),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
settings.setLanguage('de');
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'Deutsch',
|
|
||||||
style:
|
|
||||||
TextStyle(color: getOptionColor(currentLanguage, 'de')),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// SET SHOW RECOMMENDATIONS
|
|
||||||
|
|
||||||
void showRecommendationsDialog(BuildContext context) async {
|
|
||||||
final showRecommendations = await settings.getRecommendations();
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: Text(
|
|
||||||
'Polecaj restauracje w okolicy',
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
children: <Widget>[
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
settings.setRecommendations(true);
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'Tak',
|
|
||||||
style: TextStyle(
|
|
||||||
color: getOptionColor(showRecommendations, true)),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
settings.setRecommendations(false);
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'Nie',
|
|
||||||
style: TextStyle(
|
|
||||||
color: getOptionColor(showRecommendations, false)),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// SHOW APP INFO
|
|
||||||
|
|
||||||
void showAppInfoDialog(BuildContext context) async {
|
|
||||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
||||||
String version = packageInfo.version;
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(24)),
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
children: <Widget>[
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Wersja aplikacji',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
version,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
)),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Wsparcie',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
'support@menui.pl',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
)),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// SELECT RADIUS
|
|
||||||
|
|
||||||
void showRadiusSelectionDialog(BuildContext context) async {
|
|
||||||
final int currentRadius = await settings.getRadius();
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return RadiusSlider(
|
|
||||||
initialValue: currentRadius.toDouble(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getOptionColor(targetOption, thisOption) {
|
|
||||||
if (thisOption == targetOption) {
|
|
||||||
return Colors.orange;
|
|
||||||
} else {
|
|
||||||
return Colors.grey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RadiusSlider extends StatefulWidget {
|
|
||||||
final double initialValue;
|
|
||||||
RadiusSlider({Key key, @required this.initialValue}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_RadiusSliderState createState() =>
|
|
||||||
_RadiusSliderState(sliderValue: initialValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RadiusSliderState extends State<RadiusSlider> {
|
|
||||||
double sliderValue;
|
|
||||||
|
|
||||||
_RadiusSliderState({this.sliderValue});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: Text(
|
|
||||||
'Promień lokalizacji',
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
children: <Widget>[
|
|
||||||
Slider(
|
|
||||||
value: sliderValue,
|
|
||||||
min: 300,
|
|
||||||
max: 3000,
|
|
||||||
divisions: 9,
|
|
||||||
label: formatDistance(sliderValue),
|
|
||||||
onChanged: (double value) {
|
|
||||||
setState(() {
|
|
||||||
sliderValue = value;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () async {
|
|
||||||
final MenuiSettings settings = new MenuiSettings();
|
|
||||||
settings.setRadius(sliderValue.toInt());
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
'Zapisz',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
String formatDistance(double distance) {
|
|
||||||
if (distance > 1000) {
|
|
||||||
final double distanceInKM = distance / 1000;
|
|
||||||
return '${distanceInKM.toString()}km';
|
|
||||||
} else {
|
|
||||||
return '${distance}m';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import '../services.dart';
|
|||||||
|
|
||||||
class LineOfIcons extends StatelessWidget {
|
class LineOfIcons extends StatelessWidget {
|
||||||
final MenuiTags tags;
|
final MenuiTags tags;
|
||||||
final double edgeInsets = 4;
|
final double edgeInsets = 3;
|
||||||
final double imagesWidth = 16;
|
final double imagesWidth = 14;
|
||||||
final double fontSize = 9;
|
final double fontSize = 8;
|
||||||
final double maxWidth = 50;
|
final double maxWidth = 40;
|
||||||
|
|
||||||
LineOfIcons({@required this.tags});
|
LineOfIcons({@required this.tags});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 4.0,
|
spacing: 2.0,
|
||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|||||||
196
lib/components/orderView.dart
Normal file
196
lib/components/orderView.dart
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../settings.dart';
|
||||||
|
import 'homeScreen.dart';
|
||||||
|
import 'favoritesView.dart';
|
||||||
|
|
||||||
|
class OrderView extends StatelessWidget {
|
||||||
|
final settings = new MenuiSettings();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
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: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_back_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Cofnij',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200], fontSize: 12),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
RaisedButton(
|
||||||
|
color: Colors.grey[850],
|
||||||
|
elevation: 0,
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 12, horizontal: 4),
|
||||||
|
onPressed: () {
|
||||||
|
settings.clearOrder();
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.delete_forever_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Wyczyść',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200], fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[700]),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.attach_money_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Suma: 0zł',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
|
floatingActionButton: Container(
|
||||||
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: () => Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => FavoritesView())),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
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: () {
|
||||||
|
showSettings(context, settings);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.settings,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Ustawienia',
|
||||||
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,15 @@ import 'lineOfIcons.dart';
|
|||||||
import 'dishList.dart';
|
import 'dishList.dart';
|
||||||
import 'socialMedia.dart';
|
import 'socialMedia.dart';
|
||||||
import 'restaurantMapView.dart';
|
import 'restaurantMapView.dart';
|
||||||
|
import 'orderView.dart';
|
||||||
|
import 'favoritesView.dart';
|
||||||
|
import '../settings.dart';
|
||||||
|
import 'homeScreen.dart';
|
||||||
|
|
||||||
class RestaurantView extends StatelessWidget {
|
class RestaurantView extends StatelessWidget {
|
||||||
final String id;
|
final String id;
|
||||||
final MenuiServices services = new MenuiServices();
|
final MenuiServices services = new MenuiServices();
|
||||||
|
final MenuiSettings settings = new MenuiSettings();
|
||||||
|
|
||||||
RestaurantView({@required this.id});
|
RestaurantView({@required this.id});
|
||||||
|
|
||||||
@@ -15,6 +20,7 @@ class RestaurantView extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
services.fetchAllDishes(id);
|
services.fetchAllDishes(id);
|
||||||
List<String> categories = [];
|
List<String> categories = [];
|
||||||
|
Restaurant restaurant;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
decoration: BoxDecoration(color: Colors.grey[850]),
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
@@ -23,7 +29,7 @@ class RestaurantView extends StatelessWidget {
|
|||||||
builder:
|
builder:
|
||||||
(BuildContext context, AsyncSnapshot<Restaurant> snapshot) {
|
(BuildContext context, AsyncSnapshot<Restaurant> snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final Restaurant restaurant = snapshot.data;
|
restaurant = snapshot.data;
|
||||||
categories = restaurant.categories;
|
categories = restaurant.categories;
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
children: [
|
||||||
@@ -59,40 +65,19 @@ class RestaurantView extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
restaurant.name,
|
restaurant.name,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 20,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
fontWeight: FontWeight.w300),
|
fontWeight: FontWeight.w300),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
restaurant.city,
|
restaurant.city,
|
||||||
style: TextStyle(color: Colors.grey),
|
style: TextStyle(
|
||||||
|
color: Colors.grey, fontSize: 12),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
margin: EdgeInsets.all(12),
|
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: () => Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
RestaurantMapView(
|
|
||||||
coordinates: restaurant
|
|
||||||
.coordinates,
|
|
||||||
name: restaurant.name,
|
|
||||||
type: restaurant.type,
|
|
||||||
)))),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceBetween,
|
MainAxisAlignment.spaceBetween,
|
||||||
@@ -194,58 +179,193 @@ class RestaurantView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
floatingActionButton: Stack(
|
floatingActionButton: Container(
|
||||||
children: <Widget>[
|
decoration: BoxDecoration(color: Colors.grey[850]),
|
||||||
Align(
|
child: Row(
|
||||||
alignment: Alignment.bottomCenter,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Padding(
|
children: <Widget>[
|
||||||
padding: EdgeInsets.only(bottom: 4),
|
RaisedButton(
|
||||||
child: FloatingActionButton.extended(
|
color: Colors.grey[850],
|
||||||
heroTag: null,
|
elevation: 0,
|
||||||
onPressed: () {
|
padding: EdgeInsets.all(8),
|
||||||
showMenu(context, categories);
|
onPressed: () => Navigator.push(
|
||||||
},
|
context, MaterialPageRoute(builder: (context) => HomePage())),
|
||||||
label: Text(
|
child: Column(
|
||||||
'Karta dań',
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.home_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Szukaj',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white, fontWeight: FontWeight.w400),
|
color: Colors.grey[200],
|
||||||
),
|
fontSize: 10,
|
||||||
icon: Icon(
|
fontWeight: FontWeight.w400),
|
||||||
Icons.arrow_upward_rounded,
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.note_rounded,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.grey[900],
|
Text(
|
||||||
),
|
'Zamówienie',
|
||||||
)),
|
style: TextStyle(
|
||||||
Align(
|
color: Colors.grey[200],
|
||||||
alignment: Alignment.bottomLeft,
|
fontSize: 10,
|
||||||
child: Padding(
|
fontWeight: FontWeight.w400),
|
||||||
padding: EdgeInsets.only(left: 16),
|
)
|
||||||
child: FloatingActionButton(
|
],
|
||||||
heroTag: null,
|
),
|
||||||
backgroundColor: Colors.grey[900],
|
),
|
||||||
child: Icon(
|
RaisedButton(
|
||||||
Icons.arrow_back_rounded,
|
color: Colors.grey[850],
|
||||||
color: Colors.orange,
|
elevation: 0,
|
||||||
),
|
padding: EdgeInsets.all(8),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.push(context,
|
||||||
),
|
MaterialPageRoute(builder: (context) => FavoritesView())),
|
||||||
)),
|
child: Column(
|
||||||
Align(
|
mainAxisSize: MainAxisSize.min,
|
||||||
alignment: Alignment.bottomRight,
|
children: <Widget>[
|
||||||
child: Padding(
|
Icon(
|
||||||
padding: EdgeInsets.only(right: 16),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
heroTag: null,
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
child: Icon(
|
|
||||||
Icons.favorite_rounded,
|
Icons.favorite_rounded,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.share_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
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: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.favorite_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Dodaj',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ class SearchResults extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(
|
Icon(
|
||||||
Icons.arrow_back_rounded,
|
Icons.home_rounded,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Cofnij',
|
'Szukaj',
|
||||||
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
style: TextStyle(color: Colors.grey[200], fontSize: 12),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
class MenuiSettings {
|
class MenuiSettings {
|
||||||
// SET LANGUAGE
|
// SET LANGUAGE
|
||||||
@@ -85,9 +87,9 @@ class MenuiSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ADD DISH TO ORDER --- TODO
|
// ADD DISH TO ORDER --- TODO
|
||||||
void addToOrder(String id) async{
|
void addToOrder(String id) async {
|
||||||
final settings = await SharedPreferences.getInstance();
|
final settings = await SharedPreferences.getInstance();
|
||||||
if(settings.containsKey('order')){
|
if (settings.containsKey('order')) {
|
||||||
List<String> order = settings.getStringList('order');
|
List<String> order = settings.getStringList('order');
|
||||||
order.add(id);
|
order.add(id);
|
||||||
} else {
|
} else {
|
||||||
@@ -97,13 +99,328 @@ class MenuiSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET ORDER
|
// GET ORDER
|
||||||
Future<List<String>> getOrder() async{
|
Future<List<String>> getOrder() async {
|
||||||
final settings = await SharedPreferences.getInstance();
|
final settings = await SharedPreferences.getInstance();
|
||||||
if(settings.containsKey('order')){
|
if (settings.containsKey('order')) {
|
||||||
List<String> order = settings.getStringList('order');
|
List<String> order = settings.getStringList('order');
|
||||||
return order;
|
return order;
|
||||||
} else {
|
} else {
|
||||||
return new List<String>();
|
return new List<String>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CLEAR ORDER
|
||||||
|
void clearOrder() async {
|
||||||
|
final settings = await SharedPreferences.getInstance();
|
||||||
|
settings.setStringList('order', new List<String>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
showSettings(BuildContext context, MenuiSettings settings) async {
|
||||||
|
FocusManager.instance.primaryFocus.unfocus();
|
||||||
|
final String languageCode = await settings.getLanguage();
|
||||||
|
final String language = settings.decodeLanguage(languageCode);
|
||||||
|
final int radius = await settings.getRadius();
|
||||||
|
final bool recommendationsValue = await settings.getRecommendations();
|
||||||
|
final recommendations = settings.decodeBool(recommendationsValue);
|
||||||
|
|
||||||
|
showModalBottomSheet(
|
||||||
|
backgroundColor: Colors.grey[850],
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(24), topRight: Radius.circular(24))),
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Język',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
language,
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
leading: Icon(
|
||||||
|
Icons.language,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
showLanguageSelectionDialog(context, settings);
|
||||||
|
}),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Promień lokalizacji',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle:
|
||||||
|
Text('${radius}m', style: TextStyle(color: Colors.grey)),
|
||||||
|
leading: Icon(
|
||||||
|
Icons.location_searching_rounded,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
showRadiusSelectionDialog(context, settings);
|
||||||
|
}),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Proponuj restauracje',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle:
|
||||||
|
Text(recommendations, style: TextStyle(color: Colors.grey)),
|
||||||
|
leading: Icon(
|
||||||
|
Icons.notifications,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
showRecommendationsDialog(context, settings);
|
||||||
|
}),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'O aplikacji',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
leading: Icon(
|
||||||
|
Icons.info,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
showAppInfoDialog(context);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void showLanguageSelectionDialog(
|
||||||
|
BuildContext context, MenuiSettings settings) async {
|
||||||
|
final currentLanguage = await settings.getLanguage();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Text(
|
||||||
|
'Język',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
backgroundColor: Colors.grey[850],
|
||||||
|
children: <Widget>[
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
settings.setLanguage('pl');
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Polski',
|
||||||
|
style: TextStyle(color: getOptionColor(currentLanguage, 'pl')),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
settings.setLanguage('en');
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'English',
|
||||||
|
style: TextStyle(color: getOptionColor(currentLanguage, 'en')),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
settings.setLanguage('de');
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Deutsch',
|
||||||
|
style: TextStyle(color: getOptionColor(currentLanguage, 'de')),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET SHOW RECOMMENDATIONS
|
||||||
|
|
||||||
|
void showRecommendationsDialog(
|
||||||
|
BuildContext context, MenuiSettings settings) async {
|
||||||
|
final showRecommendations = await settings.getRecommendations();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Text(
|
||||||
|
'Polecaj restauracje w okolicy',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
backgroundColor: Colors.grey[850],
|
||||||
|
children: <Widget>[
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
settings.setRecommendations(true);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Tak',
|
||||||
|
style:
|
||||||
|
TextStyle(color: getOptionColor(showRecommendations, true)),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
settings.setRecommendations(false);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Nie',
|
||||||
|
style: TextStyle(
|
||||||
|
color: getOptionColor(showRecommendations, false)),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// SHOW APP INFO
|
||||||
|
|
||||||
|
void showAppInfoDialog(BuildContext context) async {
|
||||||
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
String version = packageInfo.version;
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
backgroundColor: Colors.grey[850],
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Wersja aplikacji',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
version,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
)),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Wsparcie',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'menui@menui.pl',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
)),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// SELECT RADIUS
|
||||||
|
|
||||||
|
void showRadiusSelectionDialog(
|
||||||
|
BuildContext context, MenuiSettings settings) async {
|
||||||
|
final int currentRadius = await settings.getRadius();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return RadiusSlider(
|
||||||
|
initialValue: currentRadius.toDouble(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getOptionColor(targetOption, thisOption) {
|
||||||
|
if (thisOption == targetOption) {
|
||||||
|
return Colors.orange;
|
||||||
|
} else {
|
||||||
|
return Colors.grey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RadiusSlider extends StatefulWidget {
|
||||||
|
final double initialValue;
|
||||||
|
RadiusSlider({Key key, @required this.initialValue}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_RadiusSliderState createState() =>
|
||||||
|
_RadiusSliderState(sliderValue: initialValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RadiusSliderState extends State<RadiusSlider> {
|
||||||
|
double sliderValue;
|
||||||
|
|
||||||
|
_RadiusSliderState({this.sliderValue});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Text(
|
||||||
|
'Promień lokalizacji',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
backgroundColor: Colors.grey[850],
|
||||||
|
children: <Widget>[
|
||||||
|
Slider(
|
||||||
|
value: sliderValue,
|
||||||
|
min: 300,
|
||||||
|
max: 3000,
|
||||||
|
divisions: 9,
|
||||||
|
label: formatDistance(sliderValue),
|
||||||
|
onChanged: (double value) {
|
||||||
|
setState(() {
|
||||||
|
sliderValue = value;
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () async {
|
||||||
|
final MenuiSettings settings = new MenuiSettings();
|
||||||
|
settings.setRadius(sliderValue.toInt());
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Zapisz',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String formatDistance(double distance) {
|
||||||
|
if (distance > 1000) {
|
||||||
|
final double distanceInKM = distance / 1000;
|
||||||
|
return '${distanceInKM.toString()}km';
|
||||||
|
} else {
|
||||||
|
return '${distance}m';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user