This repository has been archived on 2024-07-21. You can view files and clone it, but cannot push or open issues or pull requests.
opencanteen/lib/util.dart

98 lines
2.8 KiB
Dart
Raw Normal View History

2022-04-04 20:22:30 +02:00
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
2022-04-05 19:48:14 +02:00
import 'package:opencanteen/okna/burza.dart';
2022-04-04 20:22:30 +02:00
2022-05-15 16:59:55 +02:00
import 'lang/lang.dart';
2022-04-04 20:22:30 +02:00
import 'okna/jidelnicek.dart';
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p,
FlutterLocalNotificationsPlugin n) {
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(
child: Text(Languages.of(context)!.appName),
2022-04-04 20:22:30 +02:00
),
ListTile(
selected: true,
2022-05-15 16:59:55 +02:00
title: Text(Languages.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),
2022-05-15 16:59:55 +02:00
title: Text(Languages.of(context)!.exchange),
2022-04-05 19:48:14 +02:00
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BurzaPage(canteen: canteen, n: n),
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(
child: Text(Languages.of(context)!.appName),
2022-04-05 19:48:14 +02:00
),
ListTile(
leading: const Icon(Icons.home),
2022-05-15 16:59:55 +02:00
title: Text(Languages.of(context)!.home),
2022-04-05 19:48:14 +02:00
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (c) => JidelnicekPage(canteen: canteen, n: n))),
2022-04-05 19:48:14 +02:00
),
ListTile(
leading: const Icon(Icons.store),
selected: true,
2022-05-15 16:59:55 +02:00
title: Text(Languages.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;
}
class OfflineJidlo {
String nazev;
String varianta;
bool objednano;
double cena;
bool naBurze;
DateTime den;
OfflineJidlo(
{required this.nazev,
required this.varianta,
required this.objednano,
required this.cena,
required this.naBurze,
required this.den});
}
/// Vytvoří [DateTime] z [TimeOfDay]
DateTime casNaDate(TimeOfDay c) {
var now = DateTime.now();
return DateTime.parse(
"${now.year}-${(now.month < 10 ? "0" : "") + now.month.toString()}-${(now.day < 10 ? "0" : "") + now.day.toString()} ${(c.hour < 10 ? "0" : "") + c.hour.toString()}:${(c.minute < 10 ? "0" : "") + c.minute.toString()}:00");
}
List<Map<String, String>> instance = [
{"name": "SŠTE Brno, Olomoucká", "url": "https://stravovani.sstebrno.cz"},
{"name": "Jiné", "url": ""}
];