Compare commits

..

2 commits

Author SHA1 Message Date
Matyáš Caras
64b7f261a0 fix: přepsat Platform UI a zmenit RefreshIndicator 2023-01-28 14:30:54 +01:00
Matyáš Caras
c8d1878a39 chore: update Flutter 2023-01-28 14:30:09 +01:00
20 changed files with 1316 additions and 1028 deletions

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

View file

@ -45,6 +45,8 @@ 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,4 +244,7 @@ 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,4 +242,7 @@ 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 {
// zkontrolovat secure storage pokud je něco uložené // check secure storage for details
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> zapamatovat() async { static Future<bool> rememberme() async {
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
return await storage.containsKey(key: "oc_pass"); return await storage.containsKey(key: "oc_pass");
} }

View file

@ -1,5 +1,6 @@
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';
@ -37,7 +38,8 @@ Copyright (C) 2022 Matyáš Caras a přispěvatelé
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
void oznamitPredem(SharedPreferences prefs, tz.Location l) async { /// Used to setup notifications about ordered food
void setupNotification(SharedPreferences prefs, tz.Location l) async {
String title; String title;
String locale = Intl.getCurrentLocale(); String locale = Intl.getCurrentLocale();
@ -50,24 +52,24 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
} }
/*if (prefs.getBool("offline") ?? false) { /*if (prefs.getBool("offline") ?? false) {
// TODO možnost brát z offline dat // TODO grab data from offline storage
} else {*/ } else {*/
// bere online // data from the web
var d = await LoginManager.getDetails(); // získat údaje var d = await LoginManager.getDetails(); // grab login
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.singleWhere( var jidlo = jidla.jidla
(element) => element.objednano); // získá objednané jídlo .singleWhere((element) => element.objednano); // grab ordered meal
var kdy = DateTime.parse(prefs.getString( var kdy = DateTime.parse(prefs.getString(
"oznameni_cas")!); // uložíme čas, kdy se odeslat oznámení "oznameni_cas")!); // save the time the notif should be sent
var cas = casNaDate( var cas = timeToDate(
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;
// data o oznámení // notif data
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',
@ -76,7 +78,7 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
styleInformation: BigTextStyleInformation(''), styleInformation: BigTextStyleInformation(''),
ticker: 'today meal'); ticker: 'today meal');
// naplánovat // plan through lib
await flutterLocalNotificationsPlugin.zonedSchedule( await flutterLocalNotificationsPlugin.zonedSchedule(
0, 0,
title, title,
@ -87,7 +89,7 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime); UILocalNotificationDateInterpretation.absoluteTime);
} on StateError catch (_) { } on StateError catch (_) {
// nenalezeno // no ordered meal found
} }
} }
// } // }
@ -102,10 +104,10 @@ void main() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("oznamit") ?? false) { if (prefs.getBool("oznamit") ?? false) {
oznamitPredem(prefs, l); setupNotification(prefs, l);
} }
// nastavit oznámení // notif library setup
const AndroidInitializationSettings initializationSettingsAndroid = const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('notif_icon'); AndroidInitializationSettings('notif_icon');
@ -115,7 +117,6 @@ 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());
} }
@ -124,7 +125,9 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return (Platform
.isAndroid) // run app based on current platform to make use of the platform's respective UI lib
? MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
localizationsDelegates: const [ localizationsDelegates: const [
AppLocalizationsDelegate(), AppLocalizationsDelegate(),
@ -140,6 +143,19 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.purple, 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,6 +1,8 @@
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';
@ -13,17 +15,24 @@ class BurzaView extends StatefulWidget {
} }
class _BurzaViewState extends State<BurzaView> { class _BurzaViewState extends State<BurzaView> {
List<Widget> obsah = []; List<Widget> content = [];
double kredit = 0.0; double balance = 0.0;
Future<void> nactiBurzu(BuildContext context) async {
obsah = [const CircularProgressIndicator()]; Future<void> loadExchange(BuildContext context) async {
widget.canteen.ziskejUzivatele().then((kr) { content = [const CircularProgressIndicator()];
kredit = kr.kredit; var uzivatel = await widget.canteen.ziskejUzivatele().catchError((o) {
widget.canteen.ziskatBurzu().then((burza) { if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, platformRouter((c) => const LoginPage()));
}
return Uzivatel(kredit: 0);
});
balance = uzivatel.kredit;
var burza = await widget.canteen.ziskatBurzu();
setState(() { setState(() {
obsah = []; content = [];
if (burza.isEmpty) { if (burza.isEmpty) {
obsah = [ content = [
Text( Text(
Languages.of(context)!.noExchange, Languages.of(context)!.noExchange,
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
@ -32,7 +41,7 @@ class _BurzaViewState extends State<BurzaView> {
]; ];
} else { } else {
for (var b in burza) { for (var b in burza) {
obsah.add( content.add(
Padding( Padding(
padding: const EdgeInsets.only(top: 15), padding: const EdgeInsets.only(top: 15),
child: Row( child: Row(
@ -46,19 +55,19 @@ class _BurzaViewState extends State<BurzaView> {
), ),
), ),
Text("${b.pocet}x"), Text("${b.pocet}x"),
TextButton( PlatformButton(
onPressed: () { onPressed: () {
widget.canteen.objednatZBurzy(b).then((a) { widget.canteen.objednatZBurzy(b).then(
(a) {
if (a) { if (a) {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => PlatformDialog(
title: Text(Languages.of(context)!.ordered), title: Languages.of(context)!.ordered,
content: Text( content: Languages.of(context)!.orderSuccess,
Languages.of(context)!.orderSuccess),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.ok), text: Languages.of(context)!.ok,
onPressed: () => onPressed: () =>
Navigator.of(context).pop(), Navigator.of(context).pop(),
) )
@ -68,14 +77,12 @@ class _BurzaViewState extends State<BurzaView> {
} else { } else {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => PlatformDialog(
title: Text( title: Languages.of(context)!.cannotOrder,
Languages.of(context)!.cannotOrder), content: Languages.of(context)!.errorOrdering,
content: Text(
Languages.of(context)!.errorOrdering),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.ok), text: Languages.of(context)!.ok,
onPressed: () => onPressed: () =>
Navigator.of(context).pop(), Navigator.of(context).pop(),
) )
@ -83,10 +90,12 @@ class _BurzaViewState extends State<BurzaView> {
), ),
); );
} }
nactiBurzu(context); loadExchange(context);
});
}, },
child: Text(Languages.of(context)!.order)), );
},
text: Languages.of(context)!.order,
),
], ],
), ),
), ),
@ -94,19 +103,13 @@ class _BurzaViewState extends State<BurzaView> {
} }
} }
}); });
}); return;
}).catchError((o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
nactiBurzu(context); loadExchange(context);
} }
@override @override
@ -123,20 +126,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}$kredit"), Text("${Languages.of(context)!.balance}$balance"),
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: obsah), child: Column(children: content),
), ),
) )
], ],
), ),
), ),
), ),
onRefresh: () => nactiBurzu(context)), onRefresh: () => loadExchange(context)),
); );
} }
} }

