Compare commits

..

No commits in common. "64b7f261a029154dff9342b6ffec12cdda52fccd" and "26c6e4604e0b25b6b59af208bc55eb73837bd17c" have entirely different histories.

20 changed files with 1029 additions and 1317 deletions

@ -1 +1 @@
Subproject commit b06b8b2710955028a6b562f5aa6fe62941d6febf Subproject commit 52b3dc25f6471c27b2144594abb11c741cb88f57

View file

@ -45,8 +45,6 @@ abstract class Languages {
// Jídelníček // Jídelníček
String get todayTooltip;
String get loading; String get loading;
String get monday; String get monday;

View file

@ -244,7 +244,4 @@ class LanguageCz extends Languages {
@override @override
String get errorSaving => String get errorSaving =>
"Při ukládání offline nastala chyba, zkuste to znovu později."; "Při ukládání offline nastala chyba, zkuste to znovu později.";
@override
String get todayTooltip => "Přejít na dnešní jídelníček";
} }

View file

@ -242,7 +242,4 @@ class LanguageEn extends Languages {
@override @override
String get errorSaving => String get errorSaving =>
"An error occured while trying to save menu offline, try again later."; "An error occured while trying to save menu offline, try again later.";
@override
String get todayTooltip => "Go to today's meal";
} }

View file

@ -2,7 +2,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class LoginManager { class LoginManager {
static Future<Map<String, String>?> getDetails() async { static Future<Map<String, String>?> getDetails() async {
// check secure storage for details // zkontrolovat secure storage pokud je něco uložené
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
var user = await storage.read(key: "oc_user"); var user = await storage.read(key: "oc_user");
var pass = await storage.read(key: "oc_pass"); var pass = await storage.read(key: "oc_pass");
@ -18,7 +18,7 @@ class LoginManager {
await storage.write(key: "oc_url", value: url); await storage.write(key: "oc_url", value: url);
} }
static Future<bool> rememberme() async { static Future<bool> zapamatovat() async {
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
return await storage.containsKey(key: "oc_pass"); return await storage.containsKey(key: "oc_pass");
} }

View file

@ -1,6 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -38,8 +37,7 @@ Copyright (C) 2022 Matyáš Caras a přispěvatelé
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
/// Used to setup notifications about ordered food void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
void setupNotification(SharedPreferences prefs, tz.Location l) async {
String title; String title;
String locale = Intl.getCurrentLocale(); String locale = Intl.getCurrentLocale();
@ -52,24 +50,24 @@ void setupNotification(SharedPreferences prefs, tz.Location l) async {
} }
/*if (prefs.getBool("offline") ?? false) { /*if (prefs.getBool("offline") ?? false) {
// TODO grab data from offline storage // TODO možnost brát z offline dat
} else {*/ } else {*/
// data from the web // bere online
var d = await LoginManager.getDetails(); // grab login var d = await LoginManager.getDetails(); // získat údaje
if (d != null) { if (d != null) {
var c = Canteen(d["url"]!); var c = Canteen(d["url"]!);
if (await c.login(d["user"]!, d["pass"]!)) { if (await c.login(d["user"]!, d["pass"]!)) {
var jidla = await c.jidelnicekDen(); var jidla = await c.jidelnicekDen();
try { try {
var jidlo = jidla.jidla var jidlo = jidla.jidla.singleWhere(
.singleWhere((element) => element.objednano); // grab ordered meal (element) => element.objednano); // získá objednané jídlo
var kdy = DateTime.parse(prefs.getString( var kdy = DateTime.parse(prefs.getString(
"oznameni_cas")!); // save the time the notif should be sent "oznameni_cas")!); // uložíme čas, kdy se odeslat oznámení
var cas = timeToDate( var cas = casNaDate(
TimeOfDay(hour: kdy.hour, minute: kdy.minute), TimeOfDay(hour: kdy.hour, minute: kdy.minute),
); );
if (cas.isBefore(DateTime.now())) return; if (cas.isBefore(DateTime.now())) return;
// notif data // data o oznámení
const AndroidNotificationDetails androidSpec = const AndroidNotificationDetails androidSpec =
AndroidNotificationDetails('predobedem', 'Oznámení před obědem', AndroidNotificationDetails('predobedem', 'Oznámení před obědem',
channelDescription: 'Oznámení o dnešním jídle', channelDescription: 'Oznámení o dnešním jídle',
@ -78,7 +76,7 @@ void setupNotification(SharedPreferences prefs, tz.Location l) async {
styleInformation: BigTextStyleInformation(''), styleInformation: BigTextStyleInformation(''),
ticker: 'today meal'); ticker: 'today meal');
// plan through lib // naplánovat
await flutterLocalNotificationsPlugin.zonedSchedule( await flutterLocalNotificationsPlugin.zonedSchedule(
0, 0,
title, title,
@ -89,7 +87,7 @@ void setupNotification(SharedPreferences prefs, tz.Location l) async {
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime); UILocalNotificationDateInterpretation.absoluteTime);
} on StateError catch (_) { } on StateError catch (_) {
// no ordered meal found // nenalezeno
} }
} }
// } // }
@ -104,10 +102,10 @@ void main() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("oznamit") ?? false) { if (prefs.getBool("oznamit") ?? false) {
setupNotification(prefs, l); oznamitPredem(prefs, l);
} }
// notif library setup // nastavit oznámení
const AndroidInitializationSettings initializationSettingsAndroid = const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('notif_icon'); AndroidInitializationSettings('notif_icon');
@ -117,6 +115,7 @@ void main() async {
InitializationSettings(android: initializationSettingsAndroid, iOS: ios); InitializationSettings(android: initializationSettingsAndroid, iOS: ios);
await flutterLocalNotificationsPlugin.initialize(initializationSettings); await flutterLocalNotificationsPlugin.initialize(initializationSettings);
// spustit aplikaci
runApp(const MyApp()); runApp(const MyApp());
} }
@ -125,38 +124,23 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return (Platform return MaterialApp(
.isAndroid) // run app based on current platform to make use of the platform's respective UI lib debugShowCheckedModeBanner: false,
? MaterialApp( localizationsDelegates: const [
debugShowCheckedModeBanner: false, AppLocalizationsDelegate(),
localizationsDelegates: const [ ...GlobalMaterialLocalizations.delegates
AppLocalizationsDelegate(), ],
...GlobalMaterialLocalizations.delegates supportedLocales: const [Locale("cs", ""), Locale("en", "")],
], title: "OpenCanteen",
supportedLocales: const [Locale("cs", ""), Locale("en", "")], theme: ThemeData(
title: "OpenCanteen", primarySwatch: Colors.purple,
theme: ThemeData( ),
primarySwatch: Colors.purple, darkTheme: ThemeData(
), brightness: Brightness.dark,
darkTheme: ThemeData( primarySwatch: Colors.purple,
brightness: Brightness.dark, ),
primarySwatch: Colors.purple, home: const LoginPage(),
), );
home: const LoginPage(),
)
: const CupertinoApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: [
AppLocalizationsDelegate(),
...GlobalMaterialLocalizations.delegates
],
supportedLocales: [Locale("cs", ""), Locale("en", "")],
title: "OpenCanteen",
theme: CupertinoThemeData(
primaryColor: Colors.purple,
),
home: LoginPage(),
);
} }
} }

View file

@ -1,8 +1,6 @@
import 'package:canteenlib/canteenlib.dart'; import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:opencanteen/okna/login.dart'; import 'package:opencanteen/okna/login.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/pw/platformdialog.dart';
import 'package:opencanteen/util.dart'; import 'package:opencanteen/util.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
@ -15,101 +13,100 @@ class BurzaView extends StatefulWidget {
} }
class _BurzaViewState extends State<BurzaView> { class _BurzaViewState extends State<BurzaView> {
List<Widget> content = []; List<Widget> obsah = [];
double balance = 0.0; double kredit = 0.0;
Future<void> nactiBurzu(BuildContext context) async {
Future<void> loadExchange(BuildContext context) async { obsah = [const CircularProgressIndicator()];
content = [const CircularProgressIndicator()]; widget.canteen.ziskejUzivatele().then((kr) {
var uzivatel = await widget.canteen.ziskejUzivatele().catchError((o) { kredit = kr.kredit;
widget.canteen.ziskatBurzu().then((burza) {
setState(() {
obsah = [];
if (burza.isEmpty) {
obsah = [
Text(
Languages.of(context)!.noExchange,
style: const TextStyle(fontSize: 20),
),
Text(Languages.of(context)!.pullToReload)
];
} else {
for (var b in burza) {
obsah.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${b.den.day}. ${b.den.month}."),
const SizedBox(width: 10),
Flexible(
child: Text(
b.nazev,
),
),
Text("${b.pocet}x"),
TextButton(
onPressed: () {
widget.canteen.objednatZBurzy(b).then((a) {
if (a) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(Languages.of(context)!.ordered),
content: Text(
Languages.of(context)!.orderSuccess),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
} else {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
Languages.of(context)!.cannotOrder),
content: Text(
Languages.of(context)!.errorOrdering),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
}
nactiBurzu(context);
});
},
child: Text(Languages.of(context)!.order)),
],
),
),
);
}
}
});
});
}).catchError((o) {
if (!widget.canteen.prihlasen) { if (!widget.canteen.prihlasen) {
Navigator.pushReplacement( Navigator.pushReplacement(
context, platformRouter((c) => const LoginPage())); context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
return Uzivatel(kredit: 0);
});
balance = uzivatel.kredit;
var burza = await widget.canteen.ziskatBurzu();
setState(() {
content = [];
if (burza.isEmpty) {
content = [
Text(
Languages.of(context)!.noExchange,
style: const TextStyle(fontSize: 20),
),
Text(Languages.of(context)!.pullToReload)
];
} else {
for (var b in burza) {
content.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${b.den.day}. ${b.den.month}."),
const SizedBox(width: 10),
Flexible(
child: Text(
b.nazev,
),
),
Text("${b.pocet}x"),
PlatformButton(
onPressed: () {
widget.canteen.objednatZBurzy(b).then(
(a) {
if (a) {
showDialog(
context: context,
builder: (context) => PlatformDialog(
title: Languages.of(context)!.ordered,
content: Languages.of(context)!.orderSuccess,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
} else {
showDialog(
context: context,
builder: (context) => PlatformDialog(
title: Languages.of(context)!.cannotOrder,
content: Languages.of(context)!.errorOrdering,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
}
loadExchange(context);
},
);
},
text: Languages.of(context)!.order,
),
],
),
),
);
}
} }
}); });
return;
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
loadExchange(context); nactiBurzu(context);
} }
@override @override
@ -126,20 +123,20 @@ class _BurzaViewState extends State<BurzaView> {
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
Text("${Languages.of(context)!.balance}$balance"), Text("${Languages.of(context)!.balance}$kredit"),
const SizedBox(height: 10), const SizedBox(height: 10),
SingleChildScrollView( SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: SizedBox( child: SizedBox(
height: MediaQuery.of(context).size.height / 1.3, height: MediaQuery.of(context).size.height / 1.3,
child: Column(children: content), child: Column(children: obsah),
), ),
) )
], ],
), ),
), ),
), ),
onRefresh: () => loadExchange(context)), onRefresh: () => nactiBurzu(context)),
); );
} }
} }

