fix: okno u jídel, které nejde objednat

This commit is contained in:
Matyáš Caras 2022-05-19 18:44:56 +02:00
parent 927f101ba1
commit 3a35c67be4
3 changed files with 118 additions and 75 deletions

View file

@ -14,7 +14,7 @@ class LanguageCz extends Languages {
String get balance => "Kredit: ";
@override
String get cannotOrder => "Nelze objednat";
String get cannotOrder => "Toto jídlo není možné objednat.";
@override
String get close => "Zavřít";

View file

@ -14,7 +14,7 @@ class LanguageEn extends Languages {
String get balance => "Balance: ";
@override
String get cannotOrder => "Cannot order";
String get cannotOrder => "This food cannot be ordered.";
@override
String get close => "Close";

View file

@ -86,7 +86,27 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
? MaterialStateProperty.all(Colors.blue)
: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async {
if (!j.lzeObjednat) return;
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(Languages.of(context)!
.errorOrdering),
content: Text(
Languages.of(context)!.cannotOrder),
actions: [
TextButton(
child:
Text(Languages.of(context)!.ok),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
@ -99,8 +119,8 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
child:
CircularProgressIndicator(),
),
Text(
Languages.of(context)!.ordering)
Text(Languages.of(context)!
.ordering)
]),
),
));
@ -120,7 +140,8 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
actions: [
TextButton(
child: Text(
Languages.of(context)!.close),
Languages.of(context)!
.close),
onPressed: () {
Navigator.pop(bc);
},
@ -128,11 +149,31 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
],
));
});
}
})
],
),
onTap: () async {
if (!j.lzeObjednat) return;
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title:
Text(Languages.of(context)!.errorOrdering),
content:
Text(Languages.of(context)!.cannotOrder),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
@ -161,7 +202,8 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
content: Text(o.toString()),
actions: [
TextButton(
child: Text(Languages.of(context)!.close),
child:
Text(Languages.of(context)!.close),
onPressed: () {
Navigator.pop(bc);
},
@ -169,6 +211,7 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
],
));
});
}
},
onLongPress: () async {
if (!j.objednano || j.burzaUrl == null) return;