diff --git a/lib/lang/lang_cz.dart b/lib/lang/lang_cz.dart index 60cbf47..f230e57 100644 --- a/lib/lang/lang_cz.dart +++ b/lib/lang/lang_cz.dart @@ -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"; diff --git a/lib/lang/lang_en.dart b/lib/lang/lang_en.dart index adc8691..bcc868f 100644 --- a/lib/lang/lang_en.dart +++ b/lib/lang/lang_en.dart @@ -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"; diff --git a/lib/okna/jidelnicek.dart b/lib/okna/jidelnicek.dart index 45b65e5..a6c0c57 100644 --- a/lib/okna/jidelnicek.dart +++ b/lib/okna/jidelnicek.dart @@ -86,89 +86,132 @@ class _JidelnicekPageState extends State { ? MaterialStateProperty.all(Colors.blue) : MaterialStateProperty.all(Colors.grey), onChanged: (v) async { - if (!j.lzeObjednat) return; - 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(); + if (!j.lzeObjednat) { 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); - }, - ) - ], + 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, + 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 { - if (!j.lzeObjednat) return; - 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(); + if (!j.lzeObjednat) { 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); - }, - ) - ], + 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, + 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 { if (!j.objednano || j.burzaUrl == null) return;