View file

@ -6,8 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/okna/login.dart'; import 'package:opencanteen/okna/login.dart';
import 'package:opencanteen/okna/nastaveni.dart'; import 'package:opencanteen/okna/nastaveni.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/pw/platformdialog.dart';
import 'package:opencanteen/util.dart'; import 'package:opencanteen/util.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -16,25 +14,25 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
class MealView extends StatefulWidget { class JidelnicekView extends StatefulWidget {
const MealView({Key? key, required this.canteen}) : super(key: key); const JidelnicekView({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen; final Canteen canteen;
@override @override
State<MealView> createState() => _MealViewState(); State<JidelnicekView> createState() => _JidelnicekViewState();
} }
class _MealViewState extends State<MealView> { class _JidelnicekViewState extends State<JidelnicekView> {
List<Widget> content = [const CircularProgressIndicator()]; List<Widget> obsah = [const CircularProgressIndicator()];
DateTime day = DateTime.now(); DateTime den = DateTime.now();
String dayOWeek = ""; String denTydne = "";
double balance = 0.0; double kredit = 0.0;
bool _skipWeekend = false; bool _skipWeekend = false;
void checkWeek(BuildContext context) async { void kontrolaTyden(BuildContext context) async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("tyden") ?? false) { if (prefs.getBool("tyden") ?? false) {
// Check if user has ordered a meal in the next week // Zjistit jestli je objednáno na přístí týden
var pristi = day.add(const Duration(days: 6)); var pristi = den.add(const Duration(days: 6));
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
var jidelnicek = await widget.canteen var jidelnicek = await widget.canteen
.jidelnicekDen(den: pristi.add(Duration(days: i + 1))); .jidelnicekDen(den: pristi.add(Duration(days: i + 1)));
@ -49,8 +47,8 @@ class _MealViewState extends State<MealView> {
action: SnackBarAction( action: SnackBarAction(
onPressed: () => setState( onPressed: () => setState(
() { () {
day = pristi.add(Duration(days: i + 1)); den = pristi.add(Duration(days: i + 1));
loadMeals(); nactiJidlo();
}, },
), ),
label: Languages.of(context)!.jump, label: Languages.of(context)!.jump,
@ -63,295 +61,288 @@ class _MealViewState extends State<MealView> {
} }
} }
Future<void> loadMeals() async { Future<void> nactiJidlo() async {
content = [const CircularProgressIndicator()]; obsah = [const CircularProgressIndicator()];
switch (day.weekday) { switch (den.weekday) {
case 2: case 2:
dayOWeek = Languages.of(context)!.tuesday; denTydne = Languages.of(context)!.tuesday;
break; break;
case 3: case 3:
dayOWeek = Languages.of(context)!.wednesday; denTydne = Languages.of(context)!.wednesday;
break; break;
case 4: case 4:
dayOWeek = Languages.of(context)!.thursday; denTydne = Languages.of(context)!.thursday;
break; break;
case 5: case 5:
dayOWeek = Languages.of(context)!.friday; denTydne = Languages.of(context)!.friday;
break; break;
case 6: case 6:
dayOWeek = Languages.of(context)!.saturday; denTydne = Languages.of(context)!.saturday;
break; break;
case 7: case 7:
dayOWeek = Languages.of(context)!.sunday; denTydne = Languages.of(context)!.sunday;
break; break;
default: default:
dayOWeek = Languages.of(context)!.monday; denTydne = Languages.of(context)!.monday;
} }
var uzivatel = await widget.canteen.ziskejUzivatele().catchError( widget.canteen.ziskejUzivatele().then((kr) {
(o) { kredit = kr.kredit;
if (!widget.canteen.prihlasen) { widget.canteen.jidelnicekDen(den: den).then((jd) async {
Navigator.pushReplacement( setState(() {
context, platformRouter((c) => const LoginPage())); obsah = [];
} if (jd.jidla.isEmpty) {
return Uzivatel(kredit: 0); obsah.add(Text(
}, Languages.of(context)!.noFood,
); style: const TextStyle(fontSize: 15),
balance = uzivatel.kredit; ));
var jd = await widget.canteen.jidelnicekDen(den: day).catchError((_) { } else {
showInfo(context, Languages.of(context)!.errorContacting); for (var j in jd.jidla) {
return Jidelnicek(DateTime.now(), []); obsah.add(
}); Padding(
setState( padding: const EdgeInsets.only(top: 15),
() { child: InkWell(
content = []; child: Row(
if (jd.jidla.isEmpty) { mainAxisAlignment: MainAxisAlignment.spaceBetween,
content.add(Text( children: [
Languages.of(context)!.noFood, Text(j.varianta),
style: const TextStyle(fontSize: 15), const SizedBox(width: 10),
)); Flexible(
} else { child: Text(
for (var j in jd.jidla) { j.nazev,
content.add( ),
Padding(
padding: const EdgeInsets.only(top: 15),
child: InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(j.varianta),
const SizedBox(width: 10),
Flexible(
child: Text(
j.nazev,
), ),
), Text((j.naBurze)
Text((j.naBurze) ? Languages.of(context)!.inExchange
? Languages.of(context)!.inExchange : "${j.cena}"),
: "${j.cena}"), Checkbox(
Checkbox( value: j.objednano,
value: j.objednano, fillColor: (j.lzeObjednat)
fillColor: (j.lzeObjednat) ? MaterialStateProperty.all(Colors.purple)
? MaterialStateProperty.all(Colors.purple) : MaterialStateProperty.all(Colors.grey),
: MaterialStateProperty.all(Colors.grey), onChanged: (v) async {
onChanged: (v) async { if (!j.lzeObjednat) {
if (!j.lzeObjednat) { showDialog(
showDialog( context: context,
context: context, builder: (context) {
builder: (context) { return AlertDialog(
return PlatformDialog( title: Text(Languages.of(context)!
title: Languages.of(context)!.errorOrdering, .errorOrdering),
content: Languages.of(context)!.cannotOrder, content: Text(
actions: [ Languages.of(context)!.cannotOrder),
PlatformButton( actions: [
text: Languages.of(context)!.ok, TextButton(
onPressed: () { child:
Navigator.of(context).pop(); Text(Languages.of(context)!.ok),
}, onPressed: () {
) Navigator.of(context).pop();
], },
); )
}, ],
); );
} else { });
showDialog( } else {
context: context, showDialog(
barrierDismissible: false, context: context,
builder: (_) => Dialog( barrierDismissible: false,
child: SizedBox( builder: (_) => Dialog(
height: 100, child: SizedBox(
child: Row( height: 100,
children: [ 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) {
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,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding( const Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
), ),
Text(Languages.of(context)!.ordering) Text(Languages.of(context)!.ordering)
], ]),
), ),
), ));
), widget.canteen.objednat(j).then((_) {
);
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
loadMeals();
}).catchError(
(o) {
Navigator.of(context, rootNavigator: true)
.pop();
showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: o.toString(),
actions: [
PlatformButton(
text: Languages.of(context)!.close,
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
},
);
}
},
)
],
),
onTap: () async {
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: Languages.of(context)!.cannotOrder,
actions: [
PlatformButton(
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();
loadMeals();
}).catchError(
(o) {
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
showDialog( nactiJidlo();
context: context, }).catchError(
builder: (bc) => PlatformDialog( (o) {
title: Languages.of(context)!.errorOrdering, Navigator.of(context, rootNavigator: true).pop();
content: o.toString(), showDialog(
actions: [ context: context,
PlatformButton( builder: (bc) => AlertDialog(
text: Languages.of(context)!.close, title:
onPressed: () { Text(Languages.of(context)!.errorOrdering),
Navigator.pop(bc); 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; },
if (!j.naBurze) { );
// if not in exchange, we ask
var d = await showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.verifyExchange,
actions: [
PlatformButton(
onPressed: () {
Navigator.pop(bc, true);
},
text: Languages.of(context)!.yes,
),
PlatformButton(
onPressed: () {
Navigator.pop(bc, false);
},
text: Languages.of(context)!.no,
),
],
),
);
if (d) {
widget.canteen
.doBurzy(j)
.then((_) => loadMeals())
.catchError((o) {
showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.exchangeError,
content: o.toString(),
actions: [
PlatformButton(
text: Languages.of(context)!.close,
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
});
} }
} else { },
// else no onLongPress: () async {
widget.canteen.doBurzy(j).then((_) => loadMeals()); if (!j.objednano || j.burzaUrl == null) return;
} if (!j.naBurze) {
}, // pokud není na burze, radši se zeptáme
var d = await showDialog(
context: context,
builder: (bc) => SimpleDialog(
title: Text(
Languages.of(context)!.verifyExchange),
children: [
SimpleDialogOption(
onPressed: () {
Navigator.pop(bc, true);
},
child: Text(Languages.of(context)!.yes),
),
SimpleDialogOption(
onPressed: () {
Navigator.pop(bc, false);
},
child: Text(Languages.of(context)!.no),
),
],
));
if (d) {
widget.canteen
.doBurzy(j)
.then((_) => nactiJidlo())
.catchError((o) {
showDialog(
context: context,
builder: (bc) => AlertDialog(
title:
Text(Languages.of(context)!.exchangeError),
content: SingleChildScrollView(
child: Text(o.toString())),
actions: [
TextButton(
child: Text(Languages.of(context)!.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
});
}
} else {
// jinak ne
widget.canteen.doBurzy(j).then((_) => nactiJidlo());
}
},
),
), ),
), );
); }
} }
} });
}, });
); }).catchError((o) {
return; if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
} }
Future<void> click(String value, BuildContext context) async { Future<void> kliknuti(String value, BuildContext context) async {
if (value == Languages.of(context)!.signOut) { if (value == Languages.of(context)!.signOut) {
await showDialog<bool>( await showDialog<bool>(
context: context, context: context,
builder: (c) => PlatformDialog( builder: (c) => AlertDialog(
title: Languages.of(context)!.warning, title: Text(Languages.of(context)!.warning),
content: Languages.of(context)!.signOutWarn, content: Text(Languages.of(context)!.signOutWarn),
actions: [ actions: [
PlatformButton( TextButton(
onPressed: () { onPressed: () {
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
storage.deleteAll(); storage.deleteAll();
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
platformRouter((c) => const LoginPage()), MaterialPageRoute(builder: (c) => const LoginPage()),
(route) => false); (route) => false);
}, },
text: Languages.of(context)!.yes), child: Text(Languages.of(context)!.yes)),
PlatformButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
text: Languages.of(context)!.no, child: Text(Languages.of(context)!.no))
)
], ],
), ),
); );
} else if (value == Languages.of(context)!.review) { } else if (value == Languages.of(context)!.review) {
launchUrl( launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"),
Uri.parse((Platform.isAndroid)
? "market://details?id=cz.hernikplays.opencanteen"
: "https://apps.apple.com/cz/app/opencanteen/id1621124445"),
mode: LaunchMode.externalApplication); mode: LaunchMode.externalApplication);
} else if (value == Languages.of(context)!.reportBugs) { } else if (value == Languages.of(context)!.reportBugs) {
launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"), launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"),
@ -366,29 +357,28 @@ class _MealViewState extends State<MealView> {
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}", "${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
applicationVersion: packageInfo.version, applicationVersion: packageInfo.version,
children: [ children: [
PlatformButton( TextButton(
onPressed: (() => launchUrl( onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"), Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
mode: LaunchMode.externalApplication)), child: Text(Languages.of(context)!.source))
text: Languages.of(context)!.source,
)
]); ]);
} else if (value == Languages.of(context)!.settings) { } else if (value == Languages.of(context)!.settings) {
Navigator.push(context, platformRouter((c) => const AndroidNastaveni())); Navigator.push(
context, MaterialPageRoute(builder: (c) => const AndroidNastaveni()));
} }
} }
void loadSettings() async { void nactiNastaveni() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
_skipWeekend = prefs.getBool("skip") ?? false; _skipWeekend = prefs.getBool("skip") ?? false;
if (!mounted) return; if (!mounted) return;
checkWeek(context); kontrolaTyden(context);
} }
void saveOffline() async { void ulozitDoOffline() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("offline") ?? false) { if (prefs.getBool("offline") ?? false) {
// clear offline storage // vyčistit offline
Directory appDocDir = await getApplicationDocumentsDirectory(); Directory appDocDir = await getApplicationDocumentsDirectory();
for (var f in appDocDir.listSync()) { for (var f in appDocDir.listSync()) {
if (f.path.contains("jidelnicek")) { if (f.path.contains("jidelnicek")) {
@ -396,11 +386,11 @@ class _MealViewState extends State<MealView> {
} }
} }
// save X meal lists // uložit *pocet* jídelníčků pro offline použití
var pocet = prefs.getInt("offline_pocet") ?? 1; var pocet = prefs.getInt("offline_pocet") ?? 1;
if (pocet > 7) pocet = 7; if (pocet > 7) pocet = 7;
for (var i = 0; i < pocet; i++) { for (var i = 0; i < pocet; i++) {
var d = day.add(Duration(days: i)); var d = den.add(Duration(days: i));
Jidelnicek? j; Jidelnicek? j;
try { try {
j = await widget.canteen.jidelnicekDen(den: d); j = await widget.canteen.jidelnicekDen(den: d);
@ -437,9 +427,9 @@ class _MealViewState extends State<MealView> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
loadSettings(); nactiNastaveni();
saveOffline(); ulozitDoOffline();
loadMeals(); nactiJidlo();
} }
@override @override
@ -450,7 +440,7 @@ class _MealViewState extends State<MealView> {
title: Text(Languages.of(context)!.menu), title: Text(Languages.of(context)!.menu),
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
onSelected: ((String value) => click(value, context)), onSelected: ((String value) => kliknuti(value, context)),
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return { return {
Languages.of(context)!.reportBugs, Languages.of(context)!.reportBugs,
@ -469,71 +459,62 @@ class _MealViewState extends State<MealView> {
], ],
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: loadMeals, onRefresh: nactiJidlo,
child: Center( child: Center(
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width - 50, width: MediaQuery.of(context).size.width - 50,
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
Text("${Languages.of(context)!.balance}$balance"), Text("${Languages.of(context)!.balance}$kredit"),
Row( Row(mainAxisAlignment: MainAxisAlignment.center, children: [
mainAxisAlignment: MainAxisAlignment.center, IconButton(
children: [ onPressed: () {
IconButton( setState(() {
onPressed: () { den = den.subtract(const Duration(days: 1));
setState(() { if (den.weekday == 7 && _skipWeekend) {
day = day.subtract(const Duration(days: 1)); den = den.subtract(const Duration(days: 2));
if (day.weekday == 7 && _skipWeekend) { }
day = day.subtract(const Duration(days: 2)); nactiJidlo();
} });
loadMeals(); },
}); icon: const Icon(Icons.arrow_left)),
}, TextButton(
icon: const Icon(Icons.arrow_left)),
PlatformButton(
onPressed: () async { onPressed: () async {
var datePicked = await showDatePicker( var datePicked = await showDatePicker(
context: context, context: context,
initialDate: day, initialDate: den,
currentDate: day, currentDate: den,
firstDate: DateTime(2019, 1, 1), firstDate: DateTime(2019, 1, 1),
lastDate: DateTime(day.year + 1, 12, 31), lastDate: DateTime(den.year + 1, 12, 31),
locale: Localizations.localeOf(context)); locale: Localizations.localeOf(context));
if (datePicked == null) return; if (datePicked == null) return;
setState(() { setState(() {
day = datePicked; den = datePicked;
loadMeals(); nactiJidlo();
}); });
}, },
text: "${day.day}. ${day.month}. ${day.year} - $dayOWeek", child: Text(
), "${den.day}. ${den.month}. ${den.year} - $denTydne")),
IconButton( IconButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
day = day.add(const Duration(days: 1)); den = den.add(const Duration(days: 1));
if (day.weekday == 6 && _skipWeekend) { if (den.weekday == 6 && _skipWeekend) {
day = day.add(const Duration(days: 2)); den = den.add(const Duration(days: 2));
} }
loadMeals(); nactiJidlo();
}); });
}, },
icon: const Icon(Icons.arrow_right), icon: const Icon(Icons.arrow_right),
), ),
Tooltip( IconButton(
message: Languages.of(context)!.todayTooltip, onPressed: () => setState(() {
child: IconButton( den = DateTime.now();
onPressed: () => setState( nactiJidlo();
() { }),
day = DateTime.now(); icon: const Icon(Icons.today))
loadMeals(); ]),
},
),
icon: const Icon(Icons.today),
),
)
],
),
SingleChildScrollView( SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: GestureDetector( child: GestureDetector(
@ -543,27 +524,25 @@ class _MealViewState extends State<MealView> {
.onPrimary .onPrimary
.withOpacity(0), .withOpacity(0),
height: MediaQuery.of(context).size.height / 1.3, height: MediaQuery.of(context).size.height / 1.3,
child: Column(children: content), child: Column(children: obsah),
), ),
onHorizontalDragEnd: (details) { onHorizontalDragEnd: (details) {
if (details.primaryVelocity?.compareTo(0) == -1) { if (details.primaryVelocity?.compareTo(0) == -1) {
setState(() { setState(() {
day = day.add(const Duration(days: 1)); den = den.add(const Duration(days: 1));
if (day.weekday == 6 && _skipWeekend) { if (den.weekday == 6 && _skipWeekend) {
day = day.add(const Duration(days: 2)); den = den.add(const Duration(days: 2));
} }
loadMeals(); nactiJidlo();
}); });
} else { } else {
setState( setState(() {
() { den = den.subtract(const Duration(days: 1));
day = day.subtract(const Duration(days: 1)); if (den.weekday == 7 && _skipWeekend) {
if (day.weekday == 7 && _skipWeekend) { den = den.subtract(const Duration(days: 2));
day = day.subtract(const Duration(days: 2)); }
} nactiJidlo();
loadMeals(); });
},
);
} }
}, },
), ),

View file

@ -1,17 +1,16 @@
import 'dart:io';
import 'package:canteenlib/canteenlib.dart'; import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/okna/welcome.dart'; import 'package:opencanteen/okna/welcome.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/pw/platformfield.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
import '../../loginmanager.dart'; import '../../loginmanager.dart';
import '../../main.dart'; import '../../main.dart';
import '../../util.dart'; import '../../util.dart';
import '../pw/platformswitch.dart';
import 'jidelnicek.dart'; import 'jidelnicek.dart';
import 'offline_jidelnicek.dart'; import 'offline_jidelnicek.dart';
@ -33,14 +32,14 @@ class _LoginPageState extends State<LoginPage> {
void initState() { void initState() {
super.initState(); super.initState();
LoginManager.getDetails().then((r) async { LoginManager.getDetails().then((r) async {
// request android notification access // žádat o oprávnění na android
flutterLocalNotificationsPlugin flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>() AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission(); ?.requestPermission();
if (r != null) { if (r != null) {
// Autologin // Automaticky přihlásit
showDialog( showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
@ -75,26 +74,36 @@ class _LoginPageState extends State<LoginPage> {
if (odsouhlasil == null || odsouhlasil != "ano") { if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
platformRouter( MaterialPageRoute(
(c) => WelcomePage(canteen: canteen), builder: (c) => WelcomePage(canteen: canteen),
), ),
(route) => false); (route) => false);
} else { } else {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
platformRouter( MaterialPageRoute(
(context) => MealView(canteen: canteen), builder: (context) => JidelnicekView(canteen: canteen),
), ),
(route) => false); (route) => false);
} }
} on PlatformException { } on PlatformException {
if (!mounted) return; if (!mounted) return;
Navigator.of(context).pop(); Navigator.of(context).pop();
showInfo(context, Languages.of(context)!.corrupted); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.corrupted),
),
);
} catch (_) { } catch (_) {
if (!mounted) return; if (!mounted) return;
Navigator.of(context).pop(); Navigator.of(context).pop();
showInfo(context, Languages.of(context)!.errorContacting); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.errorContacting),
),
);
goOffline(); goOffline();
} }
} }
@ -104,150 +113,169 @@ class _LoginPageState extends State<LoginPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(Languages.of(context)!.logIn), title: Text(Languages.of(context)!.logIn),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
), ),
body: Center( body: Center(
child: SingleChildScrollView( child: SingleChildScrollView(
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width - 50, width: MediaQuery.of(context).size.width - 50,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
Languages.of(context)!.appName, Languages.of(context)!.appName,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 40), fontWeight: FontWeight.bold, fontSize: 40),
),
Text(
Languages.of(context)!.logIn,
textAlign: TextAlign.center,
),
PlatformField(
controller: userControl,
autofillHints: const [AutofillHints.username],
labelText: Languages.of(context)!.username,
),
PlatformField(
autofillHints: const [AutofillHints.password],
labelText: Languages.of(context)!.password,
controller: passControl,
obscureText: true,
),
const SizedBox(
height: 10,
),
DropdownButton(
isExpanded: true,
value: dropdownUrl,
items: instance.map<DropdownMenuItem<String>>((e) {
return DropdownMenuItem<String>(
value: e["url"],
child: Text(e["name"]!),
);
}).toList(),
onChanged: (String? value) {
setState(() {
if (value == "") {
_showUrl = true;
} else {
_showUrl = false;
}
dropdownUrl = value!;
});
},
),
AnimatedOpacity(
opacity: _showUrl ? 1.0 : 0.0,
duration: const Duration(milliseconds: 300),
child: PlatformField(
autofillHints: const [AutofillHints.url],
labelText: Languages.of(context)!.iCanteenUrl,
keyboardType: TextInputType.url,
controller: canteenControl,
), ),
), Text(
Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Languages.of(context)!.logIn,
PlatformSwitch( textAlign: TextAlign.center,
value: rememberMe, ),
onChanged: (value) { TextField(
controller: userControl,
autofillHints: const [AutofillHints.username],
decoration: InputDecoration(
labelText: Languages.of(context)!.username),
),
TextField(
autofillHints: const [AutofillHints.password],
decoration: InputDecoration(
labelText: Languages.of(context)!.password),
controller: passControl,
obscureText: true,
),
const SizedBox(
height: 10,
),
DropdownButton(
isExpanded: true,
value: dropdownUrl,
items: instance.map<DropdownMenuItem<String>>((e) {
return DropdownMenuItem<String>(
value: e["url"],
child: Text(e["name"]!),
);
}).toList(),
onChanged: (String? value) {
setState(() { setState(() {
rememberMe = value; if (value == "") {
_showUrl = true;
} else {
_showUrl = false;
}
dropdownUrl = value!;
}); });
}, },
), ),
Text(Languages.of(context)!.rememberMe) AnimatedOpacity(
]), opacity: _showUrl ? 1.0 : 0.0,
PlatformButton( duration: const Duration(milliseconds: 300),
onPressed: () async { child: TextField(
var canteenUrl = (dropdownUrl == "") autofillHints: const [AutofillHints.url],
? canteenControl.text decoration: InputDecoration(
: dropdownUrl; labelText: Languages.of(context)!.iCanteenUrl),
if (!canteenUrl.startsWith("https://") && keyboardType: TextInputType.url,
!canteenUrl.startsWith("http://")) { controller: canteenControl,
canteenUrl = "https://$canteenUrl"; ),
} ),
var canteen = Canteen(canteenUrl); Row(mainAxisAlignment: MainAxisAlignment.center, children: [
try { Switch(
var l = await canteen.login( value: rememberMe,
userControl.text, passControl.text); onChanged: (value) {
if (!l) { setState(() {
rememberMe = value;
});
}),
Text(Languages.of(context)!.rememberMe)
]),
TextButton(
onPressed: () async {
var canteenUrl = (dropdownUrl == "")
? canteenControl.text
: dropdownUrl;
if (!canteenUrl.startsWith("https://") &&
!canteenUrl.startsWith("http://")) {
canteenUrl = "https://$canteenUrl";
}
var canteen = Canteen(canteenUrl);
try {
var l = await canteen.login(
userControl.text, passControl.text);
if (!l) {
if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text(Languages.of(context)!.loginFailed),
),
);
return;
}
if (rememberMe) {
LoginManager.setDetails(
userControl.text, passControl.text, canteenUrl);
}
// souhlas
const storage = FlutterSecureStorage();
var odsouhlasil =
await storage.read(key: "oc_souhlas");
if (!mounted) return; if (!mounted) return;
showInfo(context, Languages.of(context)!.loginFailed); if (odsouhlasil == null || odsouhlasil != "ano") {
return; Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (c) => WelcomePage(
canteen: canteen,
)),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => JidelnicekView(
canteen: canteen,
)),
(route) => false);
}
} on PlatformException {
if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.corrupted),
),
);
} on Exception catch (_) {
if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text(Languages.of(context)!.errorContacting),
),
);
goOffline();
} }
if (rememberMe) { },
LoginManager.setDetails( child: Text(Languages.of(context)!.logIn)),
userControl.text, passControl.text, canteenUrl); ],
} ),
// souhlas
const storage = FlutterSecureStorage();
var odsouhlasil = await storage.read(key: "oc_souhlas");
if (!mounted) return;
if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushAndRemoveUntil(
context,
platformRouter(
(context) => WelcomePage(
canteen: canteen,
),
),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
platformRouter(
(context) => MealView(
canteen: canteen,
),
),
(route) => false);
}
} on PlatformException {
if (!mounted) return;
showInfo(context, Languages.of(context)!.corrupted);
} on Exception catch (_) {
if (!mounted) return;
showInfo(
context, Languages.of(context)!.errorContacting);
//goOffline();
}
},
text: Languages.of(context)!.logIn),
],
), ),
), ),
), ));
),
);
} }
/// Switch to offline view /// Získá offline soubor a zobrazí údaje
void goOffline() async { void goOffline() async {
if (!mounted) return; if (!mounted) return;
Navigator.pushAndRemoveUntil(context, Navigator.pushAndRemoveUntil(
platformRouter((context) => const OfflineMealView()), (route) => false); context,
MaterialPageRoute(
builder: ((context) => const AndroidOfflineJidelnicek())),
(route) => false);
} }
} }