View file

@ -6,6 +6,8 @@ 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';
@ -14,25 +16,25 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
class JidelnicekView extends StatefulWidget { class MealView extends StatefulWidget {
const JidelnicekView({Key? key, required this.canteen}) : super(key: key); const MealView({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen; final Canteen canteen;
@override @override
State<JidelnicekView> createState() => _JidelnicekViewState(); State<MealView> createState() => _MealViewState();
} }
class _JidelnicekViewState extends State<JidelnicekView> { class _MealViewState extends State<MealView> {
List<Widget> obsah = [const CircularProgressIndicator()]; List<Widget> content = [const CircularProgressIndicator()];
DateTime den = DateTime.now(); DateTime day = DateTime.now();
String denTydne = ""; String dayOWeek = "";
double kredit = 0.0; double balance = 0.0;
bool _skipWeekend = false; bool _skipWeekend = false;
void kontrolaTyden(BuildContext context) async { void checkWeek(BuildContext context) async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("tyden") ?? false) { if (prefs.getBool("tyden") ?? false) {
// Zjistit jestli je objednáno na přístí týden // Check if user has ordered a meal in the next week
var pristi = den.add(const Duration(days: 6)); var pristi = day.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)));
@ -47,8 +49,8 @@ class _JidelnicekViewState extends State<JidelnicekView> {
action: SnackBarAction( action: SnackBarAction(
onPressed: () => setState( onPressed: () => setState(
() { () {
den = pristi.add(Duration(days: i + 1)); day = pristi.add(Duration(days: i + 1));
nactiJidlo(); loadMeals();
}, },
), ),
label: Languages.of(context)!.jump, label: Languages.of(context)!.jump,
@ -61,43 +63,55 @@ class _JidelnicekViewState extends State<JidelnicekView> {
} }
} }
Future<void> nactiJidlo() async { Future<void> loadMeals() async {
obsah = [const CircularProgressIndicator()]; content = [const CircularProgressIndicator()];
switch (den.weekday) { switch (day.weekday) {
case 2: case 2:
denTydne = Languages.of(context)!.tuesday; dayOWeek = Languages.of(context)!.tuesday;
break; break;
case 3: case 3:
denTydne = Languages.of(context)!.wednesday; dayOWeek = Languages.of(context)!.wednesday;
break; break;
case 4: case 4:
denTydne = Languages.of(context)!.thursday; dayOWeek = Languages.of(context)!.thursday;
break; break;
case 5: case 5:
denTydne = Languages.of(context)!.friday; dayOWeek = Languages.of(context)!.friday;
break; break;
case 6: case 6:
denTydne = Languages.of(context)!.saturday; dayOWeek = Languages.of(context)!.saturday;
break; break;
case 7: case 7:
denTydne = Languages.of(context)!.sunday; dayOWeek = Languages.of(context)!.sunday;
break; break;
default: default:
denTydne = Languages.of(context)!.monday; dayOWeek = Languages.of(context)!.monday;
} }
widget.canteen.ziskejUzivatele().then((kr) { var uzivatel = await widget.canteen.ziskejUzivatele().catchError(
kredit = kr.kredit; (o) {
widget.canteen.jidelnicekDen(den: den).then((jd) async { if (!widget.canteen.prihlasen) {
setState(() { Navigator.pushReplacement(
obsah = []; context, platformRouter((c) => const LoginPage()));
}
return Uzivatel(kredit: 0);
},
);
balance = uzivatel.kredit;
var jd = await widget.canteen.jidelnicekDen(den: day).catchError((_) {
showInfo(context, Languages.of(context)!.errorContacting);
return Jidelnicek(DateTime.now(), []);
});
setState(
() {
content = [];
if (jd.jidla.isEmpty) { if (jd.jidla.isEmpty) {
obsah.add(Text( content.add(Text(
Languages.of(context)!.noFood, Languages.of(context)!.noFood,
style: const TextStyle(fontSize: 15), style: const TextStyle(fontSize: 15),
)); ));
} else { } else {
for (var j in jd.jidla) { for (var j in jd.jidla) {
obsah.add( content.add(
Padding( Padding(
padding: const EdgeInsets.only(top: 15), padding: const EdgeInsets.only(top: 15),
child: InkWell( child: InkWell(
@ -124,22 +138,20 @@ class _JidelnicekViewState extends State<JidelnicekView> {
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(
Languages.of(context)!.cannotOrder),
actions: [ actions: [
TextButton( PlatformButton(
child: text: Languages.of(context)!.ok,
Text(Languages.of(context)!.ok),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
) )
], ],
); );
}); },
);
} else { } else {
showDialog( showDialog(
context: context, context: context,
@ -147,44 +159,45 @@ class _JidelnicekViewState extends State<JidelnicekView> {
builder: (_) => Dialog( builder: (_) => Dialog(
child: SizedBox( child: SizedBox(
height: 100, height: 100,
child: Row(children: [ child: Row(
children: [
const Padding( const Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: child: CircularProgressIndicator(),
CircularProgressIndicator(),
), ),
Text(Languages.of(context)! Text(Languages.of(context)!.ordering)
.ordering) ],
]),
), ),
)); ),
),
);
widget.canteen.objednat(j).then((_) { widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true) Navigator.of(context, rootNavigator: true).pop();
.pop(); loadMeals();
nactiJidlo(); }).catchError(
}).catchError((o) { (o) {
Navigator.of(context, rootNavigator: true) Navigator.of(context, rootNavigator: true)
.pop(); .pop();
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (bc) => PlatformDialog(
title: Text(Languages.of(context)! title: Languages.of(context)!.errorOrdering,
.errorOrdering), content: o.toString(),
content: Text(o.toString()),
actions: [ actions: [
TextButton( PlatformButton(
child: Text( text: Languages.of(context)!.close,
Languages.of(context)!
.close),
onPressed: () { onPressed: () {
Navigator.pop(bc); Navigator.pop(bc);
}, },
) )
], ],
)); ),
}); );
},
);
} }
}) },
)
], ],
), ),
onTap: () async { onTap: () async {
@ -192,21 +205,20 @@ class _JidelnicekViewState extends State<JidelnicekView> {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return PlatformDialog(
title: title: Languages.of(context)!.errorOrdering,
Text(Languages.of(context)!.errorOrdering), content: Languages.of(context)!.cannotOrder,
content:
Text(Languages.of(context)!.cannotOrder),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.ok), text: Languages.of(context)!.ok,
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
) )
], ],
); );
}); },
);
} else { } else {
showDialog( showDialog(
context: context, context: context,
@ -222,22 +234,22 @@ class _JidelnicekViewState extends State<JidelnicekView> {
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(); Navigator.of(context, rootNavigator: true).pop();
nactiJidlo(); loadMeals();
}).catchError( }).catchError(
(o) { (o) {
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (bc) => PlatformDialog(
title: title: Languages.of(context)!.errorOrdering,
Text(Languages.of(context)!.errorOrdering), content: o.toString(),
content: Text(o.toString()),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.close), text: Languages.of(context)!.close,
onPressed: () { onPressed: () {
Navigator.pop(bc); Navigator.pop(bc);
}, },
@ -252,42 +264,40 @@ class _JidelnicekViewState extends State<JidelnicekView> {
onLongPress: () async { onLongPress: () async {
if (!j.objednano || j.burzaUrl == null) return; if (!j.objednano || j.burzaUrl == null) return;
if (!j.naBurze) { if (!j.naBurze) {
// pokud není na burze, radši se zeptáme // if not in exchange, we ask
var d = await showDialog( var d = await showDialog(
context: context, context: context,
builder: (bc) => SimpleDialog( builder: (bc) => PlatformDialog(
title: Text( title: Languages.of(context)!.verifyExchange,
Languages.of(context)!.verifyExchange), actions: [
children: [ PlatformButton(
SimpleDialogOption(
onPressed: () { onPressed: () {
Navigator.pop(bc, true); Navigator.pop(bc, true);
}, },
child: Text(Languages.of(context)!.yes), text: Languages.of(context)!.yes,
), ),
SimpleDialogOption( PlatformButton(
onPressed: () { onPressed: () {
Navigator.pop(bc, false); Navigator.pop(bc, false);
}, },
child: Text(Languages.of(context)!.no), text: Languages.of(context)!.no,
), ),
], ],
)); ),
);
if (d) { if (d) {
widget.canteen widget.canteen
.doBurzy(j) .doBurzy(j)
.then((_) => nactiJidlo()) .then((_) => loadMeals())
.catchError((o) { .catchError((o) {
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (bc) => PlatformDialog(
title: title: Languages.of(context)!.exchangeError,
Text(Languages.of(context)!.exchangeError), content: o.toString(),
content: SingleChildScrollView(
child: Text(o.toString())),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.close), text: Languages.of(context)!.close,
onPressed: () { onPressed: () {
Navigator.pop(bc); Navigator.pop(bc);
}, },
@ -298,8 +308,8 @@ class _JidelnicekViewState extends State<JidelnicekView> {
}); });
} }
} else { } else {
// jinak ne // else no
widget.canteen.doBurzy(j).then((_) => nactiJidlo()); widget.canteen.doBurzy(j).then((_) => loadMeals());
} }
}, },
), ),
@ -307,42 +317,41 @@ class _JidelnicekViewState extends State<JidelnicekView> {
); );
} }
} }
}); },
}); );
}).catchError((o) { return;
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
} }
Future<void> kliknuti(String value, BuildContext context) async { Future<void> click(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) => AlertDialog( builder: (c) => PlatformDialog(
title: Text(Languages.of(context)!.warning), title: Languages.of(context)!.warning,
content: Text(Languages.of(context)!.signOutWarn), content: Languages.of(context)!.signOutWarn,
actions: [ actions: [
TextButton( PlatformButton(
onPressed: () { onPressed: () {
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
storage.deleteAll(); storage.deleteAll();
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute(builder: (c) => const LoginPage()), platformRouter((c) => const LoginPage()),
(route) => false); (route) => false);
}, },
child: Text(Languages.of(context)!.yes)), text: Languages.of(context)!.yes),
TextButton( PlatformButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
child: Text(Languages.of(context)!.no)) text: Languages.of(context)!.no,
)
], ],
), ),
); );
} else if (value == Languages.of(context)!.review) { } else if (value == Languages.of(context)!.review) {
launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"), launchUrl(
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"),
@ -357,28 +366,29 @@ class _JidelnicekViewState extends State<JidelnicekView> {
"${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: [
TextButton( PlatformButton(
onPressed: (() => launchUrl( onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))), Uri.parse("https://git.mnau.xyz/hernik/opencanteen"),
child: Text(Languages.of(context)!.source)) mode: LaunchMode.externalApplication)),
text: Languages.of(context)!.source,
)
]); ]);
} else if (value == Languages.of(context)!.settings) { } else if (value == Languages.of(context)!.settings) {
Navigator.push( Navigator.push(context, platformRouter((c) => const AndroidNastaveni()));
context, MaterialPageRoute(builder: (c) => const AndroidNastaveni()));
} }
} }
void nactiNastaveni() async { void loadSettings() 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;
kontrolaTyden(context); checkWeek(context);
} }
void ulozitDoOffline() async { void saveOffline() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("offline") ?? false) { if (prefs.getBool("offline") ?? false) {
// vyčistit offline // clear offline storage
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")) {
@ -386,11 +396,11 @@ class _JidelnicekViewState extends State<JidelnicekView> {
} }
} }
// uložit *pocet* jídelníčků pro offline použití // save X meal lists
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 = den.add(Duration(days: i)); var d = day.add(Duration(days: i));
Jidelnicek? j; Jidelnicek? j;
try { try {
j = await widget.canteen.jidelnicekDen(den: d); j = await widget.canteen.jidelnicekDen(den: d);
@ -427,9 +437,9 @@ class _JidelnicekViewState extends State<JidelnicekView> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
nactiNastaveni(); loadSettings();
ulozitDoOffline(); saveOffline();
nactiJidlo(); loadMeals();
} }
@override @override
@ -440,7 +450,7 @@ class _JidelnicekViewState extends State<JidelnicekView> {
title: Text(Languages.of(context)!.menu), title: Text(Languages.of(context)!.menu),
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
onSelected: ((String value) => kliknuti(value, context)), onSelected: ((String value) => click(value, context)),
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return { return {
Languages.of(context)!.reportBugs, Languages.of(context)!.reportBugs,
@ -459,62 +469,71 @@ class _JidelnicekViewState extends State<JidelnicekView> {
], ],
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: nactiJidlo, onRefresh: loadMeals,
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}$kredit"), Text("${Languages.of(context)!.balance}$balance"),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton( IconButton(
onPressed: () { onPressed: () {
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();
}); });
}, },
icon: const Icon(Icons.arrow_left)), icon: const Icon(Icons.arrow_left)),
TextButton( PlatformButton(
onPressed: () async { onPressed: () async {
var datePicked = await showDatePicker( var datePicked = await showDatePicker(
context: context, context: context,
initialDate: den, initialDate: day,
currentDate: den, currentDate: day,
firstDate: DateTime(2019, 1, 1), firstDate: DateTime(2019, 1, 1),
lastDate: DateTime(den.year + 1, 12, 31), lastDate: DateTime(day.year + 1, 12, 31),
locale: Localizations.localeOf(context)); locale: Localizations.localeOf(context));
if (datePicked == null) return; if (datePicked == null) return;
setState(() { setState(() {
den = datePicked; day = datePicked;
nactiJidlo(); loadMeals();
}); });
}, },
child: Text( text: "${day.day}. ${day.month}. ${day.year} - $dayOWeek",
"${den.day}. ${den.month}. ${den.year} - $denTydne")), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
den = den.add(const Duration(days: 1)); day = day.add(const Duration(days: 1));
if (den.weekday == 6 && _skipWeekend) { if (day.weekday == 6 && _skipWeekend) {
den = den.add(const Duration(days: 2)); day = day.add(const Duration(days: 2));
} }
nactiJidlo(); loadMeals();
}); });
}, },
icon: const Icon(Icons.arrow_right), icon: const Icon(Icons.arrow_right),
), ),
IconButton( Tooltip(
onPressed: () => setState(() { message: Languages.of(context)!.todayTooltip,
den = DateTime.now(); child: IconButton(
nactiJidlo(); onPressed: () => setState(
}), () {
icon: const Icon(Icons.today)) day = DateTime.now();
]), loadMeals();
},
),
icon: const Icon(Icons.today),
),
)
],
),
SingleChildScrollView( SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: GestureDetector( child: GestureDetector(
@ -524,25 +543,27 @@ class _JidelnicekViewState extends State<JidelnicekView> {
.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: obsah), child: Column(children: content),
), ),
onHorizontalDragEnd: (details) { onHorizontalDragEnd: (details) {
if (details.primaryVelocity?.compareTo(0) == -1) { if (details.primaryVelocity?.compareTo(0) == -1) {
setState(() { setState(() {
den = den.add(const Duration(days: 1)); day = day.add(const Duration(days: 1));
if (den.weekday == 6 && _skipWeekend) { if (day.weekday == 6 && _skipWeekend) {
den = den.add(const Duration(days: 2)); day = day.add(const Duration(days: 2));
} }
nactiJidlo(); loadMeals();
}); });
} else { } else {
setState(() { setState(
den = den.subtract(const Duration(days: 1)); () {
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();
}); },
);
} }
}, },
), ),

