fix: přepsat Platform UI a zmenit RefreshIndicator #36
30 changed files with 1835 additions and 3172 deletions
2
.flutter
2
.flutter
|
@ -1 +1 @@
|
||||||
Subproject commit 52b3dc25f6471c27b2144594abb11c741cb88f57
|
Subproject commit b06b8b2710955028a6b562f5aa6fe62941d6febf
|
|
@ -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;
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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';
|
||||||
|
@ -7,8 +8,7 @@ import 'package:flutter_native_timezone/flutter_native_timezone.dart';
|
||||||
import 'package:opencanteen/lang/lang_cz.dart';
|
import 'package:opencanteen/lang/lang_cz.dart';
|
||||||
import 'package:opencanteen/loginmanager.dart';
|
import 'package:opencanteen/loginmanager.dart';
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
import 'package:canteenlib/canteenlib.dart';
|
||||||
import 'package:opencanteen/okna/android/login.dart';
|
import 'package:opencanteen/okna/login.dart';
|
||||||
import 'package:opencanteen/okna/ios/login.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
import 'package:opencanteen/util.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
@ -38,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();
|
||||||
|
@ -51,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 má 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',
|
||||||
|
@ -77,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,
|
||||||
|
@ -88,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
@ -103,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');
|
||||||
|
|
||||||
|
@ -116,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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,23 +125,38 @@ class MyApp extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return (Platform
|
||||||
debugShowCheckedModeBanner: false,
|
.isAndroid) // run app based on current platform to make use of the platform's respective UI lib
|
||||||
localizationsDelegates: const [
|
? MaterialApp(
|
||||||
AppLocalizationsDelegate(),
|
debugShowCheckedModeBanner: false,
|
||||||
...GlobalMaterialLocalizations.delegates
|
localizationsDelegates: const [
|
||||||
],
|
AppLocalizationsDelegate(),
|
||||||
supportedLocales: const [Locale("cs", ""), Locale("en", "")],
|
...GlobalMaterialLocalizations.delegates
|
||||||
title: "OpenCanteen",
|
],
|
||||||
theme: ThemeData(
|
supportedLocales: const [Locale("cs", ""), Locale("en", "")],
|
||||||
primarySwatch: Colors.purple,
|
title: "OpenCanteen",
|
||||||
),
|
theme: ThemeData(
|
||||||
darkTheme: ThemeData(
|
primarySwatch: Colors.purple,
|
||||||
brightness: Brightness.dark,
|
),
|
||||||
primarySwatch: Colors.purple,
|
darkTheme: ThemeData(
|
||||||
),
|
brightness: Brightness.dark,
|
||||||
home: (Platform.isAndroid) ? const AndroidLogin() : const IOSLogin(),
|
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(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:opencanteen/okna/android/login.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
|
|
||||||
class AndroidBurza extends StatefulWidget {
|
|
||||||
const AndroidBurza({Key? key, required this.canteen}) : super(key: key);
|
|
||||||
final Canteen canteen;
|
|
||||||
@override
|
|
||||||
State<AndroidBurza> createState() => _AndroidBurzaState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AndroidBurzaState extends State<AndroidBurza> {
|
|
||||||
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) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
nactiBurzu(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
drawer: drawerGenerator(context, widget.canteen, 3),
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(Languages.of(context)!.exchange),
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width - 50,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text("${Languages.of(context)!.balance}$kredit Kč"),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.of(context).size.height / 1.3,
|
|
||||||
child: Column(children: obsah),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onRefresh: () => nactiBurzu(context)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,557 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
import 'package:opencanteen/okna/android/login.dart';
|
|
||||||
import 'package:opencanteen/okna/android/nastaveni.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
|
|
||||||
class AndroidJidelnicek extends StatefulWidget {
|
|
||||||
const AndroidJidelnicek({Key? key, required this.canteen}) : super(key: key);
|
|
||||||
final Canteen canteen;
|
|
||||||
@override
|
|
||||||
State<AndroidJidelnicek> createState() => _AndroidJidelnicekState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AndroidJidelnicekState extends State<AndroidJidelnicek> {
|
|
||||||
List<Widget> obsah = [const CircularProgressIndicator()];
|
|
||||||
DateTime den = DateTime.now();
|
|
||||||
String denTydne = "";
|
|
||||||
double kredit = 0.0;
|
|
||||||
bool _skipWeekend = false;
|
|
||||||
|
|
||||||
void kontrolaTyden(BuildContext context) async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
if (prefs.getBool("tyden") ?? false) {
|
|
||||||
// Zjistit jestli je objednáno na přístí týden
|
|
||||||
var pristi = den.add(const Duration(days: 6));
|
|
||||||
for (var i = 0; i < 5; i++) {
|
|
||||||
var jidelnicek = await widget.canteen
|
|
||||||
.jidelnicekDen(den: pristi.add(Duration(days: i + 1)));
|
|
||||||
if (jidelnicek.jidla.isNotEmpty &&
|
|
||||||
!jidelnicek.jidla.any((element) => element.objednano == true)) {
|
|
||||||
if (!mounted) break;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.noOrder),
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
action: SnackBarAction(
|
|
||||||
onPressed: () => setState(
|
|
||||||
() {
|
|
||||||
den = pristi.add(Duration(days: i + 1));
|
|
||||||
nactiJidlo();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
label: Languages.of(context)!.jump,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> nactiJidlo() async {
|
|
||||||
obsah = [const CircularProgressIndicator()];
|
|
||||||
switch (den.weekday) {
|
|
||||||
case 2:
|
|
||||||
denTydne = Languages.of(context)!.tuesday;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
denTydne = Languages.of(context)!.wednesday;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
denTydne = Languages.of(context)!.thursday;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
denTydne = Languages.of(context)!.friday;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
denTydne = Languages.of(context)!.saturday;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
denTydne = Languages.of(context)!.sunday;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
denTydne = 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text((j.naBurze)
|
|
||||||
? Languages.of(context)!.inExchange
|
|
||||||
: "${j.cena} Kč"),
|
|
||||||
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: [
|
|
||||||
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);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// jinak ne
|
|
||||||
widget.canteen.doBurzy(j).then((_) => nactiJidlo());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}).catchError((o) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> kliknuti(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),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
storage.deleteAll();
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (c) => const AndroidLogin()),
|
|
||||||
(route) => false);
|
|
||||||
},
|
|
||||||
child: Text(Languages.of(context)!.yes)),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: Text(Languages.of(context)!.no))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (value == Languages.of(context)!.review) {
|
|
||||||
launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"),
|
|
||||||
mode: LaunchMode.externalApplication);
|
|
||||||
} else if (value == Languages.of(context)!.reportBugs) {
|
|
||||||
launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"),
|
|
||||||
mode: LaunchMode.externalApplication);
|
|
||||||
} else if (value == Languages.of(context)!.about) {
|
|
||||||
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))
|
|
||||||
]);
|
|
||||||
} else if (value == Languages.of(context)!.settings) {
|
|
||||||
Navigator.push(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const AndroidNastaveni()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nactiNastaveni() async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
_skipWeekend = prefs.getBool("skip") ?? false;
|
|
||||||
if (!mounted) return;
|
|
||||||
kontrolaTyden(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ulozitDoOffline() async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
if (prefs.getBool("offline") ?? false) {
|
|
||||||
// vyčistit offline
|
|
||||||
Directory appDocDir = await getApplicationDocumentsDirectory();
|
|
||||||
for (var f in appDocDir.listSync()) {
|
|
||||||
if (f.path.contains("jidelnicek")) {
|
|
||||||
f.deleteSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// uložit *pocet* jídelníčků pro offline použití
|
|
||||||
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));
|
|
||||||
Jidelnicek? j;
|
|
||||||
try {
|
|
||||||
j = await widget.canteen.jidelnicekDen(den: d);
|
|
||||||
} catch (e) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.errorSaving),
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var soubor = File(
|
|
||||||
"${appDocDir.path}/jidelnicek_${d.year}-${d.month}-${d.day}.json");
|
|
||||||
soubor.createSync();
|
|
||||||
var jidla = [];
|
|
||||||
for (var jidlo in j!.jidla) {
|
|
||||||
jidla.add({
|
|
||||||
"nazev": jidlo.nazev,
|
|
||||||
"varianta": jidlo.varianta,
|
|
||||||
"objednano": jidlo.objednano,
|
|
||||||
"cena": jidlo.cena,
|
|
||||||
"naBurze": jidlo.naBurze,
|
|
||||||
"den": d.toString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await soubor.writeAsString(json.encode(jidla));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
nactiNastaveni();
|
|
||||||
ulozitDoOffline();
|
|
||||||
nactiJidlo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
drawer: drawerGenerator(context, widget.canteen, 1),
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(Languages.of(context)!.menu),
|
|
||||||
actions: [
|
|
||||||
PopupMenuButton(
|
|
||||||
onSelected: ((String value) => kliknuti(value, context)),
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return {
|
|
||||||
Languages.of(context)!.reportBugs,
|
|
||||||
Languages.of(context)!.review,
|
|
||||||
Languages.of(context)!.settings,
|
|
||||||
Languages.of(context)!.about,
|
|
||||||
Languages.of(context)!.signOut
|
|
||||||
}.map((String choice) {
|
|
||||||
return PopupMenuItem<String>(
|
|
||||||
value: choice,
|
|
||||||
child: Text(choice),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
onRefresh: nactiJidlo,
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width - 50,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text("${Languages.of(context)!.balance}$kredit Kč"),
|
|
||||||
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(
|
|
||||||
onPressed: () async {
|
|
||||||
var datePicked = await showDatePicker(
|
|
||||||
context: context,
|
|
||||||
initialDate: den,
|
|
||||||
currentDate: den,
|
|
||||||
firstDate: DateTime(2019, 1, 1),
|
|
||||||
lastDate: DateTime(den.year + 1, 12, 31),
|
|
||||||
locale: Localizations.localeOf(context));
|
|
||||||
if (datePicked == null) return;
|
|
||||||
setState(() {
|
|
||||||
den = datePicked;
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
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))
|
|
||||||
]),
|
|
||||||
SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: GestureDetector(
|
|
||||||
child: Container(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onPrimary
|
|
||||||
.withOpacity(0),
|
|
||||||
height: MediaQuery.of(context).size.height / 1.3,
|
|
||||||
child: Column(children: obsah),
|
|
||||||
),
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
den = den.subtract(const Duration(days: 1));
|
|
||||||
if (den.weekday == 7 && _skipWeekend) {
|
|
||||||
den = den.subtract(const Duration(days: 2));
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,281 +0,0 @@
|
||||||
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/android/welcome.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
import '../../loginmanager.dart';
|
|
||||||
import '../../main.dart';
|
|
||||||
import '../../util.dart';
|
|
||||||
import 'jidelnicek.dart';
|
|
||||||
import 'offline_jidelnicek.dart';
|
|
||||||
|
|
||||||
class AndroidLogin extends StatefulWidget {
|
|
||||||
const AndroidLogin({Key? key}) : super(key: key);
|
|
||||||
@override
|
|
||||||
State<AndroidLogin> createState() => _AndroidLoginState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AndroidLoginState extends State<AndroidLogin> {
|
|
||||||
TextEditingController userControl = TextEditingController();
|
|
||||||
TextEditingController passControl = TextEditingController();
|
|
||||||
TextEditingController canteenControl = TextEditingController();
|
|
||||||
bool rememberMe = false;
|
|
||||||
bool _showUrl = false;
|
|
||||||
String dropdownUrl = instance.first["url"] ?? "";
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
LoginManager.getDetails().then((r) async {
|
|
||||||
// žádat o oprávnění na android
|
|
||||||
flutterLocalNotificationsPlugin
|
|
||||||
.resolvePlatformSpecificImplementation<
|
|
||||||
AndroidFlutterLocalNotificationsPlugin>()
|
|
||||||
?.requestPermission();
|
|
||||||
|
|
||||||
if (r != null) {
|
|
||||||
// Automaticky přihlásit
|
|
||||||
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)!.loggingIn)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
var canteen = Canteen(r["url"]!);
|
|
||||||
try {
|
|
||||||
var l = await canteen.login(r["user"]!, r["pass"]!);
|
|
||||||
if (!l) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.loginFailed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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) => AndroidWelcome(canteen: canteen),
|
|
||||||
),
|
|
||||||
(route) => false);
|
|
||||||
} else {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => AndroidJidelnicek(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),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} catch (_) {
|
|
||||||
if (!mounted) return;
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.errorContacting),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
goOffline();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@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),
|
|
||||||
),
|
|
||||||
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) {
|
|
||||||
setState(() {
|
|
||||||
if (value == "") {
|
|
||||||
_showUrl = true;
|
|
||||||
} else {
|
|
||||||
_showUrl = false;
|
|
||||||
}
|
|
||||||
dropdownUrl = 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";
|
|
||||||
}
|
|
||||||
var canteen = Canteen(canteenUrl);
|
|
||||||
try {
|
|
||||||
var l = await canteen.login(
|
|
||||||
userControl.text, passControl.text);
|
|
||||||
if (!l) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content:
|
|
||||||
Text(Languages.of(context)!.loginFailed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (rememberMe) {
|
|
||||||
LoginManager.setDetails(
|
|
||||||
userControl.text, passControl.text, canteenUrl);
|
|
||||||
}
|
|
||||||
// souhlas
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
var odsouhlasil =
|
|
||||||
await storage.read(key: "oc_souhlas");
|
|
||||||
if (!mounted) return;
|
|
||||||
if (odsouhlasil == null || odsouhlasil != "ano") {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (c) => AndroidWelcome(
|
|
||||||
canteen: canteen,
|
|
||||||
)),
|
|
||||||
(route) => false);
|
|
||||||
} else {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => AndroidJidelnicek(
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(Languages.of(context)!.logIn)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Získá offline soubor a zobrazí údaje
|
|
||||||
void goOffline() async {
|
|
||||||
if (!mounted) return;
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: ((context) => const AndroidOfflineJidelnicek())),
|
|
||||||
(route) => false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,282 +0,0 @@
|
||||||
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_native_timezone/flutter_native_timezone.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:timezone/timezone.dart' as tz;
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
import '../../loginmanager.dart';
|
|
||||||
import '../../main.dart';
|
|
||||||
import '../../util.dart';
|
|
||||||
|
|
||||||
class AndroidNastaveni extends StatefulWidget {
|
|
||||||
const AndroidNastaveni({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AndroidNastaveni> createState() => _AndroidNastaveniState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AndroidNastaveniState extends State<AndroidNastaveni> {
|
|
||||||
bool _ukladatOffline = false;
|
|
||||||
bool _preskakovatVikend = false;
|
|
||||||
bool _kontrolovatTyden = false;
|
|
||||||
bool _oznameniObed = false;
|
|
||||||
bool _zapamatovany = false;
|
|
||||||
TimeOfDay _oznameniCas = TimeOfDay.now();
|
|
||||||
final TextEditingController _countController =
|
|
||||||
TextEditingController(text: "1");
|
|
||||||
SharedPreferences? preferences;
|
|
||||||
void najitNastaveni() 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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void zmenitNastaveni(String key, bool value) async {
|
|
||||||
preferences!.setBool(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
najitNastaveni();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
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,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_ukladatOffline = value;
|
|
||||||
cistit(value);
|
|
||||||
zmenitNastaveni("offline", value);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(Languages.of(context)!.saveCount),
|
|
||||||
SizedBox(
|
|
||||||
width: 35,
|
|
||||||
child: TextField(
|
|
||||||
controller: _countController,
|
|
||||||
enabled: _ukladatOffline,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
|
||||||
onChanged: (c) {
|
|
||||||
var cislo = int.tryParse(c);
|
|
||||||
if (cislo != null) {
|
|
||||||
preferences!.setInt("offline_pocet", cislo);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(Languages.of(context)!.skipWeekend),
|
|
||||||
Switch(
|
|
||||||
activeColor: Colors.purple,
|
|
||||||
value: _preskakovatVikend,
|
|
||||||
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,
|
|
||||||
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),
|
|
||||||
onChanged: (value) {
|
|
||||||
if (!_zapamatovany) {
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_oznameniObed = value;
|
|
||||||
if (_oznameniObed) {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
zmenitNastaveni("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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cistit(bool value) async {
|
|
||||||
if (!value) {
|
|
||||||
Directory appDocDir = await getApplicationDocumentsDirectory();
|
|
||||||
for (var f in appDocDir.listSync()) {
|
|
||||||
// Vymažeme obsah
|
|
||||||
if (f.path.contains("jidelnicek")) {
|
|
||||||
f.deleteSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void vytvoritOznameni(DateTime den) async {
|
|
||||||
await flutterLocalNotificationsPlugin.cancelAll();
|
|
||||||
var d = await LoginManager.getDetails(); // získat údaje
|
|
||||||
if (d != null) {
|
|
||||||
// Nové oznámení
|
|
||||||
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);
|
|
||||||
|
|
||||||
const AndroidNotificationDetails androidSpec =
|
|
||||||
AndroidNotificationDetails('opencanteen', 'predobjedem',
|
|
||||||
channelDescription: 'Oznámení o dnešním jídle',
|
|
||||||
importance: Importance.max,
|
|
||||||
priority: Priority.high,
|
|
||||||
ticker: 'today meal');
|
|
||||||
var l =
|
|
||||||
tz.getLocation(await FlutterNativeTimezone.getLocalTimezone());
|
|
||||||
if (!mounted) return;
|
|
||||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
|
||||||
// Vytvoří nové oznámení pro daný čas a datum
|
|
||||||
0,
|
|
||||||
Languages.of(context)!.lunchNotif,
|
|
||||||
"${jidlo.varianta} - ${jidlo.nazev}",
|
|
||||||
tz.TZDateTime.from(den, l),
|
|
||||||
const NotificationDetails(android: androidSpec),
|
|
||||||
androidAllowWhileIdle: true,
|
|
||||||
uiLocalNotificationDateInterpretation:
|
|
||||||
UILocalNotificationDateInterpretation.absoluteTime);
|
|
||||||
} on StateError catch (_) {
|
|
||||||
// nenalezeno
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,264 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
import 'package:opencanteen/okna/android/login.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
|
|
||||||
class AndroidOfflineJidelnicek extends StatefulWidget {
|
|
||||||
const AndroidOfflineJidelnicek({Key? key}) : super(key: key);
|
|
||||||
@override
|
|
||||||
State<AndroidOfflineJidelnicek> createState() =>
|
|
||||||
_AndroidOfflineJidelnicekState();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
void nactiZeSouboru() 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 = [];
|
|
||||||
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"])));
|
|
||||||
}
|
|
||||||
data.add(jidla);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> nactiJidlo() async {
|
|
||||||
var jidelnicek = data[jidloIndex];
|
|
||||||
den = jidelnicek[0].den;
|
|
||||||
switch (den.weekday) {
|
|
||||||
case 2:
|
|
||||||
denTydne = Languages.of(context)!.tuesday;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
denTydne = Languages.of(context)!.wednesday;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
denTydne = Languages.of(context)!.thursday;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
denTydne = Languages.of(context)!.friday;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
denTydne = Languages.of(context)!.saturday;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
denTydne = Languages.of(context)!.sunday;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
denTydne = Languages.of(context)!.monday;
|
|
||||||
}
|
|
||||||
obsah = [];
|
|
||||||
for (OfflineJidlo j in jidelnicek) {
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text((j.naBurze)
|
|
||||||
? Languages.of(context)!.inExchange
|
|
||||||
: "${j.cena} Kč"),
|
|
||||||
Checkbox(
|
|
||||||
value: j.objednano,
|
|
||||||
fillColor: MaterialStateProperty.all(Colors.grey),
|
|
||||||
onChanged: (v) async {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
void kliknuti(String value, BuildContext context) async {
|
|
||||||
if (value == Languages.of(context)!.signOut) {
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
storage.deleteAll();
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
|
|
||||||
} else if (value == Languages.of(context)!.review) {
|
|
||||||
launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"),
|
|
||||||
mode: LaunchMode.externalApplication);
|
|
||||||
} else if (value == Languages.of(context)!.reportBugs) {
|
|
||||||
launchUrl(Uri.parse("https://forms.gle/jKN7QeFJwpaApSbC8"),
|
|
||||||
mode: LaunchMode.externalApplication);
|
|
||||||
} else if (value == Languages.of(context)!.about) {
|
|
||||||
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))
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
nactiNastaveni();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nactiNastaveni() async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
_skipWeekend = prefs.getBool("skip") ?? false;
|
|
||||||
if (!mounted) return;
|
|
||||||
nactiZeSouboru();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(Languages.of(context)!.menu),
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
actions: [
|
|
||||||
PopupMenuButton(
|
|
||||||
onSelected: ((String value) => kliknuti(value, context)),
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return {
|
|
||||||
Languages.of(context)!.reportBugs,
|
|
||||||
Languages.of(context)!.review,
|
|
||||||
Languages.of(context)!.about,
|
|
||||||
Languages.of(context)!.signOut
|
|
||||||
}.map((String choice) {
|
|
||||||
return PopupMenuItem<String>(
|
|
||||||
value: choice,
|
|
||||||
child: Text(choice),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width - 50,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text(
|
|
||||||
Languages.of(context)!.offline,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
Text(Languages.of(context)!.mustLogout),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (data.length <= 1) return;
|
|
||||||
obsah = [const CircularProgressIndicator()];
|
|
||||||
setState(() {
|
|
||||||
if (den.weekday == 1 && _skipWeekend) {
|
|
||||||
// pokud je pondělí a chceme přeskočit víkend
|
|
||||||
if (jidloIndex - 2 >= 0) {
|
|
||||||
jidloIndex -= data.length - 3;
|
|
||||||
} else {
|
|
||||||
jidloIndex = data.length - 1;
|
|
||||||
}
|
|
||||||
} else if (jidloIndex == 0) {
|
|
||||||
jidloIndex = data.length - 1;
|
|
||||||
} else {
|
|
||||||
jidloIndex -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.arrow_left)),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {},
|
|
||||||
child: Text(
|
|
||||||
"${den.day}. ${den.month}. ${den.year} - $denTydne")),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (data.length <= 1) return;
|
|
||||||
obsah = [const CircularProgressIndicator()];
|
|
||||||
setState(() {
|
|
||||||
if (den.weekday == 5 && _skipWeekend) {
|
|
||||||
// pokud je pondělí a chceme přeskočit víkend
|
|
||||||
if (jidloIndex + 2 <= data.length - 1) {
|
|
||||||
jidloIndex += 2;
|
|
||||||
} else {
|
|
||||||
jidloIndex = 0;
|
|
||||||
}
|
|
||||||
} else if (jidloIndex == data.length) {
|
|
||||||
jidloIndex = 0;
|
|
||||||
} else {
|
|
||||||
jidloIndex += 1;
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.arrow_right),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
jidloIndex = 0;
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.today))
|
|
||||||
]),
|
|
||||||
SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: Column(
|
|
||||||
children: obsah,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onRefresh: () => Navigator.pushReplacement(context,
|
|
||||||
MaterialPageRoute(builder: ((context) => const AndroidLogin()))),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
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/android/jidelnicek.dart';
|
|
||||||
|
|
||||||
class AndroidWelcome extends StatefulWidget {
|
|
||||||
const AndroidWelcome({Key? key, required this.canteen}) : super(key: key);
|
|
||||||
|
|
||||||
final Canteen canteen;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AndroidWelcome> createState() => _AndroidWelcomeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AndroidWelcomeState extends State<AndroidWelcome> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var listPagesViewModel = [
|
|
||||||
PageViewModel(
|
|
||||||
title: Languages.of(context)!.welcome,
|
|
||||||
body: Languages.of(context)!.appDesc,
|
|
||||||
image: const Center(
|
|
||||||
child: Icon(Icons.waving_hand_outlined, size: 175),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PageViewModel(
|
|
||||||
title: Languages.of(context)!.aboutOrder,
|
|
||||||
body: Languages.of(context)!.howOrder,
|
|
||||||
image: Center(
|
|
||||||
child: Image.asset('assets/objednavam.png',
|
|
||||||
width: MediaQuery.of(context).size.width * 0.85),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PageViewModel(
|
|
||||||
title: Languages.of(context)!.aboutToExch,
|
|
||||||
body: Languages.of(context)!.howToExch,
|
|
||||||
image: Center(
|
|
||||||
child: Image.asset('assets/doburzy.png',
|
|
||||||
width: MediaQuery.of(context).size.width * 0.85),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PageViewModel(
|
|
||||||
title: Languages.of(context)!.aboutFromExch,
|
|
||||||
body: Languages.of(context)!.howFromExch,
|
|
||||||
image: Center(
|
|
||||||
child: Image.asset('assets/burza.png',
|
|
||||||
width: MediaQuery.of(context).size.width * 0.85),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PageViewModel(
|
|
||||||
title: Languages.of(context)!.warning,
|
|
||||||
body: Languages.of(context)!.notOfficial,
|
|
||||||
image: const Center(
|
|
||||||
child: Icon(Icons.warning_amber_outlined, size: 175),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
return Scaffold(
|
|
||||||
body: IntroductionScreen(
|
|
||||||
pages: listPagesViewModel,
|
|
||||||
next: Text(Languages.of(context)!.next),
|
|
||||||
done: Text(Languages.of(context)!.ok,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
||||||
onDone: () async {
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
await storage.write(key: "oc_souhlas", value: "ano");
|
|
||||||
if (!mounted) return;
|
|
||||||
Navigator.of(context).pushAndRemoveUntil(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (c) => AndroidJidelnicek(canteen: widget.canteen)),
|
|
||||||
(route) => false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
145
lib/okna/burza.dart
Normal file
145
lib/okna/burza.dart
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
class BurzaView extends StatefulWidget {
|
||||||
|
const BurzaView({Key? key, required this.canteen}) : super(key: key);
|
||||||
|
final Canteen canteen;
|
||||||
|
@override
|
||||||
|
State<BurzaView> createState() => _BurzaViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BurzaViewState extends State<BurzaView> {
|
||||||
|
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, 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();
|
||||||
|
loadExchange(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
drawer: drawerGenerator(context, widget.canteen, 3),
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(Languages.of(context)!.exchange),
|
||||||
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
child: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width - 50,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text("${Languages.of(context)!.balance}$balance Kč"),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SingleChildScrollView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
child: SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height / 1.3,
|
||||||
|
child: Column(children: content),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onRefresh: () => loadExchange(context)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,143 +0,0 @@
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:opencanteen/okna/ios/login.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
|
|
||||||
class IOSBurza extends StatefulWidget {
|
|
||||||
const IOSBurza({Key? key, required this.canteen}) : super(key: key);
|
|
||||||
final Canteen canteen;
|
|
||||||
@override
|
|
||||||
State<IOSBurza> createState() => _IOSBurzaState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IOSBurzaState extends State<IOSBurza> {
|
|
||||||
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"),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () {
|
|
||||||
widget.canteen.objednatZBurzy(b).then((a) {
|
|
||||||
if (a) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title: Text(Languages.of(context)!.ordered),
|
|
||||||
content: Text(
|
|
||||||
Languages.of(context)!.orderSuccess),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child: Text(Languages.of(context)!.ok),
|
|
||||||
onPressed: () =>
|
|
||||||
Navigator.of(context).pop(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title: Text(
|
|
||||||
Languages.of(context)!.cannotOrder),
|
|
||||||
content: Text(
|
|
||||||
Languages.of(context)!.errorOrdering),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child: Text(Languages.of(context)!.ok),
|
|
||||||
onPressed: () =>
|
|
||||||
Navigator.of(context).pop(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
nactiBurzu(context);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text(Languages.of(context)!.order)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}).catchError((o) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const IOSLogin()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
nactiBurzu(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
drawer: drawerGenerator(context, widget.canteen, 3),
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(Languages.of(context)!.exchange),
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width - 50,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text("${Languages.of(context)!.balance}$kredit Kč"),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.of(context).size.height / 1.3,
|
|
||||||
child: Column(children: obsah),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onRefresh: () => nactiBurzu(context)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,568 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
import 'package:opencanteen/okna/ios/login.dart';
|
|
||||||
import 'package:opencanteen/okna/ios/nastaveni.dart';
|
|
||||||
import 'package:opencanteen/util.dart';
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
|
|
||||||
class IOSJidelnicek extends StatefulWidget {
|
|
||||||
const IOSJidelnicek({Key? key, required this.canteen}) : super(key: key);
|
|
||||||
final Canteen canteen;
|
|
||||||
@override
|
|
||||||
State<IOSJidelnicek> createState() => _IOSJidelnicekState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IOSJidelnicekState extends State<IOSJidelnicek> {
|
|
||||||
List<Widget> obsah = [const CircularProgressIndicator()];
|
|
||||||
DateTime den = DateTime.now();
|
|
||||||
String denTydne = "";
|
|
||||||
double kredit = 0.0;
|
|
||||||
bool _skipWeekend = false;
|
|
||||||
|
|
||||||
void kontrolaTyden(BuildContext context) async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
if (prefs.getBool("tyden") ?? false) {
|
|
||||||
// Zjistit jestli je objednáno na přístí týden
|
|
||||||
var pristi = den.add(const Duration(days: 6));
|
|
||||||
for (var i = 0; i < 5; i++) {
|
|
||||||
var jidelnicek = await widget.canteen
|
|
||||||
.jidelnicekDen(den: pristi.add(Duration(days: i + 1)));
|
|
||||||
if (jidelnicek.jidla.isNotEmpty &&
|
|
||||||
!jidelnicek.jidla.any((element) => element.objednano == true)) {
|
|
||||||
if (!mounted) break;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.noOrder),
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
action: SnackBarAction(
|
|
||||||
onPressed: () => setState(
|
|
||||||
() {
|
|
||||||
den = pristi.add(Duration(days: i + 1));
|
|
||||||
nactiJidlo();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
label: Languages.of(context)!.jump,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> nactiJidlo() async {
|
|
||||||
obsah = [const CircularProgressIndicator()];
|
|
||||||
switch (den.weekday) {
|
|
||||||
case 2:
|
|
||||||
denTydne = Languages.of(context)!.tuesday;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
denTydne = Languages.of(context)!.wednesday;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
denTydne = Languages.of(context)!.thursday;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
denTydne = Languages.of(context)!.friday;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
denTydne = Languages.of(context)!.saturday;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
denTydne = Languages.of(context)!.sunday;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
denTydne = 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text((j.naBurze)
|
|
||||||
? Languages.of(context)!.inExchange
|
|
||||||
: "${j.cena} Kč"),
|
|
||||||
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 CupertinoAlertDialog(
|
|
||||||
title: Text(Languages.of(context)!
|
|
||||||
.errorOrdering),
|
|
||||||
content: Text(
|
|
||||||
Languages.of(context)!.cannotOrder),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
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) => CupertinoAlertDialog(
|
|
||||||
title: Text(Languages.of(context)!
|
|
||||||
.errorOrdering),
|
|
||||||
content: Text(o.toString()),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child: Text(
|
|
||||||
Languages.of(context)!
|
|
||||||
.close),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(bc);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
if (!j.lzeObjednat) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return CupertinoAlertDialog(
|
|
||||||
title:
|
|
||||||
Text(Languages.of(context)!.errorOrdering),
|
|
||||||
content:
|
|
||||||
Text(Languages.of(context)!.cannotOrder),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
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) => CupertinoAlertDialog(
|
|
||||||
title:
|
|
||||||
Text(Languages.of(context)!.errorOrdering),
|
|
||||||
content: Text(o.toString()),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
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) => CupertinoAlertDialog(
|
|
||||||
title: Text(
|
|
||||||
Languages.of(context)!.exchangeError),
|
|
||||||
content: Text(o.toString()),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child: Text(
|
|
||||||
Languages.of(context)!.close),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(bc);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// jinak ne
|
|
||||||
widget.canteen.doBurzy(j).then((_) => nactiJidlo());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}).catchError((o) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const IOSLogin()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> kliknuti(String value, BuildContext context) async {
|
|
||||||
if (value == Languages.of(context)!.signOut) {
|
|
||||||
await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (c) => CupertinoAlertDialog(
|
|
||||||
title: Text(Languages.of(context)!.warning),
|
|
||||||
content: Text(Languages.of(context)!.signOutWarn),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () {
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
storage.deleteAll();
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (c) => const IOSLogin()),
|
|
||||||
(route) => false);
|
|
||||||
},
|
|
||||||
child: Text(Languages.of(context)!.yes)),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: Text(Languages.of(context)!.no))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (value == Languages.of(context)!.review) {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse("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"),
|
|
||||||
mode: LaunchMode.externalApplication);
|
|
||||||
} else if (value == Languages.of(context)!.about) {
|
|
||||||
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: [
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: (() => launchUrl(
|
|
||||||
Uri.parse("https://git.mnau.xyz/hernik/opencanteen"))),
|
|
||||||
child: Text(Languages.of(context)!.source))
|
|
||||||
]);
|
|
||||||
} else if (value == Languages.of(context)!.settings) {
|
|
||||||
Navigator.push(
|
|
||||||
context, MaterialPageRoute(builder: (c) => const IOSNastaveni()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nactiNastaveni() async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
_skipWeekend = prefs.getBool("skip") ?? false;
|
|
||||||
if (!mounted) return;
|
|
||||||
kontrolaTyden(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ulozitDoOffline() async {
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
if (prefs.getBool("offline") ?? false) {
|
|
||||||
// vyčistit offline
|
|
||||||
Directory appDocDir = await getApplicationDocumentsDirectory();
|
|
||||||
for (var f in appDocDir.listSync()) {
|
|
||||||
if (f.path.contains("jidelnicek")) {
|
|
||||||
f.deleteSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// uložit *pocet* jídelníčků pro offline použití
|
|
||||||
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));
|
|
||||||
Jidelnicek? j;
|
|
||||||
try {
|
|
||||||
j = await widget.canteen.jidelnicekDen(den: d);
|
|
||||||
} catch (e) {
|
|
||||||
if (!widget.canteen.prihlasen) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.errorSaving),
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var soubor = File(
|
|
||||||
"${appDocDir.path}/jidelnicek_${d.year}-${d.month}-${d.day}.json");
|
|
||||||
soubor.createSync();
|
|
||||||
var jidla = [];
|
|
||||||
for (var jidlo in j!.jidla) {
|
|
||||||
jidla.add({
|
|
||||||
"nazev": jidlo.nazev,
|
|
||||||
"varianta": jidlo.varianta,
|
|
||||||
"objednano": jidlo.objednano,
|
|
||||||
"cena": jidlo.cena,
|
|
||||||
"naBurze": jidlo.naBurze,
|
|
||||||
"den": d.toString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await soubor.writeAsString(json.encode(jidla));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
nactiNastaveni();
|
|
||||||
ulozitDoOffline();
|
|
||||||
nactiJidlo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
drawer: drawerGenerator(context, widget.canteen, 1),
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(Languages.of(context)!.menu),
|
|
||||||
actions: [
|
|
||||||
PopupMenuButton(
|
|
||||||
onSelected: ((String value) => kliknuti(value, context)),
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return {
|
|
||||||
Languages.of(context)!.reportBugs,
|
|
||||||
Languages.of(context)!.review,
|
|
||||||
Languages.of(context)!.settings,
|
|
||||||
Languages.of(context)!.about,
|
|
||||||
Languages.of(context)!.signOut
|
|
||||||
}.map((String choice) {
|
|
||||||
return PopupMenuItem<String>(
|
|
||||||
value: choice,
|
|
||||||
child: Text(choice),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: RefreshIndicator(
|
|
||||||
onRefresh: nactiJidlo,
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width - 45,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text("${Languages.of(context)!.balance}$kredit Kč"),
|
|
||||||
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)),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await showCupertinoModalPopup(
|
|
||||||
context: context,
|
|
||||||
builder: (c) => Container(
|
|
||||||
height: 216,
|
|
||||||
padding: const EdgeInsets.only(top: 6),
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
||||||
),
|
|
||||||
color: CupertinoColors.systemBackground
|
|
||||||
.resolveFrom(context),
|
|
||||||
child: SafeArea(
|
|
||||||
top: false,
|
|
||||||
child: CupertinoDatePicker(
|
|
||||||
mode: CupertinoDatePickerMode.date,
|
|
||||||
onDateTimeChanged: (t) {
|
|
||||||
den = t;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
nactiJidlo();
|
|
||||||
},
|
|
||||||
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))
|
|
||||||
]),
|
|
||||||
SingleChildScrollView(
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
child: GestureDetector(
|
|
||||||
child: Container(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onPrimary
|
|
||||||
.withOpacity(0),
|
|
||||||
height: MediaQuery.of(context).size.height / 1.3,
|
|
||||||
child: Column(children: obsah),
|
|
||||||
),
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
den = den.subtract(const Duration(days: 1));
|
|
||||||
if (den.weekday == 7 && _skipWeekend) {
|
|
||||||
den = den.subtract(const Duration(days: 2));
|
|
||||||
}
|
|
||||||
nactiJidlo();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,282 +0,0 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/cupertino.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/ios/welcome.dart';
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
import '../../loginmanager.dart';
|
|
||||||
import '../../main.dart';
|
|
||||||
import '../../util.dart';
|
|
||||||
import 'jidelnicek.dart';
|
|
||||||
import 'offline_jidelnicek.dart';
|
|
||||||
|
|
||||||
class IOSLogin extends StatefulWidget {
|
|
||||||
const IOSLogin({Key? key}) : super(key: key);
|
|
||||||
@override
|
|
||||||
State<IOSLogin> createState() => _IOSLoginState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IOSLoginState extends State<IOSLogin> {
|
|
||||||
TextEditingController userControl = TextEditingController();
|
|
||||||
TextEditingController passControl = TextEditingController();
|
|
||||||
TextEditingController canteenControl = TextEditingController();
|
|
||||||
bool rememberMe = false;
|
|
||||||
bool _showUrl = false;
|
|
||||||
String dropdownUrl = instance.first["url"] ?? "";
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
LoginManager.getDetails().then((r) async {
|
|
||||||
// žádat o oprávnění na iOS
|
|
||||||
await flutterLocalNotificationsPlugin
|
|
||||||
.resolvePlatformSpecificImplementation<
|
|
||||||
IOSFlutterLocalNotificationsPlugin>()
|
|
||||||
?.requestPermissions(
|
|
||||||
alert: true,
|
|
||||||
badge: true,
|
|
||||||
sound: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (r != null) {
|
|
||||||
// Automaticky přihlásit
|
|
||||||
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)!.loggingIn)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
var canteen = Canteen(r["url"]!);
|
|
||||||
try {
|
|
||||||
var l = await canteen.login(r["user"]!, r["pass"]!);
|
|
||||||
if (!l) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.loginFailed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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) => IOSWelcome(canteen: canteen),
|
|
||||||
),
|
|
||||||
(route) => false);
|
|
||||||
} else {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => IOSJidelnicek(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),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} catch (_) {
|
|
||||||
if (!mounted) return;
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(Languages.of(context)!.errorContacting),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
goOffline();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@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),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
Languages.of(context)!.logIn,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
CupertinoTextField(
|
|
||||||
controller: userControl,
|
|
||||||
autofillHints: const [AutofillHints.username],
|
|
||||||
prefix: Text(Languages.of(context)!.username),
|
|
||||||
),
|
|
||||||
CupertinoTextField(
|
|
||||||
autofillHints: const [AutofillHints.password],
|
|
||||||
prefix: Text(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: TextField(
|
|
||||||
autofillHints: const [AutofillHints.url],
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: Languages.of(context)!.iCanteenUrl),
|
|
||||||
keyboardType: TextInputType.url,
|
|
||||||
controller: canteenControl,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
||||||
CupertinoSwitch(
|
|
||||||
value: rememberMe,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
rememberMe = value;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
Text(Languages.of(context)!.rememberMe)
|
|
||||||
]),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () async {
|
|
||||||
var canteenUrl = (dropdownUrl == "")
|
|
||||||
? canteenControl.text
|
|
||||||
: dropdownUrl;
|
|
||||||
if (!canteenUrl.startsWith("https://") &&
|
|
||||||
!canteenUrl.startsWith("http://")) {
|
|
||||||
canteenUrl = "https://$canteenUrl";
|
|
||||||
}
|
|
||||||
var canteen = Canteen(canteenUrl);
|
|
||||||
try {
|
|
||||||
var l = await canteen.login(
|
|
||||||
userControl.text, passControl.text);
|
|
||||||
if (!l) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content:
|
|
||||||
Text(Languages.of(context)!.loginFailed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (rememberMe) {
|
|
||||||
LoginManager.setDetails(
|
|
||||||
userControl.text, passControl.text, canteenUrl);
|
|
||||||
}
|
|
||||||
// souhlas
|
|
||||||
const storage = FlutterSecureStorage();
|
|
||||||
var odsouhlasil =
|
|
||||||
await storage.read(key: "oc_souhlas");
|
|
||||||
if (!mounted) return;
|
|
||||||
if (odsouhlasil == null || odsouhlasil != "ano") {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (c) => IOSWelcome(
|
|
||||||
canteen: canteen,
|
|
||||||
)),
|
|
||||||
(route) => false);
|
|
||||||
} else {
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
IOSJidelnicek(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();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(Languages.of(context)!.logIn)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Získá offline soubor a zobrazí údaje
|
|
||||||
void goOffline() async {
|
|
||||||
if (!mounted) return;
|
|
||||||
Navigator.pushAndRemoveUntil(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: ((context) => const IOSOfflineJidelnicek())),
|
|
||||||
(route) => false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,282 +0,0 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:canteenlib/canteenlib.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
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:path_provider/path_provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:timezone/timezone.dart' as tz;
|
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
|
||||||
import '../../loginmanager.dart';
|
|
||||||
import '../../main.dart';
|
|
||||||
import '../../util.dart';
|
|
||||||
|
|
||||||
class IOSNastaveni extends StatefulWidget {
|
|
||||||
const IOSNastaveni({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<IOSNastaveni> createState() => _IOSNastaveniState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IOSNastaveniState extends State<IOSNastaveni> {
|
|
||||||
bool _ukladatOffline = false;
|
|
||||||
bool _preskakovatVikend = false;
|
|
||||||
bool _kontrolovatTyden = false;
|
|
||||||
bool _oznameniObed = false;
|
|
||||||
bool _zapamatovany = false;
|
|
||||||
TimeOfDay _oznameniCas = TimeOfDay.now();
|
|
||||||
final TextEditingController _countController =
|
|
||||||
TextEditingController(text: "1");
|
|
||||||
SharedPreferences? preferences;
|
|
||||||
void najitNastaveni() 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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void zmenitNastaveni(String key, bool value) async {
|
|
||||||
preferences!.setBool(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
najitNastaveni();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
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),
|
|
||||||
CupertinoSwitch(
|
|
||||||
activeColor: Colors.purple,
|
|
||||||
value: _ukladatOffline,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_ukladatOffline = value;
|
|
||||||
cistit(value);
|
|
||||||
zmenitNastaveni("offline", value);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(Languages.of(context)!.saveCount),
|
|
||||||
SizedBox(
|
|
||||||
width: 35,
|
|
||||||
child: CupertinoTextField(
|
|
||||||
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),
|
|
||||||
CupertinoSwitch(
|
|
||||||
activeColor: Colors.purple,
|
|
||||||
value: _preskakovatVikend,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_preskakovatVikend = value;
|
|
||||||
zmenitNastaveni("skip", value);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Flexible(child: Text(Languages.of(context)!.checkOrdered)),
|
|
||||||
CupertinoSwitch(
|
|
||||||
activeColor: Colors.purple,
|
|
||||||
value: _kontrolovatTyden,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_kontrolovatTyden = value;
|
|
||||||
zmenitNastaveni("tyden", value);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Flexible(child: Text(Languages.of(context)!.notifyLunch)),
|
|
||||||
CupertinoSwitch(
|
|
||||||
activeColor: Colors.purple,
|
|
||||||
value: _oznameniObed,
|
|
||||||
onChanged: (value) {
|
|
||||||
if (!_zapamatovany) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (bc) => CupertinoAlertDialog(
|
|
||||||
title: Text(Languages.of(context)!.error),
|
|
||||||
content:
|
|
||||||
Text(Languages.of(context)!.needRemember),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child: Text(Languages.of(context)!.ok),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_oznameniObed = value;
|
|
||||||
if (_oznameniObed) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title:
|
|
||||||
Text(Languages.of(context)!.warning),
|
|
||||||
content: Text(
|
|
||||||
Languages.of(context)!.notifyWarning),
|
|
||||||
actions: [
|
|
||||||
CupertinoButton(
|
|
||||||
child:
|
|
||||||
Text(Languages.of(context)!.ok),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
vytvoritOznameni(casNaDate(_oznameniCas));
|
|
||||||
}
|
|
||||||
zmenitNastaveni("oznamit", value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(Languages.of(context)!.notifyAt),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () async {
|
|
||||||
if (_oznameniObed) {
|
|
||||||
showCupertinoModalPopup(
|
|
||||||
context: context,
|
|
||||||
builder: (c) {
|
|
||||||
return Container(
|
|
||||||
height: 216,
|
|
||||||
padding: const EdgeInsets.only(top: 6),
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
||||||
),
|
|
||||||
color: CupertinoColors.systemBackground
|
|
||||||
.resolveFrom(context),
|
|
||||||
child: SafeArea(
|
|
||||||
top: false,
|
|
||||||
child: CupertinoDatePicker(
|
|
||||||
mode: CupertinoDatePickerMode.time,
|
|
||||||
onDateTimeChanged: (cas) {
|
|
||||||
setState(() {
|
|
||||||
_oznameniCas = TimeOfDay.fromDateTime(cas);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
"${(_oznameniCas.hour < 10 ? "0" : "") + _oznameniCas.hour.toString()}:${(_oznameniCas.minute < 10 ? "0" : "") + _oznameniCas.minute.toString()}",
|
|
||||||
style: TextStyle(
|
|
||||||
color: (!_oznameniObed) ? Colors.grey : Colors.purple),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cistit(bool value) async {
|
|
||||||
if (!value) {
|
|
||||||
Directory appDocDir = await getApplicationDocumentsDirectory();
|
|
||||||
for (var f in appDocDir.listSync()) {
|
|
||||||
// Vymažeme obsah
|
|
||||||
if (f.path.contains("jidelnicek")) {
|
|
||||||
f.deleteSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void vytvoritOznameni(DateTime den) async {
|
|
||||||
await flutterLocalNotificationsPlugin.cancelAll();
|
|
||||||
var d = await LoginManager.getDetails(); // získat údaje
|
|
||||||
if (d != null) {
|
|
||||||
// Nové oznámení
|
|
||||||
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);
|
|
||||||
var l =
|
|
||||||
tz.getLocation(await FlutterNativeTimezone.getLocalTimezone());
|
|
||||||
if (!mounted) return;
|
|
||||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
|
||||||
// Vytvoří nové oznámení pro daný čas a datum
|
|
||||||
0,
|
|
||||||
Languages.of(context)!.lunchNotif,
|
|
||||||
"${jidlo.varianta} - ${jidlo.nazev}",
|
|
||||||
tz.TZDateTime.from(den, l),
|
|
||||||
const NotificationDetails(),
|
|
||||||
androidAllowWhileIdle: true,
|
|
||||||
uiLocalNotificationDateInterpretation:
|
|
||||||
UILocalNotificationDateInterpretation.absoluteTime);
|
|
||||||
} on StateError catch (_) {
|
|
||||||
// nenalezeno
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
578
lib/okna/jidelnicek.dart
Normal file
578
lib/okna/jidelnicek.dart
Normal file
|
@ -0,0 +1,578 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:canteenlib/canteenlib.dart';
|
||||||
|
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';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../../lang/lang.dart';
|
||||||
|
|
||||||
|
class MealView extends StatefulWidget {
|
||||||
|
const MealView({Key? key, required this.canteen}) : super(key: key);
|
||||||
|
final Canteen canteen;
|
||||||
|
@override
|
||||||
|
State<MealView> createState() => _MealViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MealViewState extends State<MealView> {
|
||||||
|
List<Widget> content = [const CircularProgressIndicator()];
|
||||||
|
DateTime day = DateTime.now();
|
||||||
|
String dayOWeek = "";
|
||||||
|
double balance = 0.0;
|
||||||
|
bool _skipWeekend = false;
|
||||||
|
|
||||||
|
void checkWeek(BuildContext context) async {
|
||||||
|
var prefs = await SharedPreferences.getInstance();
|
||||||
|
if (prefs.getBool("tyden") ?? false) {
|
||||||
|
// 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)));
|
||||||
|
if (jidelnicek.jidla.isNotEmpty &&
|
||||||
|
!jidelnicek.jidla.any((element) => element.objednano == true)) {
|
||||||
|
if (!mounted) break;
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(Languages.of(context)!.noOrder),
|
||||||
|
duration: const Duration(seconds: 5),
|
||||||
|
action: SnackBarAction(
|
||||||
|
onPressed: () => setState(
|
||||||
|
() {
|
||||||
|
day = pristi.add(Duration(days: i + 1));
|
||||||
|
loadMeals();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
label: Languages.of(context)!.jump,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadMeals() async {
|
||||||
|
content = [const CircularProgressIndicator()];
|
||||||
|
switch (day.weekday) {
|
||||||
|
case 2:
|
||||||
|
dayOWeek = Languages.of(context)!.tuesday;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
dayOWeek = Languages.of(context)!.wednesday;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
dayOWeek = Languages.of(context)!.thursday;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
dayOWeek = Languages.of(context)!.friday;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
dayOWeek = Languages.of(context)!.saturday;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
dayOWeek = Languages.of(context)!.sunday;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dayOWeek = Languages.of(context)!.monday;
|
||||||
|
}
|
||||||
|
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} Kč"),
|
||||||
|
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();
|
||||||
|
loadMeals();
|
||||||
|
}).catchError(
|
||||||
|
(o) {
|
||||||
|
Navigator.of(context, rootNavigator: true)
|
||||||
|
.pop();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (bc) => PlatformDialog(
|
||||||
|
title: Languages.of(context)!.errorOrdering,
|
||||||
|
content: o.toString(),
|
||||||
|
actions: [
|
||||||
|
PlatformButton(
|
||||||
|
text: Languages.of(context)!.close,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(bc);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
if (!j.lzeObjednat) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return PlatformDialog(
|
||||||
|
title: Languages.of(context)!.errorOrdering,
|
||||||
|
content: Languages.of(context)!.cannotOrder,
|
||||||
|
actions: [
|
||||||
|
PlatformButton(
|
||||||
|
text: Languages.of(context)!.ok,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (_) => Dialog(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 100,
|
||||||
|
child: Row(children: [
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
Text(Languages.of(context)!.ordering)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
widget.canteen.objednat(j).then((_) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
loadMeals();
|
||||||
|
}).catchError(
|
||||||
|
(o) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> click(String value, BuildContext context) async {
|
||||||
|
if (value == Languages.of(context)!.signOut) {
|
||||||
|
await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => PlatformDialog(
|
||||||
|
title: Languages.of(context)!.warning,
|
||||||
|
content: Languages.of(context)!.signOutWarn,
|
||||||
|
actions: [
|
||||||
|
PlatformButton(
|
||||||
|
onPressed: () {
|
||||||
|
const storage = FlutterSecureStorage();
|
||||||
|
storage.deleteAll();
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
platformRouter((c) => const LoginPage()),
|
||||||
|
(route) => false);
|
||||||
|
},
|
||||||
|
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((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"),
|
||||||
|
mode: LaunchMode.externalApplication);
|
||||||
|
} else if (value == Languages.of(context)!.about) {
|
||||||
|
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: [
|
||||||
|
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, platformRouter((c) => const AndroidNastaveni()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSettings() async {
|
||||||
|
var prefs = await SharedPreferences.getInstance();
|
||||||
|
_skipWeekend = prefs.getBool("skip") ?? false;
|
||||||
|
if (!mounted) return;
|
||||||
|
checkWeek(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveOffline() async {
|
||||||
|
var prefs = await SharedPreferences.getInstance();
|
||||||
|
if (prefs.getBool("offline") ?? false) {
|
||||||
|
// clear offline storage
|
||||||
|
Directory appDocDir = await getApplicationDocumentsDirectory();
|
||||||
|
for (var f in appDocDir.listSync()) {
|
||||||
|
if (f.path.contains("jidelnicek")) {
|
||||||
|
f.deleteSync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 = day.add(Duration(days: i));
|
||||||
|
Jidelnicek? j;
|
||||||
|
try {
|
||||||
|
j = await widget.canteen.jidelnicekDen(den: d);
|
||||||
|
} catch (e) {
|
||||||
|
if (!widget.canteen.prihlasen) {
|
||||||
|
if (!mounted) return;
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
content: Text(Languages.of(context)!.errorSaving),
|
||||||
|
duration: const Duration(seconds: 5),
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var soubor = File(
|
||||||
|
"${appDocDir.path}/jidelnicek_${d.year}-${d.month}-${d.day}.json");
|
||||||
|
soubor.createSync();
|
||||||
|
var jidla = [];
|
||||||
|
for (var jidlo in j!.jidla) {
|
||||||
|
jidla.add({
|
||||||
|
"nazev": jidlo.nazev,
|
||||||
|
"varianta": jidlo.varianta,
|
||||||
|
"objednano": jidlo.objednano,
|
||||||
|
"cena": jidlo.cena,
|
||||||
|
"naBurze": jidlo.naBurze,
|
||||||
|
"den": d.toString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await soubor.writeAsString(json.encode(jidla));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
loadSettings();
|
||||||
|
saveOffline();
|
||||||
|
loadMeals();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
drawer: drawerGenerator(context, widget.canteen, 1),
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(Languages.of(context)!.menu),
|
||||||
|
actions: [
|
||||||
|
PopupMenuButton(
|
||||||
|
onSelected: ((String value) => click(value, context)),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return {
|
||||||
|
Languages.of(context)!.reportBugs,
|
||||||
|
Languages.of(context)!.review,
|
||||||
|
Languages.of(context)!.settings,
|
||||||
|
Languages.of(context)!.about,
|
||||||
|
Languages.of(context)!.signOut
|
||||||
|
}.map((String choice) {
|
||||||
|
return PopupMenuItem<String>(
|
||||||
|
value: choice,
|
||||||
|
child: Text(choice),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
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}$balance Kč"),
|
||||||
|
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: day,
|
||||||
|
currentDate: day,
|
||||||
|
firstDate: DateTime(2019, 1, 1),
|
||||||
|
lastDate: DateTime(day.year + 1, 12, 31),
|
||||||
|
locale: Localizations.localeOf(context));
|
||||||
|
if (datePicked == null) return;
|
||||||
|
setState(() {
|
||||||
|
day = datePicked;
|
||||||
|
loadMeals();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
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(
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimary
|
||||||
|
.withOpacity(0),
|
||||||
|
height: MediaQuery.of(context).size.height / 1.3,
|
||||||
|
child: Column(children: content),
|
||||||
|
),
|
||||||
|
onHorizontalDragEnd: (details) {
|
||||||
|
if (details.primaryVelocity?.compareTo(0) == -1) {
|
||||||
|
setState(() {
|
||||||
|
day = day.add(const Duration(days: 1));
|
||||||
|
if (day.weekday == 6 && _skipWeekend) {
|
||||||
|
day = day.add(const Duration(days: 2));
|
||||||
|
}
|
||||||
|
loadMeals();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(
|
||||||
|
() {
|
||||||
|
day = day.subtract(const Duration(days: 1));
|
||||||
|
if (day.weekday == 7 && _skipWeekend) {
|
||||||
|
day = day.subtract(const Duration(days: 2));
|
||||||
|
}
|
||||||
|
loadMeals();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
253
lib/okna/login.dart
Normal file
253
lib/okna/login.dart
Normal file
|
@ -0,0 +1,253 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
class LoginPage extends StatefulWidget {
|
||||||
|
const LoginPage({Key? key}) : super(key: key);
|
||||||
|
@override
|
||||||
|
State<LoginPage> createState() => _LoginPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginPageState extends State<LoginPage> {
|
||||||
|
TextEditingController userControl = TextEditingController();
|
||||||
|
TextEditingController passControl = TextEditingController();
|
||||||
|
TextEditingController canteenControl = TextEditingController();
|
||||||
|
bool rememberMe = false;
|
||||||
|
bool _showUrl = false;
|
||||||
|
String dropdownUrl = instance.first["url"] ?? "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
LoginManager.getDetails().then((r) async {
|
||||||
|
// request android notification access
|
||||||
|
flutterLocalNotificationsPlugin
|
||||||
|
.resolvePlatformSpecificImplementation<
|
||||||
|
AndroidFlutterLocalNotificationsPlugin>()
|
||||||
|
?.requestPermission();
|
||||||
|
|
||||||
|
if (r != null) {
|
||||||
|
// Autologin
|
||||||
|
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)!.loggingIn)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
var canteen = Canteen(r["url"]!);
|
||||||
|
try {
|
||||||
|
var l = await canteen.login(r["user"]!, r["pass"]!);
|
||||||
|
if (!l) {
|
||||||
|
if (!mounted) return;
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(Languages.of(context)!.loginFailed),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const storage = FlutterSecureStorage();
|
||||||
|
var odsouhlasil = await storage.read(key: "oc_souhlas");
|
||||||
|
if (!mounted) return;
|
||||||
|
if (odsouhlasil == null || odsouhlasil != "ano") {
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
platformRouter(
|
||||||
|
(c) => WelcomePage(canteen: canteen),
|
||||||
|
),
|
||||||
|
(route) => false);
|
||||||
|
} else {
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
platformRouter(
|
||||||
|
(context) => MealView(canteen: canteen),
|
||||||
|
),
|
||||||
|
(route) => false);
|
||||||
|
}
|
||||||
|
} on PlatformException {
|
||||||
|
if (!mounted) return;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showInfo(context, Languages.of(context)!.corrupted);
|
||||||
|
} catch (_) {
|
||||||
|
if (!mounted) return;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showInfo(context, Languages.of(context)!.errorContacting);
|
||||||
|
goOffline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@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),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
|
PlatformSwitch(
|
||||||
|
value: rememberMe,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
rememberMe = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(route) => false);
|
||||||
|
} else {
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
platformRouter(
|
||||||
|
(context) => MealView(
|
||||||
|
canteen: canteen,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(route) => false);
|
||||||
|
}
|
||||||
|
} on PlatformException {
|
||||||
|
if (!mounted) return;
|
||||||
|
showInfo(context, Languages.of(context)!.corrupted);
|
||||||
|
} on Exception catch (_) {
|
||||||
|
if (!mounted) return;
|
||||||
|
showInfo(
|
||||||
|
context, Languages.of(context)!.errorContacting);
|
||||||
|
//goOffline();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text: Languages.of(context)!.logIn),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Switch to offline view
|
||||||
|
void goOffline() async {
|
||||||
|
if (!mounted) return;
|
||||||
|
Navigator.pushAndRemoveUntil(context,
|
||||||
|
platformRouter((context) => const OfflineMealView()), (route) => false);
|
||||||
|
}
|
||||||
|
}
|
288
lib/okna/nastaveni.dart
Normal file
288
lib/okna/nastaveni.dart
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
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_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;
|
||||||
|
|
||||||
|
import '../../lang/lang.dart';
|
||||||
|
import '../../loginmanager.dart';
|
||||||
|
import '../../main.dart';
|
||||||
|
import '../../util.dart';
|
||||||
|
|
||||||
|
class AndroidNastaveni extends StatefulWidget {
|
||||||
|
const AndroidNastaveni({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AndroidNastaveni> createState() => _AndroidNastaveniState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AndroidNastaveniState extends State<AndroidNastaveni> {
|
||||||
|
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 loadSettings() async {
|
||||||
|
preferences = await SharedPreferences.getInstance();
|
||||||
|
_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 changeSetting(String key, bool value) async {
|
||||||
|
preferences!.setBool(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
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),
|
||||||
|
PlatformSwitch(
|
||||||
|
value: _saveOffline,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_saveOffline = value;
|
||||||
|
clear(value);
|
||||||
|
changeSetting("offline", value);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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(
|
||||||
|
() {
|
||||||
|
_skipWeekend = value;
|
||||||
|
changeSetting("skip", value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Flexible(child: Text(Languages.of(context)!.checkOrdered)),
|
||||||
|
PlatformSwitch(
|
||||||
|
value: _checkWeek,
|
||||||
|
onChanged: (value) {
|
||||||
|
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 (!_remember) {
|
||||||
|
showDialog(
|
||||||
|
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(() {
|
||||||
|
_notifyMeal = value;
|
||||||
|
if (_notifyMeal) {
|
||||||
|
showDialog(
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
changeSetting("oznamit", value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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 clear(bool value) async {
|
||||||
|
if (!value) {
|
||||||
|
Directory appDocDir = await getApplicationDocumentsDirectory();
|
||||||
|
for (var f in appDocDir.listSync()) {
|
||||||
|
// Vymažeme obsah
|
||||||
|
if (f.path.contains("jidelnicek")) {
|
||||||
|
f.deleteSync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void createNotif(DateTime den) async {
|
||||||
|
await flutterLocalNotificationsPlugin.cancelAll();
|
||||||
|
var d = await LoginManager.getDetails(); // grab details
|
||||||
|
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);
|
||||||
|
|
||||||
|
const AndroidNotificationDetails androidSpec =
|
||||||
|
AndroidNotificationDetails('opencanteen', 'predobjedem',
|
||||||
|
channelDescription: 'Oznámení o dnešním jídle',
|
||||||
|
importance: Importance.max,
|
||||||
|
priority: Priority.high,
|
||||||
|
ticker: 'today meal');
|
||||||
|
var l =
|
||||||
|
tz.getLocation(await FlutterNativeTimezone.getLocalTimezone());
|
||||||
|
if (!mounted) return;
|
||||||
|
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||||
|
// schedules a notification
|
||||||
|
0,
|
||||||
|
Languages.of(context)!.lunchNotif,
|
||||||
|
"${jidlo.varianta} - ${jidlo.nazev}",
|
||||||
|
tz.TZDateTime.from(den, l),
|
||||||
|
const NotificationDetails(android: androidSpec),
|
||||||
|
androidAllowWhileIdle: true,
|
||||||
|
uiLocalNotificationDateInterpretation:
|
||||||
|
UILocalNotificationDateInterpretation.absoluteTime);
|
||||||
|
} on StateError catch (_) {
|
||||||
|
// no meal found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
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/ios/login.dart';
|
import 'package:opencanteen/okna/login.dart';
|
||||||
|
import 'package:opencanteen/pw/platformbutton.dart';
|
||||||
import 'package:opencanteen/util.dart';
|
import 'package:opencanteen/util.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
@ -13,89 +13,90 @@ import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../lang/lang.dart';
|
import '../../lang/lang.dart';
|
||||||
|
|
||||||
class IOSOfflineJidelnicek extends StatefulWidget {
|
class OfflineMealView extends StatefulWidget {
|
||||||
const IOSOfflineJidelnicek({Key? key}) : super(key: key);
|
const OfflineMealView({Key? key}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
State<IOSOfflineJidelnicek> createState() => _IOSOfflineJidelnicekState();
|
State<OfflineMealView> createState() => _OfflineMealViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
|
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} Kč"),
|
: "${j.price} Kč"),
|
||||||
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,15 +111,17 @@ class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
|
||||||
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 IOSLogin()));
|
context, platformRouter((c) => const LoginPage()));
|
||||||
} else if (value == Languages.of(context)!.review) {
|
} else if (value == Languages.of(context)!.review) {
|
||||||
launchUrl(
|
launchUrl(
|
||||||
Uri.parse("https://apps.apple.com/cz/app/opencanteen/id1621124445"),
|
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"),
|
||||||
|
@ -127,31 +130,33 @@ class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
|
||||||
var packageInfo = await PackageInfo.fromPlatform();
|
var packageInfo = await PackageInfo.fromPlatform();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
showAboutDialog(
|
showAboutDialog(
|
||||||
context: context,
|
context: context,
|
||||||
applicationName: "OpenCanteen",
|
applicationName: "OpenCanteen",
|
||||||
applicationLegalese:
|
applicationLegalese:
|
||||||
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
|
"${Languages.of(context)!.copyright}\n${Languages.of(context)!.license}",
|
||||||
applicationVersion: packageInfo.version,
|
applicationVersion: packageInfo.version,
|
||||||
children: [
|
children: [
|
||||||
CupertinoButton(
|
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
|
||||||
|
@ -162,7 +167,7 @@ class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
|
||||||
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,
|
||||||
|
@ -196,69 +201,69 @@ class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
|
||||||
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)),
|
||||||
CupertinoButton(
|
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 IOSLogin()))),
|
context, platformRouter((context) => const LoginPage())),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -3,18 +3,19 @@ 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: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/ios/jidelnicek.dart';
|
import 'package:opencanteen/okna/jidelnicek.dart';
|
||||||
|
import 'package:opencanteen/util.dart';
|
||||||
|
|
||||||
class IOSWelcome extends StatefulWidget {
|
class WelcomePage extends StatefulWidget {
|
||||||
const IOSWelcome({Key? key, required this.canteen}) : super(key: key);
|
const WelcomePage({Key? key, required this.canteen}) : super(key: key);
|
||||||
|
|
||||||
final Canteen canteen;
|
final Canteen canteen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<IOSWelcome> createState() => _IOSWelcomeState();
|
State<WelcomePage> createState() => _WelcomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IOSWelcomeState extends State<IOSWelcome> {
|
class _WelcomePageState extends State<WelcomePage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var listPagesViewModel = [
|
var listPagesViewModel = [
|
||||||
|
@ -68,8 +69,7 @@ class _IOSWelcomeState extends State<IOSWelcome> {
|
||||||
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) => IOSJidelnicek(canteen: widget.canteen)),
|
|
||||||
(route) => false);
|
(route) => false);
|
||||||
},
|
},
|
||||||
),
|
),
|
18
lib/pw/platformbutton.dart
Normal file
18
lib/pw/platformbutton.dart
Normal 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));
|
||||||
|
}
|
30
lib/pw/platformdialog.dart
Normal file
30
lib/pw/platformdialog.dart
Normal 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
54
lib/pw/platformfield.dart
Normal 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,
|
||||||
|
);
|
||||||
|
}
|
28
lib/pw/platformswitch.dart
Normal file
28
lib/pw/platformswitch.dart
Normal 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,
|
||||||
|
);
|
||||||
|
}
|
22
lib/pw/platformwidget.dart
Normal file
22
lib/pw/platformwidget.dart
Normal 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);
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
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:opencanteen/okna/android/burza.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:opencanteen/okna/android/jidelnicek.dart';
|
import 'package:opencanteen/okna/burza.dart';
|
||||||
import 'package:opencanteen/okna/ios/burza.dart';
|
import 'package:opencanteen/okna/jidelnicek.dart';
|
||||||
import 'package:opencanteen/okna/ios/jidelnicek.dart';
|
|
||||||
import 'lang/lang.dart';
|
import 'lang/lang.dart';
|
||||||
|
|
||||||
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
|
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
|
||||||
|
@ -30,11 +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) => (Platform.isAndroid)
|
|
||||||
? AndroidBurza(canteen: canteen)
|
|
||||||
: IOSBurza(canteen: canteen),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -53,11 +49,9 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
|
||||||
leading: const Icon(Icons.home),
|
leading: const Icon(Icons.home),
|
||||||
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) => (Platform.isAndroid)
|
),
|
||||||
? AndroidJidelnicek(canteen: canteen)
|
|
||||||
: IOSJidelnicek(canteen: canteen))),
|
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.store),
|
leading: const Icon(Icons.store),
|
||||||
|
@ -72,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);
|
||||||
|
|
342
pubspec.lock
342
pubspec.lock
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
Reference in a new issue