View file

@ -5,10 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_native_timezone/flutter_native_timezone.dart'; import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/pw/platformdialog.dart';
import 'package:opencanteen/pw/platformfield.dart';
import 'package:opencanteen/pw/platformswitch.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:timezone/timezone.dart' as tz; import 'package:timezone/timezone.dart' as tz;
@ -26,48 +22,45 @@ class AndroidNastaveni extends StatefulWidget {
} }
class _AndroidNastaveniState extends State<AndroidNastaveni> { class _AndroidNastaveniState extends State<AndroidNastaveni> {
bool _saveOffline = false; bool _ukladatOffline = false;
bool _skipWeekend = false; bool _preskakovatVikend = false;
bool _checkWeek = false; bool _kontrolovatTyden = false;
bool _notifyMeal = false; bool _oznameniObed = false;
bool _remember = false; bool _zapamatovany = false;
TimeOfDay _notifTime = TimeOfDay.now(); TimeOfDay _oznameniCas = TimeOfDay.now();
final TextEditingController _countController = final TextEditingController _countController =
TextEditingController(text: "1"); TextEditingController(text: "1");
SharedPreferences? preferences; SharedPreferences? preferences;
void najitNastaveni() async {
void loadSettings() async {
preferences = await SharedPreferences.getInstance(); preferences = await SharedPreferences.getInstance();
_remember = await LoginManager.rememberme(); _zapamatovany = await LoginManager.zapamatovat();
setState( setState(() {
() { _ukladatOffline = preferences!.getBool("offline") ?? false;
_saveOffline = preferences!.getBool("offline") ?? false; _preskakovatVikend = preferences!.getBool("skip") ?? false;
_skipWeekend = preferences!.getBool("skip") ?? false; _kontrolovatTyden = preferences!.getBool("tyden") ?? false;
_checkWeek = preferences!.getBool("tyden") ?? false; _oznameniObed = preferences!.getBool("oznamit") ?? false;
_notifyMeal = preferences!.getBool("oznamit") ?? false; _countController.text =
_countController.text = (preferences!.getInt("offline_pocet") ?? 1).toString();
(preferences!.getInt("offline_pocet") ?? 1).toString(); var casStr = preferences!.getString("oznameni_cas");
var casStr = preferences!.getString("oznameni_cas"); if (casStr == null) {
if (casStr == null) { var now = DateTime.now();
var now = DateTime.now(); _oznameniCas = TimeOfDay.fromDateTime(
_notifTime = TimeOfDay.fromDateTime( DateTime.now().add(const Duration(hours: 1)));
DateTime.now().add(const Duration(hours: 1))); preferences!.setString("oznameni_cas", now.toString());
preferences!.setString("oznameni_cas", now.toString()); } else {
} else { _oznameniCas = TimeOfDay.fromDateTime(DateTime.parse(casStr));
_notifTime = TimeOfDay.fromDateTime(DateTime.parse(casStr)); }
} });
},
);
} }
void changeSetting(String key, bool value) async { void zmenitNastaveni(String key, bool value) async {
preferences!.setBool(key, value); preferences!.setBool(key, value);
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
loadSettings(); najitNastaveni();
} }
@override @override
@ -77,168 +70,168 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
title: Text(Languages.of(context)!.settings), title: Text(Languages.of(context)!.settings),
), ),
body: Center( body: Center(
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width / 1.1, width: MediaQuery.of(context).size.width / 1.1,
child: Column( child: Column(
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(Languages.of(context)!.saveOffline), Text(Languages.of(context)!.saveOffline),
PlatformSwitch( Switch(
value: _saveOffline, value: _ukladatOffline,
activeColor: Colors.purple,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_saveOffline = value; _ukladatOffline = value;
clear(value); cistit(value);
changeSetting("offline", value); zmenitNastaveni("offline", value);
}); });
})
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(Languages.of(context)!.saveCount),
SizedBox(
width: 35,
child: TextField(
controller: _countController,
enabled: _ukladatOffline,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (c) {
var cislo = int.tryParse(c);
if (cislo != null) {
preferences!.setInt("offline_pocet", cislo);
}
}, },
) ),
], )
), ],
Row( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
Text(Languages.of(context)!.saveCount), children: [
SizedBox( Text(Languages.of(context)!.skipWeekend),
width: 35, Switch(
child: PlatformField( activeColor: Colors.purple,
controller: _countController, value: _preskakovatVikend,
enabled: _saveOffline,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (c) {
var cislo = int.tryParse(c);
if (cislo != null) {
preferences!.setInt("offline_pocet", cislo);
}
},
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(Languages.of(context)!.skipWeekend),
PlatformSwitch(
value: _skipWeekend,
onChanged: (value) { onChanged: (value) {
setState( setState(() {
() { _preskakovatVikend = value;
_skipWeekend = value; zmenitNastaveni("skip", value);
changeSetting("skip", value); });
}, })
); ],
}, ),
) Row(
], mainAxisAlignment: MainAxisAlignment.spaceBetween,
), children: [
Row( Flexible(child: Text(Languages.of(context)!.checkOrdered)),
mainAxisAlignment: MainAxisAlignment.spaceBetween, Switch(
children: [ activeColor: Colors.purple,
Flexible(child: Text(Languages.of(context)!.checkOrdered)), value: _kontrolovatTyden,
PlatformSwitch(
value: _checkWeek,
onChanged: (value) { onChanged: (value) {
setState( setState(() {
() { _kontrolovatTyden = value;
_checkWeek = value; zmenitNastaveni("tyden", value);
changeSetting("tyden", value); });
}, })
); ],
}, ),
) Row(
], mainAxisAlignment: MainAxisAlignment.spaceBetween,
), children: [
Row( Flexible(child: Text(Languages.of(context)!.notifyLunch)),
mainAxisAlignment: MainAxisAlignment.spaceBetween, Switch(
children: [ activeColor: Colors.purple,
Flexible(child: Text(Languages.of(context)!.notifyLunch)), value: _oznameniObed,
PlatformSwitch( thumbColor: (!_zapamatovany
value: _notifyMeal, ? MaterialStateProperty.all(Colors.grey)
thumbColor: (!_remember ? Colors.grey : null), : null),
onChanged: (value) { onChanged: (value) {
if (!_remember) { if (!_zapamatovany) {
showDialog( showDialog(
context: context, context: context,
builder: (bc) => PlatformDialog( builder: (bc) => AlertDialog(
title: Languages.of(context)!.error, title: Text(Languages.of(context)!.error),
content: Languages.of(context)!.needRemember, content:
actions: [ Text(Languages.of(context)!.needRemember),
PlatformButton( actions: [
text: Languages.of(context)!.ok, TextButton(
onPressed: () { child: Text(Languages.of(context)!.ok),
Navigator.of(context).pop(); onPressed: () {
}, Navigator.of(context).pop();
) },
], )
), ],
); ));
} else { } else {
setState(() { setState(() {
_notifyMeal = value; _oznameniObed = value;
if (_notifyMeal) { if (_oznameniObed) {
showDialog( showDialog(
context: context, context: context,
builder: (context) => PlatformDialog( builder: (context) => AlertDialog(
title: Languages.of(context)!.warning, title:
content: Languages.of(context)!.notifyWarning, Text(Languages.of(context)!.warning),
actions: [ content: Text(
PlatformButton( Languages.of(context)!.notifyWarning),
text: Languages.of(context)!.ok, actions: [
onPressed: () { TextButton(
Navigator.of(context).pop(); child:
}, Text(Languages.of(context)!.ok),
) onPressed: () {
], Navigator.of(context).pop();
), },
); )
createNotif(timeToDate(_notifTime)); ],
));
vytvoritOznameni(casNaDate(_oznameniCas));
} }
changeSetting("oznamit", value); zmenitNastaveni("oznamit", value);
}); });
} }
}, })
) ],
], ),
), Text(Languages.of(context)!.notifyAt),
Text(Languages.of(context)!.notifyAt), TextButton(
PlatformButton( onPressed: () async {
onPressed: () async { if (_oznameniObed) {
if (_notifyMeal) { var cas = await showTimePicker(
var cas = await showTimePicker( context: context, initialTime: _oznameniCas);
context: context, initialTime: _notifTime); if (cas != null) {
if (cas != null) { var prefs = await SharedPreferences.getInstance();
var prefs = await SharedPreferences.getInstance(); prefs.setString("oznameni_cas",
prefs.setString( casNaDate(cas).toString()); // aktualizovat vybraný čas
"oznameni_cas", var den = casNaDate(cas);
timeToDate(cas) debugPrint(den.isAfter(DateTime.now()).toString());
.toString()); // aktualizovat vybraný čas if (den.isAfter(DateTime.now())) {
var den = timeToDate(cas); // znovu vytvořit oznámení POUZE když je čas v budoucnosti
debugPrint(den.isAfter(DateTime.now()).toString()); vytvoritOznameni(den);
if (den.isAfter(DateTime.now())) {
// znovu vytvořit oznámení POUZE když je čas v budoucnosti
createNotif(den);
}
} }
setState(() {
_notifTime = cas ?? _notifTime;
});
} }
}, setState(() {
text: _oznameniCas = cas ?? _oznameniCas;
"${(_notifTime.hour < 10 ? "0" : "") + _notifTime.hour.toString()}:${(_notifTime.minute < 10 ? "0" : "") + _notifTime.minute.toString()}", });
}
},
child: Text(
"${(_oznameniCas.hour < 10 ? "0" : "") + _oznameniCas.hour.toString()}:${(_oznameniCas.minute < 10 ? "0" : "") + _oznameniCas.minute.toString()}",
style: TextStyle(
color: (!_oznameniObed) ? Colors.grey : Colors.purple),
), ),
], ),
), ],
), ),
), )),
); );
} }
void clear(bool value) async { void cistit(bool value) async {
if (!value) { if (!value) {
Directory appDocDir = await getApplicationDocumentsDirectory(); Directory appDocDir = await getApplicationDocumentsDirectory();
for (var f in appDocDir.listSync()) { for (var f in appDocDir.listSync()) {
@ -250,10 +243,11 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
} }
} }
void createNotif(DateTime den) async { void vytvoritOznameni(DateTime den) async {
await flutterLocalNotificationsPlugin.cancelAll(); await flutterLocalNotificationsPlugin.cancelAll();
var d = await LoginManager.getDetails(); // grab details var d = await LoginManager.getDetails(); // získat údaje
if (d != null) { if (d != null) {
// Nové oznámení
var c = Canteen(d["url"]!); var c = Canteen(d["url"]!);
if (await c.login(d["user"]!, d["pass"]!)) { if (await c.login(d["user"]!, d["pass"]!)) {
var jidla = await c.jidelnicekDen(); var jidla = await c.jidelnicekDen();
@ -270,7 +264,7 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
tz.getLocation(await FlutterNativeTimezone.getLocalTimezone()); tz.getLocation(await FlutterNativeTimezone.getLocalTimezone());
if (!mounted) return; if (!mounted) return;
await flutterLocalNotificationsPlugin.zonedSchedule( await flutterLocalNotificationsPlugin.zonedSchedule(
// schedules a notification // Vytvoří nové oznámení pro daný čas a datum
0, 0,
Languages.of(context)!.lunchNotif, Languages.of(context)!.lunchNotif,
"${jidlo.varianta} - ${jidlo.nazev}", "${jidlo.varianta} - ${jidlo.nazev}",
@ -280,7 +274,7 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime); UILocalNotificationDateInterpretation.absoluteTime);
} on StateError catch (_) { } on StateError catch (_) {
// no meal found // nenalezeno
} }
} }
} }

View file

@ -4,7 +4,6 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/okna/login.dart'; import 'package:opencanteen/okna/login.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/util.dart'; import 'package:opencanteen/util.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -13,90 +12,90 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
class OfflineMealView extends StatefulWidget { class AndroidOfflineJidelnicek extends StatefulWidget {
const OfflineMealView({Key? key}) : super(key: key); const AndroidOfflineJidelnicek({Key? key}) : super(key: key);
@override @override
State<OfflineMealView> createState() => _OfflineMealViewState(); State<AndroidOfflineJidelnicek> createState() =>
_AndroidOfflineJidelnicekState();
} }
class _OfflineMealViewState extends State<OfflineMealView> { class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
List<Widget> content = [const CircularProgressIndicator()]; // view content List<Widget> obsah = [const CircularProgressIndicator()];
var _skipWeekend = false; // skip weekend setting var _skipWeekend = false;
DateTime currentDay = DateTime.now(); // the day we are supposed to show DateTime den = DateTime.now();
String dayOWeek = ""; // the name of the day (to show to user) String denTydne = "";
List<List<OfflineMeal>> data = []; // meal data List<List<OfflineJidlo>> data = [];
var mealIndex = 0; // index of the currently shown day var jidloIndex = 0;
/// Loads the offline data from local storage void nactiZeSouboru() async {
void loadFromFile() async {
Directory appDocDir = await getApplicationDocumentsDirectory(); Directory appDocDir = await getApplicationDocumentsDirectory();
for (var f in appDocDir.listSync()) { for (var f in appDocDir.listSync()) {
if (f.path.contains("jidelnicek")) { if (f.path.contains("jidelnicek")) {
var soubor = File(f.path); var soubor = File(f.path);
var input = await soubor.readAsString(); var input = await soubor.readAsString();
var r = jsonDecode(input); var r = jsonDecode(input);
List<OfflineMeal> jidla = []; List<OfflineJidlo> jidla = [];
for (var j in r) { for (var j in r) {
jidla.add(OfflineMeal( jidla.add(OfflineJidlo(
name: j["nazev"], nazev: j["nazev"],
variant: j["varianta"], varianta: j["varianta"],
ordered: j["objednano"], objednano: j["objednano"],
price: j["cena"], cena: j["cena"],
onExchange: j["naBurze"], naBurze: j["naBurze"],
day: DateTime.parse(j["den"]))); den: DateTime.parse(j["den"])));
} }
data.add(jidla); data.add(jidla);
} }
} }
loadFood(); nactiJidlo();
} }
Future<void> loadFood() async { Future<void> nactiJidlo() async {
var jidelnicek = data[mealIndex]; var jidelnicek = data[jidloIndex];
currentDay = jidelnicek[0].day; den = jidelnicek[0].den;
switch (currentDay.weekday) { switch (den.weekday) {
case 2: case 2:
dayOWeek = Languages.of(context)!.tuesday; denTydne = Languages.of(context)!.tuesday;
break; break;
case 3: case 3:
dayOWeek = Languages.of(context)!.wednesday; denTydne = Languages.of(context)!.wednesday;
break; break;
case 4: case 4:
dayOWeek = Languages.of(context)!.thursday; denTydne = Languages.of(context)!.thursday;
break; break;
case 5: case 5:
dayOWeek = Languages.of(context)!.friday; denTydne = Languages.of(context)!.friday;
break; break;
case 6: case 6:
dayOWeek = Languages.of(context)!.saturday; denTydne = Languages.of(context)!.saturday;
break; break;
case 7: case 7:
dayOWeek = Languages.of(context)!.sunday; denTydne = Languages.of(context)!.sunday;
break; break;
default: default:
dayOWeek = Languages.of(context)!.monday; denTydne = Languages.of(context)!.monday;
} }
content = []; obsah = [];
for (OfflineMeal j in jidelnicek) { for (OfflineJidlo j in jidelnicek) {
content.add( obsah.add(
Padding( Padding(
padding: const EdgeInsets.only(top: 15), padding: const EdgeInsets.only(top: 15),
child: InkWell( child: InkWell(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(j.variant), Text(j.varianta),
const SizedBox(width: 10), const SizedBox(width: 10),
Flexible( Flexible(
child: Text( child: Text(
j.name, j.nazev,
), ),
), ),
Text((j.onExchange) Text((j.naBurze)
? Languages.of(context)!.inExchange ? Languages.of(context)!.inExchange
: "${j.price}"), : "${j.cena}"),
Checkbox( Checkbox(
value: j.ordered, value: j.objednano,
fillColor: MaterialStateProperty.all(Colors.grey), fillColor: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async { onChanged: (v) async {
return; return;
@ -111,17 +110,14 @@ class _OfflineMealViewState extends State<OfflineMealView> {
setState(() {}); setState(() {});
} }
void click(String value, BuildContext context) async { void kliknuti(String value, BuildContext context) async {
if (value == Languages.of(context)!.signOut) { if (value == Languages.of(context)!.signOut) {
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
storage.deleteAll(); storage.deleteAll();
Navigator.pushReplacement( Navigator.pushReplacement(
context, platformRouter((c) => const LoginPage())); context, MaterialPageRoute(builder: (c) => const LoginPage()));
} else if (value == Languages.of(context)!.review) { } else if (value == Languages.of(context)!.review) {
launchUrl( launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"),
Uri.parse((Platform.isAndroid)
? "market://details?id=cz.hernikplays.opencanteen"
: "https://apps.apple.com/cz/app/opencanteen/id1621124445"),
mode: LaunchMode.externalApplication); mode: LaunchMode.externalApplication);
} else if (value == Languages.of(context)!.reportBugs) { } else if (value == Languages.of(context)!.reportBugs) {
launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"), launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"),
@ -130,33 +126,31 @@ class _OfflineMealViewState extends State<OfflineMealView> {
var packageInfo = await PackageInfo.fromPlatform(); var packageInfo = await PackageInfo.fromPlatform();
if (!mounted) return; if (!mounted) return;
showAboutDialog( showAboutDialog(
context: context, context: context,
applicationName: "OpenCanteen", applicationName: "OpenCanteen",
applicationLegalese: applicationLegalese:
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}", "${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
applicationVersion: packageInfo.version, applicationVersion: packageInfo.version,
children: [ children: [
PlatformButton( TextButton(
onPressed: (() => launchUrl( onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))), Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
text: Languages.of(context)!.source, child: Text(Languages.of(context)!.source))
) ]);
],
);
} }
} }
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
loadSettings(); nactiNastaveni();
} }
void loadSettings() async { void nactiNastaveni() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
_skipWeekend = prefs.getBool("skip") ?? false; _skipWeekend = prefs.getBool("skip") ?? false;
if (!mounted) return; if (!mounted) return;
loadFromFile(); nactiZeSouboru();
} }
@override @override
@ -167,7 +161,7 @@ class _OfflineMealViewState extends State<OfflineMealView> {
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
onSelected: ((String value) => click(value, context)), onSelected: ((String value) => kliknuti(value, context)),
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return { return {
Languages.of(context)!.reportBugs, Languages.of(context)!.reportBugs,
@ -201,69 +195,69 @@ class _OfflineMealViewState extends State<OfflineMealView> {
IconButton( IconButton(
onPressed: () { onPressed: () {
if (data.length <= 1) return; if (data.length <= 1) return;
content = [const CircularProgressIndicator()]; obsah = [const CircularProgressIndicator()];
setState(() { setState(() {
if (currentDay.weekday == 1 && _skipWeekend) { if (den.weekday == 1 && _skipWeekend) {
// pokud je pondělí a chceme přeskočit víkend // pokud je pondělí a chceme přeskočit víkend
if (mealIndex - 2 >= 0) { if (jidloIndex - 2 >= 0) {
mealIndex -= data.length - 3; jidloIndex -= data.length - 3;
} else { } else {
mealIndex = data.length - 1; jidloIndex = data.length - 1;
} }
} else if (mealIndex == 0) { } else if (jidloIndex == 0) {
mealIndex = data.length - 1; jidloIndex = data.length - 1;
} else { } else {
mealIndex -= 1; jidloIndex -= 1;
} }
loadFood(); nactiJidlo();
}); });
}, },
icon: const Icon(Icons.arrow_left)), icon: const Icon(Icons.arrow_left)),
PlatformButton( TextButton(
onPressed: () async {}, onPressed: () async {},
text: child: Text(
"${currentDay.day}. ${currentDay.month}. ${currentDay.year} - $dayOWeek"), "${den.day}. ${den.month}. ${den.year} - $denTydne")),
IconButton( IconButton(
onPressed: () { onPressed: () {
if (data.length <= 1) return; if (data.length <= 1) return;
content = [const CircularProgressIndicator()]; obsah = [const CircularProgressIndicator()];
setState(() { setState(() {
if (currentDay.weekday == 5 && _skipWeekend) { if (den.weekday == 5 && _skipWeekend) {
// pokud je pondělí a chceme přeskočit víkend // pokud je pondělí a chceme přeskočit víkend
if (mealIndex + 2 <= data.length - 1) { if (jidloIndex + 2 <= data.length - 1) {
mealIndex += 2; jidloIndex += 2;
} else { } else {
mealIndex = 0; jidloIndex = 0;
} }
} else if (mealIndex == data.length) { } else if (jidloIndex == data.length) {
mealIndex = 0; jidloIndex = 0;
} else { } else {
mealIndex += 1; jidloIndex += 1;
} }
loadFood(); nactiJidlo();
}); });
}, },
icon: const Icon(Icons.arrow_right), icon: const Icon(Icons.arrow_right),
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
mealIndex = 0; jidloIndex = 0;
}, },
icon: const Icon(Icons.today)) icon: const Icon(Icons.today))
]), ]),
SingleChildScrollView( SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: Column( child: Column(
children: content, children: obsah,
), ),
), ),
], ],
), ),
), ),
), ),
onRefresh: () => Navigator.pushReplacement( onRefresh: () => Navigator.pushReplacement(context,
context, platformRouter((context) => const LoginPage())), MaterialPageRoute(builder: ((context) => const LoginPage()))),
), ),
); );
} }

