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
String get todayTooltip;
String get loading;
String get monday;

View file

@ -244,4 +244,7 @@ class LanguageCz extends Languages {
@override
String get errorSaving =>
"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
String get errorSaving =>
"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 {
static Future<Map<String, String>?> getDetails() async {
// zkontrolovat secure storage pokud je něco uložené
// check secure storage for details
const storage = FlutterSecureStorage();
var user = await storage.read(key: "oc_user");
var pass = await storage.read(key: "oc_pass");
@ -18,7 +18,7 @@ class LoginManager {
await storage.write(key: "oc_url", value: url);
}
static Future<bool> zapamatovat() async {
static Future<bool> rememberme() async {
const storage = FlutterSecureStorage();
return await storage.containsKey(key: "oc_pass");
}

View file

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@ -37,7 +38,8 @@ Copyright (C) 2022 Matyáš Caras a přispěvatelé
final 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 locale = Intl.getCurrentLocale();
@ -50,24 +52,24 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
}
/*if (prefs.getBool("offline") ?? false) {
// TODO možnost brát z offline dat
// TODO grab data from offline storage
} else {*/
// bere online
var d = await LoginManager.getDetails(); // získat údaje
// data from the web
var d = await LoginManager.getDetails(); // grab login
if (d != null) {
var c = Canteen(d["url"]!);
if (await c.login(d["user"]!, d["pass"]!)) {
var jidla = await c.jidelnicekDen();
try {
var jidlo = jidla.jidla.singleWhere(
(element) => element.objednano); // získá objednané jídlo
var jidlo = jidla.jidla
.singleWhere((element) => element.objednano); // grab ordered meal
var kdy = DateTime.parse(prefs.getString(
"oznameni_cas")!); // uložíme čas, kdy se odeslat oznámení
var cas = casNaDate(
"oznameni_cas")!); // save the time the notif should be sent
var cas = timeToDate(
TimeOfDay(hour: kdy.hour, minute: kdy.minute),
);
if (cas.isBefore(DateTime.now())) return;
// data o oznámení
// notif data
const AndroidNotificationDetails androidSpec =
AndroidNotificationDetails('predobedem', 'Oznámení před obědem',
channelDescription: 'Oznámení o dnešním jídle',
@ -76,7 +78,7 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
styleInformation: BigTextStyleInformation(''),
ticker: 'today meal');
// naplánovat
// plan through lib
await flutterLocalNotificationsPlugin.zonedSchedule(
0,
title,
@ -87,7 +89,7 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime);
} on StateError catch (_) {
// nenalezeno
// no ordered meal found
}
}
// }
@ -102,10 +104,10 @@ void main() async {
var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("oznamit") ?? false) {
oznamitPredem(prefs, l);
setupNotification(prefs, l);
}
// nastavit oznámení
// notif library setup
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('notif_icon');
@ -115,7 +117,6 @@ void main() async {
InitializationSettings(android: initializationSettingsAndroid, iOS: ios);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
// spustit aplikaci
runApp(const MyApp());
}
@ -124,23 +125,38 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: const [
AppLocalizationsDelegate(),
...GlobalMaterialLocalizations.delegates
],
supportedLocales: const [Locale("cs", ""), Locale("en", "")],
title: "OpenCanteen",
theme: ThemeData(
primarySwatch: Colors.purple,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.purple,
),
home: const LoginPage(),
);
return (Platform
.isAndroid) // run app based on current platform to make use of the platform's respective UI lib
? MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: const [
AppLocalizationsDelegate(),
...GlobalMaterialLocalizations.delegates
],
supportedLocales: const [Locale("cs", ""), Locale("en", "")],
title: "OpenCanteen",
theme: ThemeData(
primarySwatch: Colors.purple,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.purple,
),
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:flutter/material.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 '../../lang/lang.dart';
@ -13,100 +15,101 @@ class BurzaView extends StatefulWidget {
}
class _BurzaViewState extends State<BurzaView> {
List<Widget> obsah = [];
double kredit = 0.0;
Future<void> nactiBurzu(BuildContext context) async {
obsah = [const CircularProgressIndicator()];
widget.canteen.ziskejUzivatele().then((kr) {
kredit = kr.kredit;
widget.canteen.ziskatBurzu().then((burza) {
setState(() {
obsah = [];
if (burza.isEmpty) {
obsah = [
Text(
Languages.of(context)!.noExchange,
style: const TextStyle(fontSize: 20),
),
Text(Languages.of(context)!.pullToReload)
];
} else {
for (var b in burza) {
obsah.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${b.den.day}. ${b.den.month}."),
const SizedBox(width: 10),
Flexible(
child: Text(
b.nazev,
),
),
Text("${b.pocet}x"),
TextButton(
onPressed: () {
widget.canteen.objednatZBurzy(b).then((a) {
if (a) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(Languages.of(context)!.ordered),
content: Text(
Languages.of(context)!.orderSuccess),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
} else {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
Languages.of(context)!.cannotOrder),
content: Text(
Languages.of(context)!.errorOrdering),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
}
nactiBurzu(context);
});
},
child: Text(Languages.of(context)!.order)),
],
),
),
);
}
}
});
});
}).catchError((o) {
List<Widget> content = [];
double balance = 0.0;
Future<void> loadExchange(BuildContext context) async {
content = [const CircularProgressIndicator()];
var uzivatel = await widget.canteen.ziskejUzivatele().catchError((o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
context, platformRouter((c) => const LoginPage()));
}
return Uzivatel(kredit: 0);
});
balance = uzivatel.kredit;
var burza = await widget.canteen.ziskatBurzu();
setState(() {
content = [];
if (burza.isEmpty) {
content = [
Text(
Languages.of(context)!.noExchange,
style: const TextStyle(fontSize: 20),
),
Text(Languages.of(context)!.pullToReload)
];
} else {
for (var b in burza) {
content.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${b.den.day}. ${b.den.month}."),
const SizedBox(width: 10),
Flexible(
child: Text(
b.nazev,
),
),
Text("${b.pocet}x"),
PlatformButton(
onPressed: () {
widget.canteen.objednatZBurzy(b).then(
(a) {
if (a) {
showDialog(
context: context,
builder: (context) => PlatformDialog(
title: Languages.of(context)!.ordered,
content: Languages.of(context)!.orderSuccess,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
} else {
showDialog(
context: context,
builder: (context) => PlatformDialog(
title: Languages.of(context)!.cannotOrder,
content: Languages.of(context)!.errorOrdering,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () =>
Navigator.of(context).pop(),
)
],
),
);
}
loadExchange(context);
},
);
},
text: Languages.of(context)!.order,
),
],
),
),
);
}
}
});
return;
}
@override
void initState() {
super.initState();
nactiBurzu(context);
loadExchange(context);
}
@override
@ -123,20 +126,20 @@ class _BurzaViewState extends State<BurzaView> {
child: Column(
children: [
const SizedBox(height: 10),
Text("${Languages.of(context)!.balance}$kredit"),
Text("${Languages.of(context)!.balance}$balance"),
const SizedBox(height: 10),
SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: SizedBox(
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:opencanteen/okna/login.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:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
@ -14,25 +16,25 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart';
class JidelnicekView extends StatefulWidget {
const JidelnicekView({Key? key, required this.canteen}) : super(key: key);
class MealView extends StatefulWidget {
const MealView({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
@override
State<JidelnicekView> createState() => _JidelnicekViewState();
State<MealView> createState() => _MealViewState();
}
class _JidelnicekViewState extends State<JidelnicekView> {
List<Widget> obsah = [const CircularProgressIndicator()];
DateTime den = DateTime.now();
String denTydne = "";
double kredit = 0.0;
class _MealViewState extends State<MealView> {
List<Widget> content = [const CircularProgressIndicator()];
DateTime day = DateTime.now();
String dayOWeek = "";
double balance = 0.0;
bool _skipWeekend = false;
void kontrolaTyden(BuildContext context) async {
void checkWeek(BuildContext context) async {
var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("tyden") ?? false) {
// Zjistit jestli je objednáno na přístí týden
var pristi = den.add(const Duration(days: 6));
// Check if user has ordered a meal in the next week
var pristi = day.add(const Duration(days: 6));
for (var i = 0; i < 5; i++) {
var jidelnicek = await widget.canteen
.jidelnicekDen(den: pristi.add(Duration(days: i + 1)));
@ -47,8 +49,8 @@ class _JidelnicekViewState extends State<JidelnicekView> {
action: SnackBarAction(
onPressed: () => setState(
() {
den = pristi.add(Duration(days: i + 1));
nactiJidlo();
day = pristi.add(Duration(days: i + 1));
loadMeals();
},
),
label: Languages.of(context)!.jump,
@ -61,288 +63,295 @@ class _JidelnicekViewState extends State<JidelnicekView> {
}
}
Future<void> nactiJidlo() async {
obsah = [const CircularProgressIndicator()];
switch (den.weekday) {
Future<void> loadMeals() async {
content = [const CircularProgressIndicator()];
switch (day.weekday) {
case 2:
denTydne = Languages.of(context)!.tuesday;
dayOWeek = Languages.of(context)!.tuesday;
break;
case 3:
denTydne = Languages.of(context)!.wednesday;
dayOWeek = Languages.of(context)!.wednesday;
break;
case 4:
denTydne = Languages.of(context)!.thursday;
dayOWeek = Languages.of(context)!.thursday;
break;
case 5:
denTydne = Languages.of(context)!.friday;
dayOWeek = Languages.of(context)!.friday;
break;
case 6:
denTydne = Languages.of(context)!.saturday;
dayOWeek = Languages.of(context)!.saturday;
break;
case 7:
denTydne = Languages.of(context)!.sunday;
dayOWeek = Languages.of(context)!.sunday;
break;
default:
denTydne = Languages.of(context)!.monday;
dayOWeek = Languages.of(context)!.monday;
}
widget.canteen.ziskejUzivatele().then((kr) {
kredit = kr.kredit;
widget.canteen.jidelnicekDen(den: den).then((jd) async {
setState(() {
obsah = [];
if (jd.jidla.isEmpty) {
obsah.add(Text(
Languages.of(context)!.noFood,
style: const TextStyle(fontSize: 15),
));
} else {
for (var j in jd.jidla) {
obsah.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(j.varianta),
const SizedBox(width: 10),
Flexible(
child: Text(
j.nazev,
),
var uzivatel = await widget.canteen.ziskejUzivatele().catchError(
(o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
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) {
content.add(Text(
Languages.of(context)!.noFood,
style: const TextStyle(fontSize: 15),
));
} else {
for (var j in jd.jidla) {
content.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(j.varianta),
const SizedBox(width: 10),
Flexible(
child: Text(
j.nazev,
),
Text((j.naBurze)
? Languages.of(context)!.inExchange
: "${j.cena}"),
Checkbox(
value: j.objednano,
fillColor: (j.lzeObjednat)
? MaterialStateProperty.all(Colors.purple)
: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async {
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(Languages.of(context)!
.errorOrdering),
content: Text(
Languages.of(context)!.cannotOrder),
actions: [
TextButton(
child:
Text(Languages.of(context)!.ok),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child:
CircularProgressIndicator(),
),
Text(Languages.of(context)!
.ordering)
]),
),
));
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true)
.pop();
nactiJidlo();
}).catchError((o) {
Navigator.of(context, rootNavigator: true)
.pop();
showDialog(
context: context,
builder: (bc) => AlertDialog(
title: Text(Languages.of(context)!
.errorOrdering),
content: Text(o.toString()),
actions: [
TextButton(
child: Text(
Languages.of(context)!
.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
));
});
}
})
],
),
onTap: () async {
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title:
Text(Languages.of(context)!.errorOrdering),
content:
Text(Languages.of(context)!.cannotOrder),
actions: [
TextButton(
child: Text(Languages.of(context)!.ok),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
),
Text((j.naBurze)
? Languages.of(context)!.inExchange
: "${j.cena}"),
Checkbox(
value: j.objednano,
fillColor: (j.lzeObjednat)
? MaterialStateProperty.all(Colors.purple)
: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async {
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: Languages.of(context)!.cannotOrder,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
},
);
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(
children: [
const Padding(
padding: EdgeInsets.all(10),
child: CircularProgressIndicator(),
),
Text(Languages.of(context)!.ordering)
]),
],
),
));
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
nactiJidlo();
}).catchError(
(o) {
Navigator.of(context, rootNavigator: true).pop();
showDialog(
context: context,
builder: (bc) => AlertDialog(
title:
Text(Languages.of(context)!.errorOrdering),
content: Text(o.toString()),
actions: [
TextButton(
child: Text(Languages.of(context)!.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
),
),
);
},
);
}
},
onLongPress: () async {
if (!j.objednano || j.burzaUrl == null) return;
if (!j.naBurze) {
// pokud není na burze, radši se zeptáme
var d = await showDialog(
context: context,
builder: (bc) => SimpleDialog(
title: Text(
Languages.of(context)!.verifyExchange),
children: [
SimpleDialogOption(
onPressed: () {
Navigator.pop(bc, true);
},
child: Text(Languages.of(context)!.yes),
),
SimpleDialogOption(
onPressed: () {
Navigator.pop(bc, false);
},
child: Text(Languages.of(context)!.no),
),
],
));
if (d) {
widget.canteen
.doBurzy(j)
.then((_) => nactiJidlo())
.catchError((o) {
showDialog(
context: context,
builder: (bc) => AlertDialog(
title:
Text(Languages.of(context)!.exchangeError),
content: SingleChildScrollView(
child: Text(o.toString())),
actions: [
TextButton(
child: Text(Languages.of(context)!.close),
onPressed: () {
Navigator.pop(bc);
},
)
],
),
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
loadMeals();
}).catchError(
(o) {
Navigator.of(context, rootNavigator: true)
.pop();
showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: o.toString(),
actions: [
PlatformButton(
text: Languages.of(context)!.close,
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
},
);
});
}
} else {
// jinak ne
widget.canteen.doBurzy(j).then((_) => nactiJidlo());
}
},
}
},
)
],
),
onTap: () async {
if (!j.lzeObjednat) {
showDialog(
context: context,
builder: (context) {
return PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: Languages.of(context)!.cannotOrder,
actions: [
PlatformButton(
text: Languages.of(context)!.ok,
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
},
);
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => Dialog(
child: SizedBox(
height: 100,
child: Row(children: [
const Padding(
padding: EdgeInsets.all(10),
child: CircularProgressIndicator(),
),
Text(Languages.of(context)!.ordering)
]),
),
),
);
widget.canteen.objednat(j).then((_) {
Navigator.of(context, rootNavigator: true).pop();
loadMeals();
}).catchError(
(o) {
Navigator.of(context, rootNavigator: true).pop();
showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.errorOrdering,
content: o.toString(),
actions: [
PlatformButton(
text: Languages.of(context)!.close,
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
},
);
}
},
onLongPress: () async {
if (!j.objednano || j.burzaUrl == null) return;
if (!j.naBurze) {
// if not in exchange, we ask
var d = await showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.verifyExchange,
actions: [
PlatformButton(
onPressed: () {
Navigator.pop(bc, true);
},
text: Languages.of(context)!.yes,
),
PlatformButton(
onPressed: () {
Navigator.pop(bc, false);
},
text: Languages.of(context)!.no,
),
],
),
);
if (d) {
widget.canteen
.doBurzy(j)
.then((_) => loadMeals())
.catchError((o) {
showDialog(
context: context,
builder: (bc) => PlatformDialog(
title: Languages.of(context)!.exchangeError,
content: o.toString(),
actions: [
PlatformButton(
text: Languages.of(context)!.close,
onPressed: () {
Navigator.pop(bc);
},
)
],
),
);
});
}
} else {
// else no
widget.canteen.doBurzy(j).then((_) => loadMeals());
}
},
),
);
}
),
);
}
});
});
}).catchError((o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
}
},
);
return;
}
Future<void> kliknuti(String value, BuildContext context) async {
Future<void> click(String value, BuildContext context) async {
if (value == Languages.of(context)!.signOut) {
await showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: Text(Languages.of(context)!.warning),
content: Text(Languages.of(context)!.signOutWarn),
builder: (c) => PlatformDialog(
title: Languages.of(context)!.warning,
content: Languages.of(context)!.signOutWarn,
actions: [
TextButton(
PlatformButton(
onPressed: () {
const storage = FlutterSecureStorage();
storage.deleteAll();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (c) => const LoginPage()),
platformRouter((c) => const LoginPage()),
(route) => false);
},
child: Text(Languages.of(context)!.yes)),
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(Languages.of(context)!.no))
text: Languages.of(context)!.yes),
PlatformButton(
onPressed: () => Navigator.of(context).pop(),
text: Languages.of(context)!.no,
)
],
),
);
} 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);
} else if (value == Languages.of(context)!.reportBugs) {
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}",
applicationVersion: packageInfo.version,
children: [
TextButton(
onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
child: Text(Languages.of(context)!.source))
PlatformButton(
onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"),
mode: LaunchMode.externalApplication)),
text: Languages.of(context)!.source,
)
]);
} else if (value == Languages.of(context)!.settings) {
Navigator.push(
context, MaterialPageRoute(builder: (c) => const AndroidNastaveni()));
Navigator.push(context, platformRouter((c) => const AndroidNastaveni()));
}
}
void nactiNastaveni() async {
void loadSettings() async {
var prefs = await SharedPreferences.getInstance();
_skipWeekend = prefs.getBool("skip") ?? false;
if (!mounted) return;
kontrolaTyden(context);
checkWeek(context);
}
void ulozitDoOffline() async {
void saveOffline() async {
var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("offline") ?? false) {
// vyčistit offline
// clear offline storage
Directory appDocDir = await getApplicationDocumentsDirectory();
for (var f in appDocDir.listSync()) {
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;
if (pocet > 7) pocet = 7;
for (var i = 0; i < pocet; i++) {
var d = den.add(Duration(days: i));
var d = day.add(Duration(days: i));
Jidelnicek? j;
try {
j = await widget.canteen.jidelnicekDen(den: d);
@ -427,9 +437,9 @@ class _JidelnicekViewState extends State<JidelnicekView> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
nactiNastaveni();
ulozitDoOffline();
nactiJidlo();
loadSettings();
saveOffline();
loadMeals();
}
@override
@ -440,7 +450,7 @@ class _JidelnicekViewState extends State<JidelnicekView> {
title: Text(Languages.of(context)!.menu),
actions: [
PopupMenuButton(
onSelected: ((String value) => kliknuti(value, context)),
onSelected: ((String value) => click(value, context)),
itemBuilder: (BuildContext context) {
return {
Languages.of(context)!.reportBugs,
@ -459,62 +469,71 @@ class _JidelnicekViewState extends State<JidelnicekView> {
],
),
body: RefreshIndicator(
onRefresh: nactiJidlo,
onRefresh: loadMeals,
child: Center(
child: SizedBox(
width: MediaQuery.of(context).size.width - 50,
child: Column(
children: [
const SizedBox(height: 10),
Text("${Languages.of(context)!.balance}$kredit"),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
IconButton(
onPressed: () {
setState(() {
den = den.subtract(const Duration(days: 1));
if (den.weekday == 7 && _skipWeekend) {
den = den.subtract(const Duration(days: 2));
}
nactiJidlo();
});
},
icon: const Icon(Icons.arrow_left)),
TextButton(
Text("${Languages.of(context)!.balance}$balance"),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () {
setState(() {
day = day.subtract(const Duration(days: 1));
if (day.weekday == 7 && _skipWeekend) {
day = day.subtract(const Duration(days: 2));
}
loadMeals();
});
},
icon: const Icon(Icons.arrow_left)),
PlatformButton(
onPressed: () async {
var datePicked = await showDatePicker(
context: context,
initialDate: den,
currentDate: den,
initialDate: day,
currentDate: day,
firstDate: DateTime(2019, 1, 1),
lastDate: DateTime(den.year + 1, 12, 31),
lastDate: DateTime(day.year + 1, 12, 31),
locale: Localizations.localeOf(context));
if (datePicked == null) return;
setState(() {
den = datePicked;
nactiJidlo();
day = datePicked;
loadMeals();
});
},
child: Text(
"${den.day}. ${den.month}. ${den.year} - $denTydne")),
IconButton(
onPressed: () {
setState(() {
den = den.add(const Duration(days: 1));
if (den.weekday == 6 && _skipWeekend) {
den = den.add(const Duration(days: 2));
}
nactiJidlo();
});
},
icon: const Icon(Icons.arrow_right),
),
IconButton(
onPressed: () => setState(() {
den = DateTime.now();
nactiJidlo();
}),
icon: const Icon(Icons.today))
]),
text: "${day.day}. ${day.month}. ${day.year} - $dayOWeek",
),
IconButton(
onPressed: () {
setState(() {
day = day.add(const Duration(days: 1));
if (day.weekday == 6 && _skipWeekend) {
day = day.add(const Duration(days: 2));
}
loadMeals();
});
},
icon: const Icon(Icons.arrow_right),
),
Tooltip(
message: Languages.of(context)!.todayTooltip,
child: IconButton(
onPressed: () => setState(
() {
day = DateTime.now();
loadMeals();
},
),
icon: const Icon(Icons.today),
),
)
],
),
SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: GestureDetector(
@ -524,25 +543,27 @@ class _JidelnicekViewState extends State<JidelnicekView> {
.onPrimary
.withOpacity(0),
height: MediaQuery.of(context).size.height / 1.3,
child: Column(children: obsah),
child: Column(children: content),
),
onHorizontalDragEnd: (details) {
if (details.primaryVelocity?.compareTo(0) == -1) {
setState(() {
den = den.add(const Duration(days: 1));
if (den.weekday == 6 && _skipWeekend) {
den = den.add(const Duration(days: 2));
day = day.add(const Duration(days: 1));
if (day.weekday == 6 && _skipWeekend) {
day = day.add(const Duration(days: 2));
}
nactiJidlo();
loadMeals();
});
} else {
setState(() {
den = den.subtract(const Duration(days: 1));
if (den.weekday == 7 && _skipWeekend) {
den = den.subtract(const Duration(days: 2));
}
nactiJidlo();
});
setState(
() {
day = day.subtract(const Duration(days: 1));
if (day.weekday == 7 && _skipWeekend) {
day = day.subtract(const Duration(days: 2));
}
loadMeals();
},
);
}
},
),

View file

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

View file

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

View file

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/okna/login.dart';
import 'package:opencanteen/pw/platformbutton.dart';
import 'package:opencanteen/util.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
@ -12,90 +13,90 @@ import 'package:url_launcher/url_launcher.dart';
import '../../lang/lang.dart';
class AndroidOfflineJidelnicek extends StatefulWidget {
const AndroidOfflineJidelnicek({Key? key}) : super(key: key);
class OfflineMealView extends StatefulWidget {
const OfflineMealView({Key? key}) : super(key: key);
@override
State<AndroidOfflineJidelnicek> createState() =>
_AndroidOfflineJidelnicekState();
State<OfflineMealView> createState() => _OfflineMealViewState();
}
class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
List<Widget> obsah = [const CircularProgressIndicator()];
var _skipWeekend = false;
DateTime den = DateTime.now();
String denTydne = "";
List<List<OfflineJidlo>> data = [];
var jidloIndex = 0;
class _OfflineMealViewState extends State<OfflineMealView> {
List<Widget> content = [const CircularProgressIndicator()]; // view content
var _skipWeekend = false; // skip weekend setting
DateTime currentDay = DateTime.now(); // the day we are supposed to show
String dayOWeek = ""; // the name of the day (to show to user)
List<List<OfflineMeal>> data = []; // meal data
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();
for (var f in appDocDir.listSync()) {
if (f.path.contains("jidelnicek")) {
var soubor = File(f.path);
var input = await soubor.readAsString();
var r = jsonDecode(input);
List<OfflineJidlo> jidla = [];
List<OfflineMeal> jidla = [];
for (var j in r) {
jidla.add(OfflineJidlo(
nazev: j["nazev"],
varianta: j["varianta"],
objednano: j["objednano"],
cena: j["cena"],
naBurze: j["naBurze"],
den: DateTime.parse(j["den"])));
jidla.add(OfflineMeal(
name: j["nazev"],
variant: j["varianta"],
ordered: j["objednano"],
price: j["cena"],
onExchange: j["naBurze"],
day: DateTime.parse(j["den"])));
}
data.add(jidla);
}
}
nactiJidlo();
loadFood();
}
Future<void> nactiJidlo() async {
var jidelnicek = data[jidloIndex];
den = jidelnicek[0].den;
switch (den.weekday) {
Future<void> loadFood() async {
var jidelnicek = data[mealIndex];
currentDay = jidelnicek[0].day;
switch (currentDay.weekday) {
case 2:
denTydne = Languages.of(context)!.tuesday;
dayOWeek = Languages.of(context)!.tuesday;
break;
case 3:
denTydne = Languages.of(context)!.wednesday;
dayOWeek = Languages.of(context)!.wednesday;
break;
case 4:
denTydne = Languages.of(context)!.thursday;
dayOWeek = Languages.of(context)!.thursday;
break;
case 5:
denTydne = Languages.of(context)!.friday;
dayOWeek = Languages.of(context)!.friday;
break;
case 6:
denTydne = Languages.of(context)!.saturday;
dayOWeek = Languages.of(context)!.saturday;
break;
case 7:
denTydne = Languages.of(context)!.sunday;
dayOWeek = Languages.of(context)!.sunday;
break;
default:
denTydne = Languages.of(context)!.monday;
dayOWeek = Languages.of(context)!.monday;
}
obsah = [];
for (OfflineJidlo j in jidelnicek) {
obsah.add(
content = [];
for (OfflineMeal j in jidelnicek) {
content.add(
Padding(
padding: const EdgeInsets.only(top: 15),
child: InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(j.varianta),
Text(j.variant),
const SizedBox(width: 10),
Flexible(
child: Text(
j.nazev,
j.name,
),
),
Text((j.naBurze)
Text((j.onExchange)
? Languages.of(context)!.inExchange
: "${j.cena}"),
: "${j.price}"),
Checkbox(
value: j.objednano,
value: j.ordered,
fillColor: MaterialStateProperty.all(Colors.grey),
onChanged: (v) async {
return;
@ -110,14 +111,17 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
setState(() {});
}
void kliknuti(String value, BuildContext context) async {
void click(String value, BuildContext context) async {
if (value == Languages.of(context)!.signOut) {
const storage = FlutterSecureStorage();
storage.deleteAll();
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const LoginPage()));
context, platformRouter((c) => const LoginPage()));
} 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);
} else if (value == Languages.of(context)!.reportBugs) {
launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"),
@ -126,31 +130,33 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
var packageInfo = await PackageInfo.fromPlatform();
if (!mounted) return;
showAboutDialog(
context: context,
applicationName: "OpenCanteen",
applicationLegalese:
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
applicationVersion: packageInfo.version,
children: [
TextButton(
onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
child: Text(Languages.of(context)!.source))
]);
context: context,
applicationName: "OpenCanteen",
applicationLegalese:
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
applicationVersion: packageInfo.version,
children: [
PlatformButton(
onPressed: (() => launchUrl(
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
text: Languages.of(context)!.source,
)
],
);
}
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
nactiNastaveni();
loadSettings();
}
void nactiNastaveni() async {
void loadSettings() async {
var prefs = await SharedPreferences.getInstance();
_skipWeekend = prefs.getBool("skip") ?? false;
if (!mounted) return;
nactiZeSouboru();
loadFromFile();
}
@override
@ -161,7 +167,7 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
automaticallyImplyLeading: false,
actions: [
PopupMenuButton(
onSelected: ((String value) => kliknuti(value, context)),
onSelected: ((String value) => click(value, context)),
itemBuilder: (BuildContext context) {
return {
Languages.of(context)!.reportBugs,
@ -195,69 +201,69 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
IconButton(
onPressed: () {
if (data.length <= 1) return;
obsah = [const CircularProgressIndicator()];
content = [const CircularProgressIndicator()];
setState(() {
if (den.weekday == 1 && _skipWeekend) {
if (currentDay.weekday == 1 && _skipWeekend) {
// pokud je pondělí a chceme přeskočit víkend
if (jidloIndex - 2 >= 0) {
jidloIndex -= data.length - 3;
if (mealIndex - 2 >= 0) {
mealIndex -= data.length - 3;
} else {
jidloIndex = data.length - 1;
mealIndex = data.length - 1;
}
} else if (jidloIndex == 0) {
jidloIndex = data.length - 1;
} else if (mealIndex == 0) {
mealIndex = data.length - 1;
} else {
jidloIndex -= 1;
mealIndex -= 1;
}
nactiJidlo();
loadFood();
});
},
icon: const Icon(Icons.arrow_left)),
TextButton(
PlatformButton(
onPressed: () async {},
child: Text(
"${den.day}. ${den.month}. ${den.year} - $denTydne")),
text:
"${currentDay.day}. ${currentDay.month}. ${currentDay.year} - $dayOWeek"),
IconButton(
onPressed: () {
if (data.length <= 1) return;
obsah = [const CircularProgressIndicator()];
content = [const CircularProgressIndicator()];
setState(() {
if (den.weekday == 5 && _skipWeekend) {
if (currentDay.weekday == 5 && _skipWeekend) {
// pokud je pondělí a chceme přeskočit víkend
if (jidloIndex + 2 <= data.length - 1) {
jidloIndex += 2;
if (mealIndex + 2 <= data.length - 1) {
mealIndex += 2;
} else {
jidloIndex = 0;
mealIndex = 0;
}
} else if (jidloIndex == data.length) {
jidloIndex = 0;
} else if (mealIndex == data.length) {
mealIndex = 0;
} else {
jidloIndex += 1;
mealIndex += 1;
}
nactiJidlo();
loadFood();
});
},
icon: const Icon(Icons.arrow_right),
),
IconButton(
onPressed: () {
jidloIndex = 0;
mealIndex = 0;
},
icon: const Icon(Icons.today))
]),
SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: obsah,
children: content,
),
),
],
),
),
),
onRefresh: () => Navigator.pushReplacement(context,
MaterialPageRoute(builder: ((context) => const LoginPage()))),
onRefresh: () => Navigator.pushReplacement(
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:opencanteen/lang/lang.dart';
import 'package:opencanteen/okna/jidelnicek.dart';
import 'package:opencanteen/util.dart';
class WelcomePage extends StatefulWidget {
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");
if (!mounted) return;
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (c) => JidelnicekView(canteen: widget.canteen)),
platformRouter((c) => MealView(canteen: widget.canteen)),
(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 'package:canteenlib/canteenlib.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:opencanteen/okna/burza.dart';
import 'package:opencanteen/okna/jidelnicek.dart';
import 'lang/lang.dart';
@ -28,8 +30,7 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
title: Text(Languages.of(context)!.exchange),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BurzaView(canteen: canteen)),
platformRouter((context) => BurzaView(canteen: canteen)),
),
),
],
@ -49,8 +50,7 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
title: Text(Languages.of(context)!.home),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (c) => JidelnicekView(canteen: canteen)),
platformRouter((c) => MealView(canteen: canteen)),
),
),
ListTile(
@ -66,31 +66,60 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
return drawer;
}
class OfflineJidlo {
String nazev;
String varianta;
bool objednano;
double cena;
bool naBurze;
DateTime den;
class OfflineMeal {
String name;
String variant;
bool ordered;
double price;
bool onExchange;
DateTime day;
OfflineJidlo(
{required this.nazev,
required this.varianta,
required this.objednano,
required this.cena,
required this.naBurze,
required this.den});
OfflineMeal(
{required this.name,
required this.variant,
required this.ordered,
required this.price,
required this.onExchange,
required this.day});
}
/// Vytvoří [DateTime] z [TimeOfDay]
DateTime casNaDate(TimeOfDay c) {
/// Parses [DateTime] from [TimeOfDay]
DateTime timeToDate(TimeOfDay c) {
var now = DateTime.now();
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");
}
/// List of instances to be used in the dropdown menu
List<Map<String, String>> instance = [
{"name": "SŠTE Brno, Olomoucká", "url": "https://stravovani.sstebrno.cz"},
{"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
description:
name: archive
url: "https://pub.dartlang.org"
sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d
url: "https://pub.dev"
source: hosted
version: "3.3.4"
version: "3.3.6"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
url: "https://pub.dev"
source: hosted
version: "2.10.0"
canteenlib:
dependency: "direct main"
description:
name: canteenlib
url: "https://pub.dartlang.org"
sha256: c15aa1d11fb9d6d01d633b8cbb6780d3e63c9058f8cc3b0f7de2fbc21cf4903d
url: "https://pub.dev"
source: hosted
version: "1.1.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
url: "https://pub.dev"
source: hosted
version: "1.2.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c"
url: "https://pub.dev"
source: hosted
version: "0.3.5"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.17.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
url: "https://pub.dev"
source: hosted
version: "3.0.2"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
url: "https://pub.dev"
source: hosted
version: "0.7.8"
dots_indicator:
dependency: transitive
description:
name: dots_indicator
url: "https://pub.dartlang.org"
sha256: e59dfc90030ee5a4fd4c53144a8ce97cc7a823c2067b8fb9814960cd1ae63f89
url: "https://pub.dev"
source: hosted
version: "2.1.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
url: "https://pub.dev"
source: hosted
version: "2.0.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
flutter:
@ -115,35 +130,40 @@ packages:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
sha256: ce0e501cfc258907842238e4ca605e74b7fd1cdf04b3b43e86c43f3e40a1592c
url: "https://pub.dev"
source: hosted
version: "0.11.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
sha256: f222919a34545931e47b06000836b5101baeffb0e6eb5a4691d2d42851740dd9
url: "https://pub.dev"
source: hosted
version: "12.0.3+1"
version: "12.0.4"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
url: "https://pub.dartlang.org"
sha256: "3c6d6db334f609a92be0c0915f40871ec56f5d2adf01e77ae364162c587c0ca8"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
sha256: "5ec1feac5f7f7d9266759488bc5f76416152baba9aa1b26fe572246caa00d1ab"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_localizations:
@ -155,315 +175,351 @@ packages:
dependency: "direct main"
description:
name: flutter_native_timezone
url: "https://pub.dartlang.org"
sha256: ed7bfb982f036243de1c068e269182a877100c994f05143c8b26a325e28c1b02
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_secure_storage:
dependency: "direct main"
description:
name: flutter_secure_storage
url: "https://pub.dartlang.org"
sha256: "1b7c2f80ee41861543bc63fee56122a114129c15234731312418ca1eda7d3d7f"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
url: "https://pub.dartlang.org"
sha256: "736436adaf91552433823f51ce22e098c2f0551db06b6596f58597a25b8ea797"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
url: "https://pub.dartlang.org"
sha256: "388f76fd0f093e7415a39ec4c169ae7cceeee6d9f9ba529d788a13f2be4de7bd"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
name: flutter_secure_storage_platform_interface
url: "https://pub.dartlang.org"
sha256: b3773190e385a3c8a382007893d678ae95462b3c2279e987b55d140d3b0cb81b
url: "https://pub.dev"
source: hosted
version: "1.0.0"
version: "1.0.1"
flutter_secure_storage_web:
dependency: transitive
description:
name: flutter_secure_storage_web
url: "https://pub.dartlang.org"
sha256: "42938e70d4b872e856e678c423cc0e9065d7d294f45bc41fc1981a4eb4beaffe"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.1.1"
flutter_secure_storage_windows:
dependency: transitive
description:
name: flutter_secure_storage_windows
url: "https://pub.dartlang.org"
sha256: ca89c8059cf439985aa83c59619b3674c7ef6cc2e86943d169a7369d6a69cab5
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.1.3"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
sha256: "7cc92eabe01e3f1babe1571c5560b135dfc762a34e41e9056881e2196b178ec1"
url: "https://pub.dev"
source: hosted
version: "8.1.2"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
url: "https://pub.dev"
source: hosted
version: "0.13.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
sha256: "8e9d133755c3e84c73288363e6343157c383a0c6c56fc51afcc5d4d7180306d6"
url: "https://pub.dev"
source: hosted
version: "3.2.2"
version: "3.3.0"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
url: "https://pub.dev"
source: hosted
version: "0.17.0"
introduction_screen:
dependency: "direct main"
description:
name: introduction_screen
url: "https://pub.dartlang.org"
sha256: "73965475d6b271846f81c5fce5b459546a4ea36c285408691522437fd6bbeb69"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "3.1.4"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted
version: "0.6.4"
version: "0.6.5"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
url: "https://pub.dev"
source: hosted
version: "4.7.0"
version: "4.8.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted
version: "0.1.5"
version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
url: "https://pub.dartlang.org"
sha256: f62d7253edc197fe3c88d7c2ddab82d68f555e778d55390ccc3537eca8e8d637
url: "https://pub.dev"
source: hosted
version: "1.4.3+1"
package_info_plus_linux:
dependency: transitive
description:
name: package_info_plus_linux
url: "https://pub.dartlang.org"
sha256: "04b575f44233d30edbb80a94e57cad9107aada334fc02aabb42b6becd13c43fc"
url: "https://pub.dev"
source: hosted
version: "1.0.5"
package_info_plus_macos:
dependency: transitive
description:
name: package_info_plus_macos
url: "https://pub.dartlang.org"
sha256: a2ad8b4acf4cd479d4a0afa5a74ea3f5b1c7563b77e52cc32b3ee6956d5482a6
url: "https://pub.dev"
source: hosted
version: "1.3.0"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
url: "https://pub.dartlang.org"
sha256: f7a0c8f1e7e981bc65f8b64137a53fd3c195b18d429fba960babc59a5a1c7ae8
url: "https://pub.dev"
source: hosted
version: "1.0.2"
package_info_plus_web:
dependency: transitive
description:
name: package_info_plus_web
url: "https://pub.dartlang.org"
sha256: f0829327eb534789e0a16ccac8936a80beed4e2401c4d3a74f3f39094a822d3b
url: "https://pub.dev"
source: hosted
version: "1.0.6"
package_info_plus_windows:
dependency: transitive
description:
name: package_info_plus_windows
url: "https://pub.dartlang.org"
sha256: "79524f11c42dd9078b96d797b3cf79c0a2883a50c4920dc43da8562c115089bc"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
url: "https://pub.dev"
source: hosted
version: "1.8.2"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95
url: "https://pub.dev"
source: hosted
version: "2.0.11"
version: "2.0.12"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e
url: "https://pub.dev"
source: hosted
version: "2.0.21"
path_provider_ios:
version: "2.0.22"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
name: path_provider_foundation
sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74"
url: "https://pub.dev"
source: hosted
version: "2.0.11"
version: "2.1.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379
url: "https://pub.dev"
source: hosted
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:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76
url: "https://pub.dev"
source: hosted
version: "2.0.5"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c
url: "https://pub.dev"
source: hosted
version: "2.1.3"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a
url: "https://pub.dev"
source: hosted
version: "2.1.3"
pointycastle:
dependency: transitive
description:
name: pointycastle
url: "https://pub.dartlang.org"
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
url: "https://pub.dev"
source: hosted
version: "3.6.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
url: "https://pub.dev"
source: hosted
version: "4.2.4"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
sha256: "5949029e70abe87f75cfe59d17bf5c397619c4b74a099b10116baeb34786fad9"
url: "https://pub.dev"
source: hosted
version: "2.0.15"
version: "2.0.17"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
sha256: "955e9736a12ba776bdd261cf030232b30eadfcd9c79b32a3250dd4a494e8c8f7"
url: "https://pub.dev"
source: hosted
version: "2.0.14"
shared_preferences_ios:
version: "2.0.15"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
name: shared_preferences_foundation
sha256: "1ffa239043ab8baf881ec3094a3c767af9d10399b2839020b9e4d44c0bb23951"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
sha256: f8ea038aa6da37090093974ebdcf4397010605fd2ff65c37a66f9d28394cb874
url: "https://pub.dev"
source: hosted
version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.1.3"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3
url: "https://pub.dev"
source: hosted
version: "2.1.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958
url: "https://pub.dev"
source: hosted
version: "2.0.4"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
sha256: "5eaf05ae77658d3521d0e993ede1af962d4b326cd2153d312df716dc250f00c9"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
@ -473,128 +529,146 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.9.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
timezone:
dependency: "direct main"
description:
name: timezone
url: "https://pub.dartlang.org"
sha256: "24c8fcdd49a805d95777a39064862133ff816ebfffe0ceff110fb5960e557964"
url: "https://pub.dev"
source: hosted
version: "0.9.0"
version: "0.9.1"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
sha256: "698fa0b4392effdc73e9e184403b627362eb5fbf904483ac9defbb1c2191d809"
url: "https://pub.dev"
source: hosted
version: "6.1.6"
version: "6.1.8"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
sha256: "3e2f6dfd2c7d9cd123296cab8ef66cfc2c1a13f5845f42c7a0f365690a8a7dd1"
url: "https://pub.dev"
source: hosted
version: "6.0.21"
version: "6.0.23"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
sha256: bb328b24d3bccc20bdf1024a0990ac4f869d57663660de9c936fb8c043edefe3
url: "https://pub.dev"
source: hosted
version: "6.0.17"
version: "6.0.18"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
sha256: "318c42cba924e18180c029be69caf0a1a710191b9ec49bb42b5998fdcccee3cc"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
sha256: "41988b55570df53b3dd2a7fc90c76756a963de6a8c5f8e113330cb35992e2094"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
sha256: "4eae912628763eb48fc214522e58e942fd16ce195407dbf45638239523c759a6"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
sha256: "44d79408ce9f07052095ef1f9a693c258d6373dc3944249374e30eff7219ccb0"
url: "https://pub.dev"
source: hosted
version: "2.0.13"
version: "2.0.14"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
sha256: b6217370f8eb1fd85c8890c539f5a639a01ab209a36db82c921ebeacefc7a615
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46
url: "https://pub.dev"
source: hosted
version: "3.1.1"
version: "3.1.3"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86
url: "https://pub.dev"
source: hosted
version: "0.2.0+2"
version: "0.2.0+3"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
version: "6.2.2"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.18.0 <3.0.0"
dart: ">=2.18.2 <4.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.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
version: 1.6.1+26
version: 1.7.0+27
environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.18.2 <3.0.0"
dependencies:
flutter:
@ -27,6 +27,7 @@ dependencies:
flutter_native_timezone: ^2.0.0
intl: ^0.17.0
package_info_plus: ^1.4.3+1
fluttertoast: ^8.1.2
dev_dependencies:
flutter_lints: ^2.0.1