opencanteen/lib/util.dart

103 lines
3 KiB
Dart
Raw Normal View History

2022-12-12 16:48:19 +01:00
import 'dart:io';
2022-04-04 20:22:30 +02:00
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
2022-12-12 16:48:19 +01:00
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';
2022-05-15 16:59:55 +02:00
import 'lang/lang.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(
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(
2022-12-12 16:48:19 +01:00
builder: (context) => (Platform.isAndroid)
? AndroidBurza(canteen: canteen)
: IOSBurza(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(
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(
2022-12-12 16:48:19 +01:00
builder: (c) => (Platform.isAndroid)
? AndroidJidelnicek(canteen: canteen)
: IOSJidelnicek(canteen: canteen))),
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": ""}
];