View file

@ -4,7 +4,6 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:introduction_screen/introduction_screen.dart'; import 'package:introduction_screen/introduction_screen.dart';
import 'package:opencanteen/lang/lang.dart'; import 'package:opencanteen/lang/lang.dart';
import 'package:opencanteen/okna/jidelnicek.dart'; import 'package:opencanteen/okna/jidelnicek.dart';
import 'package:opencanteen/util.dart';
class WelcomePage extends StatefulWidget { class WelcomePage extends StatefulWidget {
const WelcomePage({Key? key, required this.canteen}) : super(key: key); const WelcomePage({Key? key, required this.canteen}) : super(key: key);
@ -69,7 +68,8 @@ class _WelcomePageState extends State<WelcomePage> {
await storage.write(key: "oc_souhlas", value: "ano"); await storage.write(key: "oc_souhlas", value: "ano");
if (!mounted) return; if (!mounted) return;
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
platformRouter((c) => MealView(canteen: widget.canteen)), MaterialPageRoute(
builder: (c) => JidelnicekView(canteen: widget.canteen)),
(route) => false); (route) => false);
}, },
), ),

View file

@ -1,18 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:opencanteen/pw/platformwidget.dart';
class PlatformButton extends PlatformWidget<TextButton, CupertinoButton> {
final String text;
final void Function()? onPressed;
const PlatformButton(
{super.key, required this.text, required this.onPressed});
@override
TextButton createAndroidWidget(BuildContext context) =>
TextButton(onPressed: onPressed, child: Text(text));
@override
CupertinoButton createIosWidget(BuildContext context) =>
CupertinoButton(onPressed: onPressed, child: Text(text));
}

