fix: přepsat Platform UI a zmenit RefreshIndicator #36

Merged
hernik merged 3 commits from better-ui into main 2023-01-28 14:42:12 +01:00
14 changed files with 41 additions and 1666 deletions
Showing only changes of commit 26c6e4604e - Show all commits

View file

@ -7,8 +7,7 @@ import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'package:opencanteen/lang/lang_cz.dart';
import 'package:opencanteen/loginmanager.dart';
import 'package:canteenlib/canteenlib.dart';
import 'package:opencanteen/okna/android/login.dart';
import 'package:opencanteen/okna/ios/login.dart';
import 'package:opencanteen/okna/login.dart';
import 'package:opencanteen/util.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:intl/intl.dart';
@ -140,7 +139,7 @@ class MyApp extends StatelessWidget {
brightness: Brightness.dark,
primarySwatch: Colors.purple,
),
home: (Platform.isAndroid) ? const AndroidLogin() : const IOSLogin(),
home: const LoginPage(),
);
}
}

View file

@ -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);
},
),
);
}
}

View file

@ -1,18 +1,18 @@
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
import 'package:opencanteen/okna/android/login.dart';
import 'package:opencanteen/okna/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);
class BurzaView extends StatefulWidget {
const BurzaView({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
@override
State<AndroidBurza> createState() => _AndroidBurzaState();
State<BurzaView> createState() => _BurzaViewState();
}
class _AndroidBurzaState extends State<AndroidBurza> {
class _BurzaViewState extends State<BurzaView> {
List<Widget> obsah = [];
double kredit = 0.0;
Future<void> nactiBurzu(BuildContext context) async {
@ -98,7 +98,7 @@ class _AndroidBurzaState extends State<AndroidBurza> {
}).catchError((o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
}

View file

@ -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"),
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)),
);
}
}

View file

@ -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}"),
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"),
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();
});
}
},
),
)
],
),
),
),
),
);
}
}

View file

@ -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);
}
}

View file

@ -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
}
}
}
}
}

View file

@ -1,265 +0,0 @@
import 'dart:convert';
import 'dart:io';
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/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 IOSOfflineJidelnicek extends StatefulWidget {
const IOSOfflineJidelnicek({Key? key}) : super(key: key);
@override
State<IOSOfflineJidelnicek> createState() => _IOSOfflineJidelnicekState();
}
class _IOSOfflineJidelnicekState extends State<IOSOfflineJidelnicek> {
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}"),
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 IOSLogin()));
} 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))
]);
}
}
@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)),
CupertinoButton(
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 IOSLogin()))),
),
);
}
}

View file

@ -4,8 +4,8 @@ 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/okna/login.dart';
import 'package:opencanteen/okna/nastaveni.dart';
import 'package:opencanteen/util.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
@ -14,14 +14,14 @@ 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);
class JidelnicekView extends StatefulWidget {
const JidelnicekView({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
@override
State<AndroidJidelnicek> createState() => _AndroidJidelnicekState();
State<JidelnicekView> createState() => _JidelnicekViewState();
}
class _AndroidJidelnicekState extends State<AndroidJidelnicek> {
class _JidelnicekViewState extends State<JidelnicekView> {
List<Widget> obsah = [const CircularProgressIndicator()];
DateTime den = DateTime.now();
String denTydne = "";
@ -312,7 +312,7 @@ class _AndroidJidelnicekState extends State<AndroidJidelnicek> {
}).catchError((o) {
if (!widget.canteen.prihlasen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
context, MaterialPageRoute(builder: (c) => const LoginPage()));
}
});
}
@ -331,7 +331,7 @@ class _AndroidJidelnicekState extends State<AndroidJidelnicek> {
storage.deleteAll();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (c) => const AndroidLogin()),
MaterialPageRoute(builder: (c) => const LoginPage()),
(route) => false);
},
child: Text(Languages.of(context)!.yes)),

View file

