2022-12-12 16:48:19 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2022-04-04 20:22:30 +02:00
|
|
|
import 'package:canteenlib/canteenlib.dart';
|
2023-01-28 14:30:54 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2022-04-04 20:22:30 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-01-28 14:30:54 +01:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2022-12-14 20:02:32 +01:00
|
|
|
import 'package:opencanteen/okna/burza.dart';
|
|
|
|
import 'package:opencanteen/okna/jidelnicek.dart';
|
2023-01-28 15:41:17 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2022-04-04 20:22:30 +02:00
|
|
|
|
2022-12-12 16:48:19 +01:00
|
|
|
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
|
2022-04-04 20:22:30 +02:00
|
|
|
Drawer drawer = const Drawer();
|
|
|
|
switch (p) {
|
|
|
|
case 1:
|
|
|
|
// Home page
|
|
|
|
drawer = Drawer(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
2022-05-15 16:59:55 +02:00
|
|
|
DrawerHeader(
|
2023-01-28 15:41:17 +01:00
|
|
|
child: Text(AppLocalizations.of(context)!.appName),
|
2022-04-04 20:22:30 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
selected: true,
|
2023-01-28 15:41:17 +01:00
|
|
|
title: Text(AppLocalizations.of(context)!.home),
|
2022-04-04 20:22:30 +02:00
|
|
|
leading: const Icon(Icons.home),
|
|
|
|
onTap: () => Navigator.pop(context),
|
|
|
|
),
|
2022-04-05 19:48:14 +02:00
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.store),
|
2023-01-28 15:41:17 +01:00
|
|
|
title: Text(AppLocalizations.of(context)!.exchange),
|
2022-04-05 19:48:14 +02:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
2023-01-28 14:30:54 +01:00
|
|
|
platformRouter((context) => BurzaView(canteen: canteen)),
|
2022-04-05 19:48:14 +02:00
|
|
|
),
|
|
|
|
),
|
2022-04-04 20:22:30 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
break;
|
2022-04-05 19:48:14 +02:00
|
|
|
case 3:
|
|
|
|
drawer = Drawer(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
2022-05-15 16:59:55 +02:00
|
|
|
DrawerHeader(
|
2023-01-28 15:41:17 +01:00
|
|
|
child: Text(AppLocalizations.of(context)!.appName),
|
2022-04-05 19:48:14 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.home),
|
2023-01-28 15:41:17 +01:00
|
|
|
title: Text(AppLocalizations.of(context)!.home),
|
2022-04-05 19:48:14 +02:00
|
|
|
onTap: () => Navigator.push(
|
2022-12-14 20:02:32 +01:00
|
|
|
context,
|
2023-01-28 14:30:54 +01:00
|
|
|
platformRouter((c) => MealView(canteen: canteen)),
|
2022-12-14 20:02:32 +01:00
|
|
|
),
|
2022-04-05 19:48:14 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.store),
|
|
|
|
selected: true,
|
2023-01-28 15:41:17 +01:00
|
|
|
title: Text(AppLocalizations.of(context)!.exchange),
|
2022-04-05 19:48:14 +02:00
|
|
|
onTap: () => Navigator.pop(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2022-04-04 20:22:30 +02:00
|
|
|
}
|
|
|
|
return drawer;
|
|
|
|
}
|
2022-05-16 20:26:39 +02:00
|
|
|
|
2023-01-28 14:30:54 +01:00
|
|
|
class OfflineMeal {
|
|
|
|
String name;
|
|
|
|
String variant;
|
|
|
|
bool ordered;
|
|
|
|
double price;
|
|
|
|
bool onExchange;
|
|
|
|
DateTime day;
|
2022-05-16 20:26:39 +02:00
|
|
|
|
2023-01-28 14:30:54 +01:00
|
|
|
OfflineMeal(
|
|
|
|
{required this.name,
|
|
|
|
required this.variant,
|
|
|
|
required this.ordered,
|
|
|
|
required this.price,
|
|
|
|
required this.onExchange,
|
|
|
|
required this.day});
|
2022-05-16 20:26:39 +02:00
|
|
|
}
|
2022-06-08 17:12:44 +02:00
|
|
|
|
2023-01-28 14:30:54 +01:00
|
|
|
/// Parses [DateTime] from [TimeOfDay]
|
|
|
|
DateTime timeToDate(TimeOfDay c) {
|
2022-06-08 17:12:44 +02:00
|
|
|
var now = DateTime.now();
|
|
|
|
return DateTime.parse(
|
|
|
|
"${now.year}-${(now.month < 10 ? "0" : "") + now.month.toString()}-${(now.day < 10 ? "0" : "") + now.day.toString()} ${(c.hour < 10 ? "0" : "") + c.hour.toString()}:${(c.minute < 10 ? "0" : "") + c.minute.toString()}:00");
|
|
|
|
}
|
2022-09-12 16:49:42 +02:00
|
|
|
|
2023-01-28 14:30:54 +01:00
|
|
|
/// List of instances to be used in the dropdown menu
|
2022-09-12 16:49:42 +02:00
|
|
|
List<Map<String, String>> instance = [
|
|
|
|
{"name": "SŠTE Brno, Olomoucká", "url": "https://stravovani.sstebrno.cz"},
|
|
|
|
{"name": "Jiné", "url": ""}
|
|
|
|
];
|
2023-01-28 14:30:54 +01:00
|
|
|
|
|
|
|
/// 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);
|
2023-09-04 20:45:45 +02:00
|
|
|
|
|
|
|
class SettingsManager {
|
|
|
|
bool skipWeekend = false;
|
|
|
|
bool checkOrdered = false;
|
|
|
|
bool saveOffline = false;
|
|
|
|
}
|