feat: implementovat oznámení o neobjednaném jídle

PR #14
This commit is contained in:
Matyáš Caras 2022-05-26 16:40:27 +02:00 committed by GitHub
commit 7ec2ded7ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 87 additions and 3 deletions

View file

@ -1,3 +1,6 @@
# 1.2.0
- Přidat možnost zobrazení oznámení v případě neobjednaného jídla na příští týden
- Přidat oznámení o rozbitých uložených údajích
# 1.1.2 # 1.1.2
- Přidat chybějící knihovnu do O Aplikaci (licence) - Přidat chybějící knihovnu do O Aplikaci (licence)
# 1.1.1 # 1.1.1

View file

@ -4,7 +4,9 @@
<application <application
android:label="OpenCanteen" android:label="OpenCanteen"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/launcher_icon"> android:icon="@mipmap/launcher_icon"
android:allowBackup="false"
android:fullBackupContent="false">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"

View file

@ -41,6 +41,8 @@ abstract class Languages {
String get warning; String get warning;
String get corrupted;
// Jídelníček // Jídelníček
String get loading; String get loading;
@ -85,6 +87,8 @@ abstract class Languages {
String get balance; String get balance;
String get noOrder;
// Uvítací obrazovka // Uvítací obrazovka
String get welcome; String get welcome;
@ -131,7 +135,7 @@ abstract class Languages {
String get copyright; String get copyright;
// Settings // Nastavení
String get settings; String get settings;
@ -139,6 +143,8 @@ abstract class Languages {
String get skipWeekend; String get skipWeekend;
String get checkOrdered;
// Offline // Offline
String get offline; String get offline;

View file

@ -196,4 +196,15 @@ class LanguageCz extends Languages {
@override @override
String get next => "Další"; String get next => "Další";
@override
String get checkOrdered =>
"Kontrolovat, jestli mám objednáno na příští týden";
@override
String get noOrder => "Na přístí týden nemáte objednané žádné jídlo!";
@override
String get corrupted =>
"Nastal problém s dešifrováním uložených údajů, prosím zkuste vyčistit veškerá data této aplikace.";
} }

View file

@ -196,4 +196,14 @@ class LanguageEn extends Languages {
@override @override
String get next => "Next"; String get next => "Next";
@override
String get checkOrdered => "Check if I have ordered food for the next week";
@override
String get noOrder => "You did not order any food for the next week!";
@override
String get corrupted =>
"The saved credentials seem to be corrupted, please try clearing the application's data.";
} }

View file

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/lang/lang_cz.dart'; import 'package:opencanteen/lang/lang_cz.dart';
@ -136,6 +137,13 @@ class _LoginPageState extends State<LoginPage> {
)), )),
); );
} }
} on PlatformException {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.corrupted),
),
);
} catch (_) { } catch (_) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
@ -271,6 +279,13 @@ class _LoginPageState extends State<LoginPage> {
)), )),
); );
} }
} on PlatformException {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.corrupted),
),
);
} on Exception catch (_) { } on Exception catch (_) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(

View file

@ -27,6 +27,26 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
String denTydne = ""; String denTydne = "";
double kredit = 0.0; double kredit = 0.0;
bool _skipWeekend = false; bool _skipWeekend = false;
void kontrolaTyden(BuildContext context) async {
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)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.noOrder),
duration: const Duration(seconds: 5),
),
);
}
}
}
Future<void> nactiJidlo() async { Future<void> nactiJidlo() async {
obsah = [const CircularProgressIndicator()]; obsah = [const CircularProgressIndicator()];
switch (den.weekday) { switch (den.weekday) {
@ -270,6 +290,7 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
); );
} }
} }
kontrolaTyden(context);
}); });
}); });
}).catchError((o) { }).catchError((o) {

View file

@ -16,12 +16,14 @@ class Nastaveni extends StatefulWidget {
class _NastaveniState extends State<Nastaveni> { class _NastaveniState extends State<Nastaveni> {
bool _ukladatOffline = false; bool _ukladatOffline = false;
bool _preskakovatVikend = false; bool _preskakovatVikend = false;
bool _kontrolovatTyden = false;
void najitNastaveni() async { void najitNastaveni() async {
var preferences = await SharedPreferences.getInstance(); var preferences = await SharedPreferences.getInstance();
setState(() { setState(() {
_ukladatOffline = preferences.getBool("offline") ?? false; _ukladatOffline = preferences.getBool("offline") ?? false;
_preskakovatVikend = preferences.getBool("skip") ?? false; _preskakovatVikend = preferences.getBool("skip") ?? false;
_kontrolovatTyden = preferences.getBool("tyden") ?? false;
}); });
} }
@ -75,6 +77,20 @@ class _NastaveniState extends State<Nastaveni> {
}); });
}) })
], ],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text(Languages.of(context)!.checkOrdered)),
Switch(
value: _kontrolovatTyden,
onChanged: (value) {
setState(() {
_kontrolovatTyden = value;
zmenitNastaveni("tyden", value);
});
})
],
) )
], ],
), ),

View file

@ -6,7 +6,7 @@ publish_to: 'none'
# The following defines the version and build number for your application. # The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43 # A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +. # followed by an optional build number separated by a +.
version: 1.1.3+7 version: 1.2.0+14
environment: environment:
sdk: ">=2.16.1 <3.0.0" sdk: ">=2.16.1 <3.0.0"