View file

@ -1,16 +1,17 @@
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';
@ -32,14 +33,14 @@ class _LoginPageState extends State<LoginPage> {
void initState() { void initState() {
super.initState(); super.initState();
LoginManager.getDetails().then((r) async { LoginManager.getDetails().then((r) async {
// žádat o oprávnění na android // request android notification access
flutterLocalNotificationsPlugin flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>() AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission(); ?.requestPermission();
if (r != null) { if (r != null) {
// Automaticky přihlásit // Autologin
showDialog( showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
@ -74,36 +75,26 @@ class _LoginPageState extends State<LoginPage> {
if (odsouhlasil == null || odsouhlasil != "ano") { if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( platformRouter(
builder: (c) => WelcomePage(canteen: canteen), (c) => WelcomePage(canteen: canteen),
), ),
(route) => false); (route) => false);
} else { } else {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( platformRouter(
builder: (context) => JidelnicekView(canteen: canteen), (context) => MealView(canteen: canteen),
), ),
(route) => false); (route) => false);
} }
} on PlatformException { } on PlatformException {
if (!mounted) return; if (!mounted) return;
Navigator.of(context).pop(); Navigator.of(context).pop();
ScaffoldMessenger.of(context).hideCurrentSnackBar(); showInfo(context, Languages.of(context)!.corrupted);
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();
ScaffoldMessenger.of(context).hideCurrentSnackBar(); showInfo(context, Languages.of(context)!.errorContacting);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.errorContacting),
),
);
goOffline(); goOffline();
} }
} }
@ -134,16 +125,14 @@ class _LoginPageState extends State<LoginPage> {
Languages.of(context)!.logIn, Languages.of(context)!.logIn,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
TextField( PlatformField(
controller: userControl, controller: userControl,
autofillHints: const [AutofillHints.username], autofillHints: const [AutofillHints.username],
decoration: InputDecoration( labelText: Languages.of(context)!.username,
labelText: Languages.of(context)!.username),
), ),
TextField( PlatformField(
autofillHints: const [AutofillHints.password], autofillHints: const [AutofillHints.password],
decoration: InputDecoration( labelText: Languages.of(context)!.password,
labelText: Languages.of(context)!.password),
controller: passControl, controller: passControl,
obscureText: true, obscureText: true,
), ),
@ -173,25 +162,25 @@ class _LoginPageState extends State<LoginPage> {
AnimatedOpacity( AnimatedOpacity(
opacity: _showUrl ? 1.0 : 0.0, opacity: _showUrl ? 1.0 : 0.0,
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
child: TextField( child: PlatformField(
autofillHints: const [AutofillHints.url], autofillHints: const [AutofillHints.url],
decoration: InputDecoration( labelText: Languages.of(context)!.iCanteenUrl,
labelText: Languages.of(context)!.iCanteenUrl),
keyboardType: TextInputType.url, keyboardType: TextInputType.url,
controller: canteenControl, controller: canteenControl,
), ),
), ),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Switch( PlatformSwitch(
value: rememberMe, value: rememberMe,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
rememberMe = value; rememberMe = value;
}); });
}), },
),
Text(Languages.of(context)!.rememberMe) Text(Languages.of(context)!.rememberMe)
]), ]),
TextButton( PlatformButton(
onPressed: () async { onPressed: () async {
var canteenUrl = (dropdownUrl == "") var canteenUrl = (dropdownUrl == "")
? canteenControl.text ? canteenControl.text
@ -206,13 +195,7 @@ class _LoginPageState extends State<LoginPage> {
userControl.text, passControl.text); userControl.text, passControl.text);
if (!l) { if (!l) {
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar(); showInfo(context, Languages.of(context)!.loginFailed);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text(Languages.of(context)!.loginFailed),
),
);
return; return;
} }
if (rememberMe) { if (rememberMe) {
@ -221,61 +204,50 @@ class _LoginPageState extends State<LoginPage> {
} }
// souhlas // souhlas
const storage = FlutterSecureStorage(); const storage = FlutterSecureStorage();
var odsouhlasil = var odsouhlasil = await storage.read(key: "oc_souhlas");
await storage.read(key: "oc_souhlas");
if (!mounted) return; if (!mounted) return;
if (odsouhlasil == null || odsouhlasil != "ano") { if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( platformRouter(
builder: (c) => WelcomePage( (context) => WelcomePage(
canteen: canteen, canteen: canteen,
)), ),
),
(route) => false); (route) => false);
} else { } else {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( platformRouter(
builder: (context) => JidelnicekView( (context) => MealView(
canteen: canteen, canteen: canteen,
)), ),
),
(route) => false); (route) => false);
} }
} on PlatformException { } on PlatformException {
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar(); showInfo(context, Languages.of(context)!.corrupted);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.corrupted),
),
);
} on Exception catch (_) { } on Exception catch (_) {
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar(); showInfo(
ScaffoldMessenger.of(context).showSnackBar( context, Languages.of(context)!.errorContacting);
SnackBar( //goOffline();
content:
Text(Languages.of(context)!.errorContacting),
),
);
goOffline();
} }
}, },
child: Text(Languages.of(context)!.logIn)), text: Languages.of(context)!.logIn),
], ],
), ),
), ),
), ),
)); ),
);
} }
/// Získá offline soubor a zobrazí údaje /// Switch to offline view
void goOffline() async { void goOffline() async {
if (!mounted) return; if (!mounted) return;
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(context,
context, platformRouter((context) => const OfflineMealView()), (route) => false);
MaterialPageRoute(
builder: ((context) => const AndroidOfflineJidelnicek())),
(route) => false);
} }
} }

