feat: vylepšit oznámení o neobjednaném jídle
This commit is contained in:
parent
28eba7d9ab
commit
ce9eb97ac9
4 changed files with 36 additions and 13 deletions
|
@ -91,6 +91,8 @@ abstract class Languages {
|
|||
|
||||
String get signOutWarn;
|
||||
|
||||
String get jump;
|
||||
|
||||
// Uvítací obrazovka
|
||||
|
||||
String get welcome;
|
||||
|
|
|
@ -231,4 +231,7 @@ class LanguageCz extends Languages {
|
|||
|
||||
@override
|
||||
String get signOutWarn => "Opravdu se chcete odhlásit?";
|
||||
|
||||
@override
|
||||
String get jump => "Přeskočit";
|
||||
}
|
||||
|
|
|
@ -229,4 +229,7 @@ class LanguageEn extends Languages {
|
|||
|
||||
@override
|
||||
String get signOutWarn => "Do you really want to sign out?";
|
||||
|
||||
@override
|
||||
String get jump => "Jump";
|
||||
}
|
||||
|
|
|
@ -35,18 +35,31 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
|
|||
var prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.getBool("tyden") ?? false) {
|
||||
// Zjistit jestli je objednáno na přístí týden
|
||||
var pristi = den.add(const Duration(days: 7));
|
||||
var jidelnicek = await widget.canteen.jidelnicekDen(den: pristi);
|
||||
if (jidelnicek.jidla.isNotEmpty &&
|
||||
!jidelnicek.jidla.any((element) => element.objednano == true)) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(Languages.of(context)!.noOrder),
|
||||
duration: const Duration(seconds: 5),
|
||||
),
|
||||
);
|
||||
var pristi = den.add(const Duration(days: 6));
|
||||
for (var i = 0; i < 5; i++) {
|
||||
var jidelnicek = await widget.canteen
|
||||
.jidelnicekDen(den: pristi.add(Duration(days: i + 1)));
|
||||
if (jidelnicek.jidla.isNotEmpty &&
|
||||
!jidelnicek.jidla.any((element) => element.objednano == true)) {
|
||||
if (!mounted) break;
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(Languages.of(context)!.noOrder),
|
||||
duration: const Duration(seconds: 5),
|
||||
action: SnackBarAction(
|
||||
onPressed: () => setState(
|
||||
() {
|
||||
den = pristi.add(Duration(days: i + 1));
|
||||
nactiJidlo();
|
||||
},
|
||||
),
|
||||
label: Languages.of(context)!.jump,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +307,6 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
|
|||
);
|
||||
}
|
||||
}
|
||||
kontrolaTyden(context);
|
||||
});
|
||||
});
|
||||
}).catchError((o) {
|
||||
|
@ -343,6 +355,9 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
|
|||
void nactiNastaveni() async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
_skipWeekend = prefs.getBool("skip") ?? false;
|
||||
print(mounted);
|
||||
if (!mounted) return;
|
||||
kontrolaTyden(context);
|
||||
}
|
||||
|
||||
/// uložení jídelníčku pro dnešek offline
|
||||
|
|
Reference in a new issue