View file

@ -1,30 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:opencanteen/pw/platformwidget.dart';
class PlatformDialog extends PlatformWidget<AlertDialog, CupertinoAlertDialog> {
final String title;
final String? content;
final List<Widget> actions;
const PlatformDialog(
{super.key, required this.title, this.content, this.actions = const []});
@override
AlertDialog createAndroidWidget(BuildContext context) => AlertDialog(
title: Text(title),
content: (content != null)
? SingleChildScrollView(child: Text(content!))
: null,
actions: actions,
);
@override
CupertinoAlertDialog createIosWidget(BuildContext context) =>
CupertinoAlertDialog(
title: Text(title),
content: (content != null)
? SingleChildScrollView(child: Text(content!))
: null,
actions: actions,
);
}

View file

@ -1,54 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:opencanteen/pw/platformwidget.dart';
class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
final TextEditingController? controller;
final bool? enabled;
final bool obscureText;
final String? labelText;
final bool autocorrect;
final TextInputType? keyboardType;
final List<TextInputFormatter> inputFormatters;
final void Function(String)? onChanged;
final List<String>? autofillHints;
const PlatformField({
super.key,
this.controller,
this.enabled,
this.labelText,
this.obscureText = false,
this.autocorrect = false,
this.keyboardType,
this.inputFormatters = const [],
this.onChanged,
this.autofillHints,
});
@override
TextField createAndroidWidget(BuildContext context) => TextField(
controller: controller,
enabled: enabled,
obscureText: obscureText,
decoration: InputDecoration(labelText: labelText),
autocorrect: autocorrect,
keyboardType: keyboardType,
inputFormatters: inputFormatters,
onChanged: onChanged,
autofillHints: autofillHints,
);
@override
CupertinoTextField createIosWidget(BuildContext context) =>
CupertinoTextField(
controller: controller,
enabled: enabled,
obscureText: obscureText,
prefix: (labelText == null) ? null : Text(labelText!),
autocorrect: autocorrect,
keyboardType: keyboardType,
inputFormatters: inputFormatters,
onChanged: onChanged,
);
}