View file

@ -5,6 +5,10 @@ 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;
@ -22,45 +26,48 @@ class AndroidNastaveni extends StatefulWidget {
} }
class _AndroidNastaveniState extends State<AndroidNastaveni> { class _AndroidNastaveniState extends State<AndroidNastaveni> {
bool _ukladatOffline = false; bool _saveOffline = false;
bool _preskakovatVikend = false; bool _skipWeekend = false;
bool _kontrolovatTyden = false; bool _checkWeek = false;
bool _oznameniObed = false; bool _notifyMeal = false;
bool _zapamatovany = false; bool _remember = false;
TimeOfDay _oznameniCas = TimeOfDay.now(); TimeOfDay _notifTime = 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();
_zapamatovany = await LoginManager.zapamatovat(); _remember = await LoginManager.rememberme();
setState(() { setState(
_ukladatOffline = preferences!.getBool("offline") ?? false; () {
_preskakovatVikend = preferences!.getBool("skip") ?? false; _saveOffline = preferences!.getBool("offline") ?? false;
_kontrolovatTyden = preferences!.getBool("tyden") ?? false; _skipWeekend = preferences!.getBool("skip") ?? false;
_oznameniObed = preferences!.getBool("oznamit") ?? false; _checkWeek = preferences!.getBool("tyden") ?? 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 zmenitNastaveni(String key, bool value) async { void changeSetting(String key, bool value) async {
preferences!.setBool(key, value); preferences!.setBool(key, value);
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
najitNastaveni(); loadSettings();
} }
@override @override
@ -78,16 +85,16 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(Languages.of(context)!.saveOffline), Text(Languages.of(context)!.saveOffline),
Switch( PlatformSwitch(
value: _ukladatOffline, value: _saveOffline,
activeColor: Colors.purple,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_ukladatOffline = value; _saveOffline = value;
cistit(value); clear(value);
zmenitNastaveni("offline", value); changeSetting("offline", value);
}); });
}) },
)
], ],
), ),
Row( Row(
@ -96,9 +103,9 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
Text(Languages.of(context)!.saveCount), Text(Languages.of(context)!.saveCount),
SizedBox( SizedBox(
width: 35, width: 35,
child: TextField( child: PlatformField(
controller: _countController, controller: _countController,
enabled: _ukladatOffline, enabled: _saveOffline,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly], inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (c) { onChanged: (c) {
@ -115,123 +122,123 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(Languages.of(context)!.skipWeekend), Text(Languages.of(context)!.skipWeekend),
Switch( PlatformSwitch(
activeColor: Colors.purple, value: _skipWeekend,
value: _preskakovatVikend,
onChanged: (value) { onChanged: (value) {
setState(() { setState(
_preskakovatVikend = value; () {
zmenitNastaveni("skip", value); _skipWeekend = value;
}); changeSetting("skip", value);
}) },
);
},
)
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Flexible(child: Text(Languages.of(context)!.checkOrdered)), Flexible(child: Text(Languages.of(context)!.checkOrdered)),
Switch( PlatformSwitch(
activeColor: Colors.purple, value: _checkWeek,
value: _kontrolovatTyden,
onChanged: (value) { onChanged: (value) {
setState(() { setState(
_kontrolovatTyden = value; () {
zmenitNastaveni("tyden", value); _checkWeek = value;
}); changeSetting("tyden", value);
}) },
);
},
)
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Flexible(child: Text(Languages.of(context)!.notifyLunch)), Flexible(child: Text(Languages.of(context)!.notifyLunch)),
Switch( PlatformSwitch(
activeColor: Colors.purple, value: _notifyMeal,
value: _oznameniObed, thumbColor: (!_remember ? Colors.grey : null),
thumbColor: (!_zapamatovany
? MaterialStateProperty.all(Colors.grey)
: null),
onChanged: (value) { onChanged: (value) {
if (!_zapamatovany) { if (!_remember) {
showDialog( showDialog(
context: context, context: context,
builder: (bc) => AlertDialog( builder: (bc) => PlatformDialog(
title: Text(Languages.of(context)!.error), title: Languages.of(context)!.error,
content: content: Languages.of(context)!.needRemember,
Text(Languages.of(context)!.needRemember),
actions: [ actions: [
TextButton( PlatformButton(
child: Text(Languages.of(context)!.ok), text: Languages.of(context)!.ok,
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
) )
], ],
)); ),
);
} else { } else {
setState(() { setState(() {
_oznameniObed = value; _notifyMeal = value;
if (_oznameniObed) { if (_notifyMeal) {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => PlatformDialog(
title: title: Languages.of(context)!.warning,
Text(Languages.of(context)!.warning), content: Languages.of(context)!.notifyWarning,
content: Text(
Languages.of(context)!.notifyWarning),
actions: [ actions: [
TextButton( PlatformButton(
child: text: Languages.of(context)!.ok,
Text(Languages.of(context)!.ok),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
) )
], ],
)); ),
vytvoritOznameni(casNaDate(_oznameniCas)); );
createNotif(timeToDate(_notifTime));
} }
zmenitNastaveni("oznamit", value); changeSetting("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)
.toString()); // aktualizovat vybraný čas
var den = timeToDate(cas);
debugPrint(den.isAfter(DateTime.now()).toString()); debugPrint(den.isAfter(DateTime.now()).toString());
if (den.isAfter(DateTime.now())) { if (den.isAfter(DateTime.now())) {
// znovu vytvořit oznámení POUZE když je čas v budoucnosti // znovu vytvořit oznámení POUZE když je čas v budoucnosti
vytvoritOznameni(den); createNotif(den);
} }
} }
setState(() { setState(() {
_oznameniCas = cas ?? _oznameniCas; _notifTime = cas ?? _notifTime;
}); });
} }
}, },
child: Text( text:
"${(_oznameniCas.hour < 10 ? "0" : "") + _oznameniCas.hour.toString()}:${(_oznameniCas.minute < 10 ? "0" : "") + _oznameniCas.minute.toString()}", "${(_notifTime.hour < 10 ? "0" : "") + _notifTime.hour.toString()}:${(_notifTime.minute < 10 ? "0" : "") + _notifTime.minute.toString()}",
style: TextStyle(
color: (!_oznameniObed) ? Colors.grey : Colors.purple),
),
), ),
], ],
), ),
)), ),
),
); );
} }
void cistit(bool value) async { void clear(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()) {
@ -243,11 +250,10 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
} }
} }
void vytvoritOznameni(DateTime den) async { void createNotif(DateTime den) async {
await flutterLocalNotificationsPlugin.cancelAll(); await flutterLocalNotificationsPlugin.cancelAll();
var d = await LoginManager.getDetails(); // získat údaje var d = await LoginManager.getDetails(); // grab details
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();
@ -264,7 +270,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(
// Vytvoří nové oznámení pro daný čas a datum // schedules a notification
0, 0,
Languages.of(context)!.lunchNotif, Languages.of(context)!.lunchNotif,
"${jidlo.varianta} - ${jidlo.nazev}", "${jidlo.varianta} - ${jidlo.nazev}",
@ -274,7 +280,7 @@ class _AndroidNastaveniState extends State<AndroidNastaveni> {
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime); UILocalNotificationDateInterpretation.absoluteTime);
} on StateError catch (_) { } on StateError catch (_) {
// nenalezeno // no meal found
} }
} }
} }