@ -5,7 +5,7 @@ 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 'package:opencanteen/okna/welcome.dart';
import '../../lang/lang.dart';
import '../../loginmanager.dart';
@ -14,13 +14,13 @@ import '../../util.dart';
import 'jidelnicek.dart';
import 'offline_jidelnicek.dart';
class AndroidLogin extends StatefulWidget {
const AndroidLogin({Key? key}) : super(key: key);
class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key);
@override
State<AndroidLogin> createState() => _AndroidLoginState();
State<LoginPage> createState() => _LoginPageState();
}
class _AndroidLoginState extends State<AndroidLogin> {
class _LoginPageState extends State<LoginPage> {
TextEditingController userControl = TextEditingController();
TextEditingController passControl = TextEditingController();
TextEditingController canteenControl = TextEditingController();
@ -75,14 +75,14 @@ class _AndroidLoginState extends State<AndroidLogin> {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (c) => AndroidWelcome(canteen: canteen),
builder: (c) => WelcomePage(canteen: canteen),
),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => AndroidJidelnicek(canteen: canteen),
builder: (context) => JidelnicekView(canteen: canteen),
),
(route) => false);
}
@ -228,7 +228,7 @@ class _AndroidLoginState extends State<AndroidLogin> {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (c) => AndroidWelcome(
builder: (c) => WelcomePage(
canteen: canteen,
)),
(route) => false);
@ -236,7 +236,7 @@ class _AndroidLoginState extends State<AndroidLogin> {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => AndroidJidelnicek(
builder: (context) => JidelnicekView(
canteen: canteen,
)),
(route) => false);

View file

@ -3,7 +3,7 @@ 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/okna/login.dart';
import 'package:opencanteen/util.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
@ -115,7 +115,7 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
const storage = FlutterSecureStorage();
storage.deleteAll();
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (c) => const AndroidLogin()));
context, MaterialPageRoute(builder: (c) => const LoginPage()));
} else if (value == Languages.of(context)!.review) {
launchUrl(Uri.parse("market://details?id=cz.hernikplays.opencanteen"),
mode: LaunchMode.externalApplication);
@ -257,7 +257,7 @@ class _AndroidOfflineJidelnicekState extends State<AndroidOfflineJidelnicek> {
),
),
onRefresh: () => Navigator.pushReplacement(context,
MaterialPageRoute(builder: ((context) => const AndroidLogin()))),
MaterialPageRoute(builder: ((context) => const LoginPage()))),
),
);
}

View file

@ -3,18 +3,18 @@ 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/ios/jidelnicek.dart';
import 'package:opencanteen/okna/jidelnicek.dart';
class IOSWelcome extends StatefulWidget {
const IOSWelcome({Key? key, required this.canteen}) : super(key: key);
class WelcomePage extends StatefulWidget {
const WelcomePage({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
@override
State<IOSWelcome> createState() => _IOSWelcomeState();
State<WelcomePage> createState() => _WelcomePageState();
}
class _IOSWelcomeState extends State<IOSWelcome> {
class _WelcomePageState extends State<WelcomePage> {
@override
Widget build(BuildContext context) {
var listPagesViewModel = [
@ -69,7 +69,7 @@ class _IOSWelcomeState extends State<IOSWelcome> {
if (!mounted) return;
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (c) => IOSJidelnicek(canteen: widget.canteen)),
builder: (c) => JidelnicekView(canteen: widget.canteen)),
(route) => false);
},
),

View file

@ -2,10 +2,8 @@ import 'dart:io';
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
import 'package:opencanteen/okna/android/burza.dart';
import 'package:opencanteen/okna/android/jidelnicek.dart';
import 'package:opencanteen/okna/ios/burza.dart';
import 'package:opencanteen/okna/ios/jidelnicek.dart';
import 'package:opencanteen/okna/burza.dart';
import 'package:opencanteen/okna/jidelnicek.dart';
import 'lang/lang.dart';
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
@ -31,10 +29,7 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => (Platform.isAndroid)
? AndroidBurza(canteen: canteen)
: IOSBurza(canteen: canteen),
),
builder: (context) => BurzaView(canteen: canteen)),
),
),
],
@ -53,11 +48,10 @@ Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
leading: const Icon(Icons.home),
title: Text(Languages.of(context)!.home),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (c) => (Platform.isAndroid)
? AndroidJidelnicek(canteen: canteen)
: IOSJidelnicek(canteen: canteen))),
context,
MaterialPageRoute(
builder: (c) => JidelnicekView(canteen: canteen)),
),
),
ListTile(
leading: const Icon(Icons.store),