View file

@ -1,28 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:opencanteen/pw/platformwidget.dart';
class PlatformSwitch extends PlatformWidget<Switch, CupertinoSwitch> {
final bool value;
final void Function(bool)? onChanged;
final Color? thumbColor;
const PlatformSwitch(
{super.key,
required this.value,
required this.onChanged,
this.thumbColor});
@override
Switch createAndroidWidget(BuildContext context) => Switch(
value: value,
onChanged: onChanged,
thumbColor: MaterialStateProperty.all(thumbColor),
);
@override
CupertinoSwitch createIosWidget(BuildContext context) => CupertinoSwitch(
value: value,
onChanged: onChanged,
thumbColor: thumbColor,
);
}

View file

@ -1,22 +0,0 @@
import 'dart:io';
import 'package:flutter/material.dart';
/// Abstract class used to create widgets for the respective platform UI library
abstract class PlatformWidget<A extends Widget, I extends Widget>
extends StatelessWidget {
const PlatformWidget({super.key});
@override
Widget build(BuildContext context) {
if (Platform.isAndroid) {
return createAndroidWidget(context);
} else {
return createIosWidget(context);
}
}
A createAndroidWidget(BuildContext context);
I createIosWidget(BuildContext context);
}

View file

@ -1,9 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:canteenlib/canteenlib.dart'; import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:opencanteen/okna/burza.dart'; import 'package:opencanteen/okna/burza.dart';
import 'package:opencanteen/okna/jidelnicek.dart'; import 'package:opencanteen/okna/jidelnicek.dart';
import 'lang/lang.dart'; import 'lang/lang.dart';
@ -30,7 +28,8 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
title: Text(Languages.of(context)!.exchange), title: Text(Languages.of(context)!.exchange),
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
platformRouter((context) => BurzaView(canteen: canteen)), MaterialPageRoute(
builder: (context) => BurzaView(canteen: canteen)),
), ),
), ),
], ],
@ -50,7 +49,8 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
title: Text(Languages.of(context)!.home), title: Text(Languages.of(context)!.home),
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
platformRouter((c) => MealView(canteen: canteen)), MaterialPageRoute(
builder: (c) => JidelnicekView(canteen: canteen)),
), ),
), ),
ListTile( ListTile(
@ -66,60 +66,31 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
return drawer; return drawer;
} }
class OfflineMeal { class OfflineJidlo {
String name; String nazev;
String variant; String varianta;
bool ordered; bool objednano;
double price; double cena;
bool onExchange; bool naBurze;
DateTime day; DateTime den;
OfflineMeal( OfflineJidlo(
{required this.name, {required this.nazev,
required this.variant, required this.varianta,
required this.ordered, required this.objednano,
required this.price, required this.cena,
required this.onExchange, required this.naBurze,
required this.day}); required this.den});
} }
/// Parses [DateTime] from [TimeOfDay] /// Vytvoří [DateTime] z [TimeOfDay]
DateTime timeToDate(TimeOfDay c) { DateTime casNaDate(TimeOfDay c) {
var now = DateTime.now(); var now = DateTime.now();
return DateTime.parse( return DateTime.parse(
"${now.year}-${(now.month < 10 ? "0" : "") + now.month.toString()}-${(now.day < 10 ? "0" : "") + now.day.toString()} ${(c.hour < 10 ? "0" : "") + c.hour.toString()}:${(c.minute < 10 ? "0" : "") + c.minute.toString()}:00"); "${now.year}-${(now.month < 10 ? "0" : "") + now.month.toString()}-${(now.day < 10 ? "0" : "") + now.day.toString()} ${(c.hour < 10 ? "0" : "") + c.hour.toString()}:${(c.minute < 10 ? "0" : "") + c.minute.toString()}:00");
} }
/// List of instances to be used in the dropdown menu
List<Map<String, String>> instance = [ List<Map<String, String>> instance = [
{"name": "SŠTE Brno, Olomoucká", "url": "https://stravovani.sstebrno.cz"}, {"name": "SŠTE Brno, Olomoucká", "url": "https://stravovani.sstebrno.cz"},
{"name": "Jiné", "url": ""} {"name": "Jiné", "url": ""}
]; ];
/// Used to display either a toas or a snackbar
void showInfo(BuildContext context, String message) {
if (Platform.isAndroid) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
duration: const Duration(seconds: 4),
),
);
} else {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 3,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0,
);
}
}
Route platformRouter(Widget Function(BuildContext context) builder) =>
(Platform.isAndroid)
? MaterialPageRoute(builder: builder)
: CupertinoPageRoute(builder: builder);