View file

@ -4,6 +4,7 @@ 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';
@ -12,90 +13,90 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart'; import '../../lang/lang.dart';
class AndroidOfflineJidelnicek extends StatefulWidget { class OfflineMealView extends StatefulWidget {
const AndroidOfflineJidelnicek({Key? key}) : super(key: key); const OfflineMealView({Key? key}) : super(key: key);
@override @override
State<AndroidOfflineJidelnicek> createState() => State<OfflineMealView> createState() => _OfflineMealViewState();
_AndroidOfflineJidelnicekState();
} }
class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> { class _OfflineMealViewState extends State<OfflineMealView> {
List<Widget> obsah = [const CircularProgressIndicator()]; List<Widget> content = [const CircularProgressIndicator()]; // view content
var _skipWeekend = false; var _skipWeekend = false; // skip weekend setting
DateTime den = DateTime.now(); DateTime currentDay = DateTime.now(); // the day we are supposed to show
String denTydne = ""; String dayOWeek = ""; // the name of the day (to show to user)
List<List<OfflineJidlo>> data = []; List<List<OfflineMeal>> data = []; // meal data
var jidloIndex = 0; var mealIndex = 0; // index of the currently shown day
void nactiZeSouboru() async { /// Loads the offline data from local storage
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<OfflineJidlo> jidla = []; List<OfflineMeal> jidla = [];
for (var j in r) { for (var j in r) {
jidla.add(OfflineJidlo( jidla.add(OfflineMeal(
nazev: j["nazev"], name: j["nazev"],
varianta: j["varianta"], variant: j["varianta"],
objednano: j["objednano"], ordered: j["objednano"],
cena: j["cena"], price: j["cena"],
naBurze: j["naBurze"], onExchange: j["naBurze"],
den: DateTime.parse(j["den"]))); day: DateTime.parse(j["den"])));
} }
data.add(jidla); data.add(jidla);
} }
} }
nactiJidlo(); loadFood();
} }
Future<void> nactiJidlo() async { Future<void> loadFood() async {
var jidelnicek = data[jidloIndex]; var jidelnicek = data[mealIndex];
den = jidelnicek[0].den; currentDay = jidelnicek[0].day;
switch (den.weekday) { switch (currentDay.weekday) {
case 2: case 2:
denTydne = Languages.of(context)!.tuesday; dayOWeek = Languages.of(context)!.tuesday;
break; break;
case 3: case 3:
denTydne = Languages.of(context)!.wednesday; dayOWeek = Languages.of(context)!.wednesday;
break; break;
case 4: case 4:
denTydne = Languages.of(context)!.thursday; dayOWeek = Languages.of(context)!.thursday;
break; break;
case 5: case 5:
denTydne = Languages.of(context)!.friday; dayOWeek = Languages.of(context)!.friday;
break; break;
case 6: case 6:
denTydne = Languages.of(context)!.saturday; dayOWeek = Languages.of(context)!.saturday;
break; break;
case 7: case 7:
denTydne = Languages.of(context)!.sunday; dayOWeek = Languages.of(context)!.sunday;
break; break;
default: default:
denTydne = Languages.of(context)!.monday; dayOWeek = Languages.of(context)!.monday;
} }
obsah = []; content = [];
for (OfflineJidlo j in jidelnicek) { for (OfflineMeal j in jidelnicek) {
obsah.add( content.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.varianta), Text(j.variant),
const SizedBox(width: 10), const SizedBox(width: 10),
Flexible( Flexible(
child: Text( child: Text(
j.nazev, j.name,
), ),
), ),
Text((j.naBurze) Text((j.onExchange)
? Languages.of(context)!.inExchange ? Languages.of(context)!.inExchange
: "${j.cena}"), : "${j.price}"),
Checkbox( Checkbox(
value: j.objednano, value: j.ordered,
fillColor: MaterialStateProperty.all(Colors.grey), fillColor: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async { onChanged: (v) async {
return; return;
@ -110,14 +111,17 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
setState(() {}); setState(() {});
} }
void kliknuti(String value, BuildContext context) async { void click(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, MaterialPageRoute(builder: (c) => const LoginPage())); context, platformRouter((c) => const LoginPage()));
} else if (value == Languages.of(context)!.review) { } else if (value == Languages.of(context)!.review) {
launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"), launchUrl(
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"),
@ -132,25 +136,27 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
"${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: [
TextButton( PlatformButton(
onPressed: (() => launchUrl( onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))), Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
child: Text(Languages.of(context)!.source)) text: Languages.of(context)!.source,
]); )
],
);
} }
} }
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
nactiNastaveni(); loadSettings();
} }
void nactiNastaveni() async { void loadSettings() 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;
nactiZeSouboru(); loadFromFile();
} }
@override @override
@ -161,7 +167,7 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
onSelected: ((String value) => kliknuti(value, context)), onSelected: ((String value) => click(value, context)),
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return { return {
Languages.of(context)!.reportBugs, Languages.of(context)!.reportBugs,
@ -195,69 +201,69 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
IconButton( IconButton(
onPressed: () { onPressed: () {
if (data.length <= 1) return; if (data.length <= 1) return;
obsah = [const CircularProgressIndicator()]; content = [const CircularProgressIndicator()];
setState(() { setState(() {
if (den.weekday == 1 && _skipWeekend) { if (currentDay.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 (jidloIndex - 2 >= 0) { if (mealIndex - 2 >= 0) {
jidloIndex -= data.length - 3; mealIndex -= data.length - 3;
} else { } else {
jidloIndex = data.length - 1; mealIndex = data.length - 1;
} }
} else if (jidloIndex == 0) { } else if (mealIndex == 0) {
jidloIndex = data.length - 1; mealIndex = data.length - 1;
} else { } else {
jidloIndex -= 1; mealIndex -= 1;
} }
nactiJidlo(); loadFood();
}); });
}, },
icon: const Icon(Icons.arrow_left)), icon: const Icon(Icons.arrow_left)),
TextButton( PlatformButton(
onPressed: () async {}, onPressed: () async {},
child: Text( text:
"${den.day}. ${den.month}. ${den.year} - $denTydne")), "${currentDay.day}. ${currentDay.month}. ${currentDay.year} - $dayOWeek"),
IconButton( IconButton(
onPressed: () { onPressed: () {
if (data.length <= 1) return; if (data.length <= 1) return;
obsah = [const CircularProgressIndicator()]; content = [const CircularProgressIndicator()];
setState(() { setState(() {
if (den.weekday == 5 && _skipWeekend) { if (currentDay.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 (jidloIndex + 2 <= data.length - 1) { if (mealIndex + 2 <= data.length - 1) {
jidloIndex += 2; mealIndex += 2;
} else { } else {
jidloIndex = 0; mealIndex = 0;
} }
} else if (jidloIndex == data.length) { } else if (mealIndex == data.length) {
jidloIndex = 0; mealIndex = 0;
} else { } else {
jidloIndex += 1; mealIndex += 1;
} }
nactiJidlo(); loadFood();
}); });
}, },
icon: const Icon(Icons.arrow_right), icon: const Icon(Icons.arrow_right),
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
jidloIndex = 0; mealIndex = 0;
}, },
icon: const Icon(Icons.today)) icon: const Icon(Icons.today))
]), ]),
SingleChildScrollView( SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: Column( child: Column(
children: obsah, children: content,
), ),
), ),
], ],
), ),
), ),
), ),
onRefresh: () => Navigator.pushReplacement(context, onRefresh: () => Navigator.pushReplacement(
MaterialPageRoute(builder: ((context) => const LoginPage()))), context, platformRouter((context) => const LoginPage())),
), ),
); );
} }

