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: "; String get balance => "Kredit: ";
@override @override
String get cannotOrder => "Nelze objednat"; String get cannotOrder => "Toto jídlo není možné objednat.";
@override @override
String get close => "Zavřít"; String get close => "Zavřít";

View file

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

View file

@ -86,89 +86,132 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
? MaterialStateProperty.all(Colors.blue) ? MaterialStateProperty.all(Colors.blue)
: MaterialStateProperty.all(Colors.grey), : MaterialStateProperty.all(Colors.grey),
onChanged: (v) async { onChanged: (v) async {
if (!j.lzeObjednat) return; if (!j.lzeObjednat) {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child:
CircularProgressIndicator(),
),
Text(
Languages.of(context)!.ordering)
]),
),
));
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true)
.pop();
nactiJidlo();
}).catchError((o) {
Navigator.of(context, rootNavigator: true)
.pop();
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (context) {
title: Text(Languages.of(context)! return AlertDialog(
.errorOrdering), title: Text(Languages.of(context)!
content: Text(o.toString()), .errorOrdering),
actions: [ content: Text(
TextButton( Languages.of(context)!.cannotOrder),
child: Text( actions: [
Languages.of(context)!.close), TextButton(
onPressed: () { child:
Navigator.pop(bc); Text(Languages.of(context)!.ok),
}, onPressed: () {
) Navigator.of(context).pop();
], },
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child:
CircularProgressIndicator(),
),
Text(Languages.of(context)!
.ordering)
]),
),
)); ));
}); widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true)
.pop();
nactiJidlo();
}).catchError((o) {
Navigator.of(context, rootNavigator: true)
.pop();
showDialog(
context: context,
builder: (bc) => AlertDialog(
title: Text(Languages.of(context)!
.errorOrdering),
content: Text(o.toString()),
actions: [
TextButton(
child: Text(
Languages.of(context)!
.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
));
});
}
}) })
], ],
), ),
onTap: () async { onTap: () async {
if (!j.lzeObjednat) return; if (!j.lzeObjednat) {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child: CircularProgressIndicator(),
),
Text(Languages.of(context)!.ordering)
]),
),
));
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
nactiJidlo();
}).catchError((o) {
Navigator.of(context, rootNavigator: true).pop();
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (context) {
title: Text( return AlertDialog(
Languages.of(context)!.errorOrdering), title:
content: Text(o.toString()), Text(Languages.of(context)!.errorOrdering),
actions: [ content:
TextButton( Text(Languages.of(context)!.cannotOrder),
child: Text(Languages.of(context)!.close), actions: [
onPressed: () { TextButton(
Navigator.pop(bc); child: Text(Languages.of(context)!.ok),
}, onPressed: () {
) Navigator.of(context).pop();
], },
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child: CircularProgressIndicator(),
),
Text(Languages.of(context)!.ordering)
]),
),
)); ));
}); widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
nactiJidlo();
}).catchError((o) {
Navigator.of(context, rootNavigator: true).pop();
showDialog(
context: context,
builder: (bc) => AlertDialog(
title: Text(
Languages.of(context)!.errorOrdering),
content: Text(o.toString()),
actions: [
TextButton(
child:
Text(Languages.of(context)!.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
));
});
}
}, },
onLongPress: () async { onLongPress: () async {
if (!j.objednano || j.burzaUrl == null) return; if (!j.objednano || j.burzaUrl == null) return;