View file

@ -5,120 +5,105 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: archive name: archive
sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.6" version: "3.3.4"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.2" version: "2.3.1"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.10.0"
canteenlib: canteenlib:
dependency: "direct main" dependency: "direct main"
description: description:
name: canteenlib name: canteenlib
sha256: c15aa1d11fb9d6d01d633b8cbb6780d3e63c9058f8cc3b0f7de2fbc21cf4903d url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
name: checked_yaml name: checked_yaml
sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.2" version: "2.0.1"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
name: cli_util name: cli_util
sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.5" version: "0.3.5"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.16.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
name: convert name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
name: crypto name: crypto
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.2"
dbus: dbus:
dependency: transitive dependency: transitive
description: description:
name: dbus name: dbus
sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.8" version: "0.7.8"
dots_indicator: dots_indicator:
dependency: transitive dependency: transitive
description: description:
name: dots_indicator name: dots_indicator
sha256: e59dfc90030ee5a4fd4c53144a8ce97cc7a823c2067b8fb9814960cd1ae63f89 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
name: ffi name: ffi
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
file: file:
dependency: transitive dependency: transitive
description: description:
name: file name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.4" version: "6.1.4"
flutter: flutter:
@ -130,40 +115,35 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_launcher_icons name: flutter_launcher_icons
sha256: ce0e501cfc258907842238e4ca605e74b7fd1cdf04b3b43e86c43f3e40a1592c url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.11.0" version: "0.11.0"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
flutter_local_notifications: flutter_local_notifications:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_local_notifications name: flutter_local_notifications
sha256: f222919a34545931e47b06000836b5101baeffb0e6eb5a4691d2d42851740dd9 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "12.0.4" version: "12.0.3+1"
flutter_local_notifications_linux: flutter_local_notifications_linux:
dependency: transitive dependency: transitive
description: description:
name: flutter_local_notifications_linux name: flutter_local_notifications_linux
sha256: "3c6d6db334f609a92be0c0915f40871ec56f5d2adf01e77ae364162c587c0ca8" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
flutter_local_notifications_platform_interface: flutter_local_notifications_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: flutter_local_notifications_platform_interface name: flutter_local_notifications_platform_interface
sha256: "5ec1feac5f7f7d9266759488bc5f76416152baba9aa1b26fe572246caa00d1ab" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.0" version: "6.0.0"
flutter_localizations: flutter_localizations:
@ -175,351 +155,315 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_native_timezone name: flutter_native_timezone
sha256: ed7bfb982f036243de1c068e269182a877100c994f05143c8b26a325e28c1b02 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
flutter_secure_storage: flutter_secure_storage:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_secure_storage name: flutter_secure_storage
sha256: "1b7c2f80ee41861543bc63fee56122a114129c15234731312418ca1eda7d3d7f" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "5.0.2" version: "5.0.2"
flutter_secure_storage_linux: flutter_secure_storage_linux:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_linux name: flutter_secure_storage_linux
sha256: "736436adaf91552433823f51ce22e098c2f0551db06b6596f58597a25b8ea797" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.1"
flutter_secure_storage_macos: flutter_secure_storage_macos:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_macos name: flutter_secure_storage_macos
sha256: "388f76fd0f093e7415a39ec4c169ae7cceeee6d9f9ba529d788a13f2be4de7bd" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.1"
flutter_secure_storage_platform_interface: flutter_secure_storage_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_platform_interface name: flutter_secure_storage_platform_interface
sha256: b3773190e385a3c8a382007893d678ae95462b3c2279e987b55d140d3b0cb81b url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.1" version: "1.0.0"
flutter_secure_storage_web: flutter_secure_storage_web:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_web name: flutter_secure_storage_web
sha256: "42938e70d4b872e856e678c423cc0e9065d7d294f45bc41fc1981a4eb4beaffe" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.0.2"
flutter_secure_storage_windows: flutter_secure_storage_windows:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_windows name: flutter_secure_storage_windows
sha256: ca89c8059cf439985aa83c59619b3674c7ef6cc2e86943d169a7369d6a69cab5 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.3" version: "1.1.2"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
sha256: "7cc92eabe01e3f1babe1571c5560b135dfc762a34e41e9056881e2196b178ec1"
url: "https://pub.dev"
source: hosted
version: "8.1.2"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.5" version: "0.13.5"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.2" version: "4.0.2"
image: image:
dependency: transitive dependency: transitive
description: description:
name: image name: image
sha256: "8e9d133755c3e84c73288363e6343157c383a0c6c56fc51afcc5d4d7180306d6" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.0" version: "3.2.2"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.17.0" version: "0.17.0"
introduction_screen: introduction_screen:
dependency: "direct main" dependency: "direct main"
description: description:
name: introduction_screen name: introduction_screen
sha256: "73965475d6b271846f81c5fce5b459546a4ea36c285408691522437fd6bbeb69" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.4" version: "3.0.2"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.5" version: "0.6.4"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
name: json_annotation name: json_annotation
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "4.8.0" version: "4.7.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.1.5"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
package_info_plus: package_info_plus:
dependency: "direct main" dependency: "direct main"
description: description:
name: package_info_plus name: package_info_plus
sha256: f62d7253edc197fe3c88d7c2ddab82d68f555e778d55390ccc3537eca8e8d637 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.3+1" version: "1.4.3+1"
package_info_plus_linux: package_info_plus_linux:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_linux name: package_info_plus_linux
sha256: "04b575f44233d30edbb80a94e57cad9107aada334fc02aabb42b6becd13c43fc" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.5" version: "1.0.5"
package_info_plus_macos: package_info_plus_macos:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_macos name: package_info_plus_macos
sha256: a2ad8b4acf4cd479d4a0afa5a74ea3f5b1c7563b77e52cc32b3ee6956d5482a6 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
package_info_plus_platform_interface: package_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_platform_interface name: package_info_plus_platform_interface
sha256: f7a0c8f1e7e981bc65f8b64137a53fd3c195b18d429fba960babc59a5a1c7ae8 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
package_info_plus_web: package_info_plus_web:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_web name: package_info_plus_web
sha256: f0829327eb534789e0a16ccac8936a80beed4e2401c4d3a74f3f39094a822d3b url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.6" version: "1.0.6"
package_info_plus_windows: package_info_plus_windows:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_windows name: package_info_plus_windows
sha256: "79524f11c42dd9078b96d797b3cf79c0a2883a50c4920dc43da8562c115089bc" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.2"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
name: path_provider name: path_provider
sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.12" version: "2.0.11"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.22" version: "2.0.21"
path_provider_foundation: path_provider_ios:
dependency: transitive dependency: transitive
description: description:
name: path_provider_foundation name: path_provider_ios
sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.0.11"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
name: path_provider_linux name: path_provider_linux
sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.7" version: "2.1.7"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.5" version: "2.0.5"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
petitparser: petitparser:
dependency: transitive dependency: transitive
description: description:
name: petitparser name: petitparser
sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "5.1.0" version: "5.1.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
name: platform name: platform
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
pointycastle: pointycastle:
dependency: transitive dependency: transitive
description: description:
name: pointycastle name: pointycastle
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.6.2" version: "3.6.2"
process: process:
dependency: transitive dependency: transitive
description: description:
name: process name: process
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
name: shared_preferences name: shared_preferences
sha256: "5949029e70abe87f75cfe59d17bf5c397619c4b74a099b10116baeb34786fad9" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.17" version: "2.0.15"
shared_preferences_android: shared_preferences_android:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
sha256: "955e9736a12ba776bdd261cf030232b30eadfcd9c79b32a3250dd4a494e8c8f7" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.15" version: "2.0.14"
shared_preferences_foundation: shared_preferences_ios:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_foundation name: shared_preferences_ios
sha256: "1ffa239043ab8baf881ec3094a3c767af9d10399b2839020b9e4d44c0bb23951" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.2" version: "2.1.1"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_linux name: shared_preferences_linux
sha256: f8ea038aa6da37090093974ebdcf4397010605fd2ff65c37a66f9d28394cb874 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.3" version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_platform_interface: shared_preferences_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_platform_interface name: shared_preferences_platform_interface
sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
shared_preferences_web: shared_preferences_web:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_web name: shared_preferences_web
sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.4" version: "2.0.4"
shared_preferences_windows: shared_preferences_windows:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_windows name: shared_preferences_windows
sha256: "5eaf05ae77658d3521d0e993ede1af962d4b326cd2153d312df716dc250f00c9" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.3" version: "2.1.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -529,146 +473,128 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.9.1"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
timezone: timezone:
dependency: "direct main" dependency: "direct main"
description: description:
name: timezone name: timezone
sha256: "24c8fcdd49a805d95777a39064862133ff816ebfffe0ceff110fb5960e557964" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.1" version: "0.9.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
url_launcher: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
name: url_launcher name: url_launcher
sha256: "698fa0b4392effdc73e9e184403b627362eb5fbf904483ac9defbb1c2191d809" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.8" version: "6.1.6"
url_launcher_android: url_launcher_android:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
sha256: "3e2f6dfd2c7d9cd123296cab8ef66cfc2c1a13f5845f42c7a0f365690a8a7dd1" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.23" version: "6.0.21"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_ios name: url_launcher_ios
sha256: bb328b24d3bccc20bdf1024a0990ac4f869d57663660de9c936fb8c043edefe3 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.18" version: "6.0.17"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_linux name: url_launcher_linux
sha256: "318c42cba924e18180c029be69caf0a1a710191b9ec49bb42b5998fdcccee3cc" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.1"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
sha256: "41988b55570df53b3dd2a7fc90c76756a963de6a8c5f8e113330cb35992e2094" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.1"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_platform_interface name: url_launcher_platform_interface
sha256: "4eae912628763eb48fc214522e58e942fd16ce195407dbf45638239523c759a6" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
url_launcher_web: url_launcher_web:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_web name: url_launcher_web
sha256: "44d79408ce9f07052095ef1f9a693c258d6373dc3944249374e30eff7219ccb0" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.14" version: "2.0.13"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_windows name: url_launcher_windows
sha256: b6217370f8eb1fd85c8890c539f5a639a01ab209a36db82c921ebeacefc7a615 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.1"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.1.2"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.3" version: "3.1.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0+3" version: "0.2.0+2"
xml: xml:
dependency: transitive dependency: transitive
description: description:
name: xml name: xml
sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.2.2" version: "6.1.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
name: yaml name: yaml
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" url: "https://pub.dartlang.org"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.18.2 <4.0.0" dart: ">=2.18.0 <3.0.0"
flutter: ">=3.0.0" flutter: ">=3.0.0"

View file

@ -6,10 +6,10 @@ 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.7.0+27 version: 1.6.1+26
environment: environment:
sdk: ">=2.18.2 <3.0.0" sdk: ">=2.16.1 <3.0.0"
dependencies: dependencies:
flutter: flutter:
@ -27,7 +27,6 @@ dependencies:
flutter_native_timezone: ^2.0.0 flutter_native_timezone: ^2.0.0
intl: ^0.17.0 intl: ^0.17.0
package_info_plus: ^1.4.3+1 package_info_plus: ^1.4.3+1
fluttertoast: ^8.1.2
dev_dependencies: dev_dependencies:
flutter_lints: ^2.0.1 flutter_lints: ^2.0.1