View file

@ -4,6 +4,7 @@ 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);
@ -68,8 +69,7 @@ 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(
MaterialPageRoute( platformRouter((c) => MealView(canteen: widget.canteen)),
builder: (c) => JidelnicekView(canteen: widget.canteen)),
(route) => false); (route) => false);
}, },
), ),

View file

@ -0,0 +1,18 @@
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

@ -0,0 +1,30 @@
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,
);
}

54
lib/pw/platformfield.dart Normal file
View file

@ -0,0 +1,54 @@
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

@ -0,0 +1,28 @@
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

@ -0,0 +1,22 @@
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,7 +1,9 @@
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';
@ -28,8 +30,7 @@ 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,
MaterialPageRoute( platformRouter((context) => BurzaView(canteen: canteen)),
builder: (context) => BurzaView(canteen: canteen)),
), ),
), ),
], ],
@ -49,8 +50,7 @@ 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,
MaterialPageRoute( platformRouter((c) => MealView(canteen: canteen)),
builder: (c) => JidelnicekView(canteen: canteen)),
), ),
), ),
ListTile( ListTile(
@ -66,31 +66,60 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
return drawer; return drawer;
} }
class OfflineJidlo { class OfflineMeal {
String nazev; String name;
String varianta; String variant;
bool objednano; bool ordered;
double cena; double price;
bool naBurze; bool onExchange;
DateTime den; DateTime day;
OfflineJidlo( OfflineMeal(
{required this.nazev, {required this.name,
required this.varianta, required this.variant,
required this.objednano, required this.ordered,
required this.cena, required this.price,
required this.naBurze, required this.onExchange,
required this.den}); required this.day});
} }
/// Vytvoří [DateTime] z [TimeOfDay] /// Parses [DateTime] from [TimeOfDay]
DateTime casNaDate(TimeOfDay c) { DateTime timeToDate(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,105 +5,120 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: archive name: archive
url: "https://pub.dartlang.org" sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d
url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.4" version: "3.3.6"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.1" version: "2.3.2"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
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
url: "https://pub.dartlang.org" sha256: c15aa1d11fb9d6d01d633b8cbb6780d3e63c9058f8cc3b0f7de2fbc21cf4903d
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
url: "https://pub.dartlang.org" sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
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
url: "https://pub.dartlang.org" sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.2"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
name: cli_util name: cli_util
url: "https://pub.dartlang.org" sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c"
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
url: "https://pub.dartlang.org" sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
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
url: "https://pub.dartlang.org" sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.dev"
source: hosted source: hosted
version: "1.16.0" version: "1.17.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
name: convert name: convert
url: "https://pub.dartlang.org" sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
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
url: "https://pub.dartlang.org" sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
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
url: "https://pub.dartlang.org" sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
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
url: "https://pub.dartlang.org" sha256: e59dfc90030ee5a4fd4c53144a8ce97cc7a823c2067b8fb9814960cd1ae63f89
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
url: "https://pub.dartlang.org" sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
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
url: "https://pub.dartlang.org" sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.4" version: "6.1.4"
flutter: flutter:
@ -115,35 +130,40 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_launcher_icons name: flutter_launcher_icons
url: "https://pub.dartlang.org" sha256: ce0e501cfc258907842238e4ca605e74b7fd1cdf04b3b43e86c43f3e40a1592c
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
url: "https://pub.dartlang.org" sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
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
url: "https://pub.dartlang.org" sha256: f222919a34545931e47b06000836b5101baeffb0e6eb5a4691d2d42851740dd9
url: "https://pub.dev"
source: hosted source: hosted
version: "12.0.3+1" version: "12.0.4"
flutter_local_notifications_linux: flutter_local_notifications_linux:
dependency: transitive dependency: transitive
description: description:
name: flutter_local_notifications_linux name: flutter_local_notifications_linux
url: "https://pub.dartlang.org" sha256: "3c6d6db334f609a92be0c0915f40871ec56f5d2adf01e77ae364162c587c0ca8"
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
url: "https://pub.dartlang.org" sha256: "5ec1feac5f7f7d9266759488bc5f76416152baba9aa1b26fe572246caa00d1ab"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.0" version: "6.0.0"
flutter_localizations: flutter_localizations:
@ -155,315 +175,351 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_native_timezone name: flutter_native_timezone
url: "https://pub.dartlang.org" sha256: ed7bfb982f036243de1c068e269182a877100c994f05143c8b26a325e28c1b02
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
url: "https://pub.dartlang.org" sha256: "1b7c2f80ee41861543bc63fee56122a114129c15234731312418ca1eda7d3d7f"
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
url: "https://pub.dartlang.org" sha256: "736436adaf91552433823f51ce22e098c2f0551db06b6596f58597a25b8ea797"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.2"
flutter_secure_storage_macos: flutter_secure_storage_macos:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_macos name: flutter_secure_storage_macos
url: "https://pub.dartlang.org" sha256: "388f76fd0f093e7415a39ec4c169ae7cceeee6d9f9ba529d788a13f2be4de7bd"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.2"
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
url: "https://pub.dartlang.org" sha256: b3773190e385a3c8a382007893d678ae95462b3c2279e987b55d140d3b0cb81b
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.1"
flutter_secure_storage_web: flutter_secure_storage_web:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_web name: flutter_secure_storage_web
url: "https://pub.dartlang.org" sha256: "42938e70d4b872e856e678c423cc0e9065d7d294f45bc41fc1981a4eb4beaffe"
url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.2" version: "1.1.1"
flutter_secure_storage_windows: flutter_secure_storage_windows:
dependency: transitive dependency: transitive
description: description:
name: flutter_secure_storage_windows name: flutter_secure_storage_windows
url: "https://pub.dartlang.org" sha256: ca89c8059cf439985aa83c59619b3674c7ef6cc2e86943d169a7369d6a69cab5
url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
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
url: "https://pub.dartlang.org" sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
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
url: "https://pub.dartlang.org" sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
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
url: "https://pub.dartlang.org" sha256: "8e9d133755c3e84c73288363e6343157c383a0c6c56fc51afcc5d4d7180306d6"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.2.2" version: "3.3.0"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
url: "https://pub.dartlang.org" sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
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
url: "https://pub.dartlang.org" sha256: "73965475d6b271846f81c5fce5b459546a4ea36c285408691522437fd6bbeb69"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.1.4"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
url: "https://pub.dartlang.org" sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.4" version: "0.6.5"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
name: json_annotation name: json_annotation
url: "https://pub.dartlang.org" sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
url: "https://pub.dev"
source: hosted source: hosted
version: "4.7.0" version: "4.8.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://pub.dartlang.org" sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
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
url: "https://pub.dartlang.org" sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted source: hosted
version: "0.1.5" version: "0.2.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
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
url: "https://pub.dartlang.org" sha256: f62d7253edc197fe3c88d7c2ddab82d68f555e778d55390ccc3537eca8e8d637
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
url: "https://pub.dartlang.org" sha256: "04b575f44233d30edbb80a94e57cad9107aada334fc02aabb42b6becd13c43fc"
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
url: "https://pub.dartlang.org" sha256: a2ad8b4acf4cd479d4a0afa5a74ea3f5b1c7563b77e52cc32b3ee6956d5482a6
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
url: "https://pub.dartlang.org" sha256: f7a0c8f1e7e981bc65f8b64137a53fd3c195b18d429fba960babc59a5a1c7ae8
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
url: "https://pub.dartlang.org" sha256: f0829327eb534789e0a16ccac8936a80beed4e2401c4d3a74f3f39094a822d3b
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
url: "https://pub.dartlang.org" sha256: "79524f11c42dd9078b96d797b3cf79c0a2883a50c4920dc43da8562c115089bc"
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
url: "https://pub.dartlang.org" sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
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
url: "https://pub.dartlang.org" sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.11" version: "2.0.12"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
url: "https://pub.dartlang.org" sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.21" version: "2.0.22"
path_provider_ios: path_provider_foundation:
dependency: transitive dependency: transitive
description: description:
name: path_provider_ios name: path_provider_foundation
url: "https://pub.dartlang.org" sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.11" version: "2.1.1"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
name: path_provider_linux name: path_provider_linux
url: "https://pub.dartlang.org" sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379
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
url: "https://pub.dartlang.org" sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76
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
url: "https://pub.dartlang.org" sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c
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
url: "https://pub.dartlang.org" sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4"
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
url: "https://pub.dartlang.org" sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
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
url: "https://pub.dartlang.org" sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a
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
url: "https://pub.dartlang.org" sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
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
url: "https://pub.dartlang.org" sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
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
url: "https://pub.dartlang.org" sha256: "5949029e70abe87f75cfe59d17bf5c397619c4b74a099b10116baeb34786fad9"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.15" version: "2.0.17"
shared_preferences_android: shared_preferences_android:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
url: "https://pub.dartlang.org" sha256: "955e9736a12ba776bdd261cf030232b30eadfcd9c79b32a3250dd4a494e8c8f7"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.14" version: "2.0.15"
shared_preferences_ios: shared_preferences_foundation:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_ios name: shared_preferences_foundation
url: "https://pub.dartlang.org" sha256: "1ffa239043ab8baf881ec3094a3c767af9d10399b2839020b9e4d44c0bb23951"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_linux name: shared_preferences_linux
url: "https://pub.dartlang.org" sha256: f8ea038aa6da37090093974ebdcf4397010605fd2ff65c37a66f9d28394cb874
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.3"
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
url: "https://pub.dartlang.org" sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3
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
url: "https://pub.dartlang.org" sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958
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
url: "https://pub.dartlang.org" sha256: "5eaf05ae77658d3521d0e993ede1af962d4b326cd2153d312df716dc250f00c9"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -473,128 +529,146 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.dartlang.org" sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
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
url: "https://pub.dartlang.org" sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
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
url: "https://pub.dartlang.org" sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
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
url: "https://pub.dartlang.org" sha256: "24c8fcdd49a805d95777a39064862133ff816ebfffe0ceff110fb5960e557964"
url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.0" version: "0.9.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
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
url: "https://pub.dartlang.org" sha256: "698fa0b4392effdc73e9e184403b627362eb5fbf904483ac9defbb1c2191d809"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.6" version: "6.1.8"
url_launcher_android: url_launcher_android:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
url: "https://pub.dartlang.org" sha256: "3e2f6dfd2c7d9cd123296cab8ef66cfc2c1a13f5845f42c7a0f365690a8a7dd1"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.21" version: "6.0.23"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_ios name: url_launcher_ios
url: "https://pub.dartlang.org" sha256: bb328b24d3bccc20bdf1024a0990ac4f869d57663660de9c936fb8c043edefe3
url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.17" version: "6.0.18"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_linux name: url_launcher_linux
url: "https://pub.dartlang.org" sha256: "318c42cba924e18180c029be69caf0a1a710191b9ec49bb42b5998fdcccee3cc"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
url: "https://pub.dartlang.org" sha256: "41988b55570df53b3dd2a7fc90c76756a963de6a8c5f8e113330cb35992e2094"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_platform_interface name: url_launcher_platform_interface
url: "https://pub.dartlang.org" sha256: "4eae912628763eb48fc214522e58e942fd16ce195407dbf45638239523c759a6"
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
url: "https://pub.dartlang.org" sha256: "44d79408ce9f07052095ef1f9a693c258d6373dc3944249374e30eff7219ccb0"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.13" version: "2.0.14"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_windows name: url_launcher_windows
url: "https://pub.dartlang.org" sha256: b6217370f8eb1fd85c8890c539f5a639a01ab209a36db82c921ebeacefc7a615
url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.3"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.2" version: "2.1.4"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
url: "https://pub.dartlang.org" sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.3"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
url: "https://pub.dartlang.org" sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86
url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0+2" version: "0.2.0+3"
xml: xml:
dependency: transitive dependency: transitive
description: description:
name: xml name: xml
url: "https://pub.dartlang.org" sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5"
url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.0" version: "6.2.2"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
name: yaml name: yaml
url: "https://pub.dartlang.org" sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.18.0 <3.0.0" dart: ">=2.18.2 <4.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.6.1+26 version: 1.7.0+27
environment: environment:
sdk: ">=2.16.1 <3.0.0" sdk: ">=2.18.2 <3.0.0"
dependencies: dependencies:
flutter: flutter:
@ -27,6 +27,7 @@ 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