2021-12-13 13:39:06 +01:00
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
import 'package:meincantor/const.dart';
|
|
|
|
import 'package:meincantor/raumuebersicht.dart';
|
|
|
|
import 'package:meincantor/schulbibliothek.dart';
|
|
|
|
import 'package:meincantor/schulcomputer.dart';
|
|
|
|
import 'package:meincantor/schuelerzeitung.dart';
|
|
|
|
import 'package:meincantor/Settings/dashboard.dart';
|
2021-11-16 19:41:35 +01:00
|
|
|
|
2021-12-13 13:39:06 +01:00
|
|
|
import 'package:meincantor/main.dart';
|
|
|
|
import 'package:meincantor/networking.dart';
|
|
|
|
import 'package:meincantor/login.dart';
|
2021-11-16 19:41:35 +01:00
|
|
|
|
2021-09-14 20:55:58 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2021-12-13 13:39:06 +01:00
|
|
|
import 'package:intl/intl.dart';
|
2021-09-14 20:55:58 +02:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2021-11-06 11:01:44 +01:00
|
|
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
2021-09-14 20:55:58 +02:00
|
|
|
|
2021-12-13 13:39:06 +01:00
|
|
|
import 'news.dart';
|
|
|
|
|
2021-09-14 20:55:58 +02:00
|
|
|
class Dashboard extends StatefulWidget {
|
|
|
|
const Dashboard({Key? key, this.restorationId}) : super(key: key);
|
|
|
|
|
|
|
|
final String? restorationId;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _DashboardState();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<String> getSettingsString(String key) async {
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
String? value = prefs.getString(key);
|
|
|
|
if (value == null || value.isEmpty) {
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2021-11-06 11:01:44 +01:00
|
|
|
Widget buildSettingsString(String key, TextStyle? style) {
|
2021-09-14 20:55:58 +02:00
|
|
|
return FutureBuilder(
|
|
|
|
future: getSettingsString(key),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
return Text(snapshot.data as String, style: style);
|
|
|
|
} else {
|
|
|
|
return (const Center(child: CircularProgressIndicator()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DashboardState extends State<Dashboard> with RestorationMixin {
|
|
|
|
final RestorableInt _currentIndex = RestorableInt(0);
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final drawerElements = ListView(
|
|
|
|
children: [
|
|
|
|
UserAccountsDrawerHeader(
|
2021-11-16 19:41:35 +01:00
|
|
|
accountName: buildSettingsString('name', const TextStyle()),
|
|
|
|
accountEmail: buildSettingsString('user', const TextStyle()),
|
2021-12-13 13:39:06 +01:00
|
|
|
currentAccountPicture: FutureBuilder(
|
|
|
|
future: Future.sync(() async {
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
String? user = prefs.getString("user");
|
|
|
|
if (user == null || user.isEmpty) {
|
|
|
|
user = "";
|
|
|
|
}
|
|
|
|
String? name = prefs.getString("name");
|
|
|
|
if (name == null || name.isEmpty) {
|
|
|
|
name = "";
|
|
|
|
}
|
|
|
|
Map data = {"user": user, "name": name };
|
|
|
|
return data;
|
|
|
|
}),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
// .svg?text=${(snapshot.data! as Map)['name'][0]}
|
|
|
|
String url = "$avatarUrl/${(snapshot.data! as Map)['user']}";
|
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
image: DecorationImage(
|
|
|
|
fit: BoxFit.scaleDown,
|
|
|
|
image: NetworkImage(url)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const CircularProgressIndicator();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
ListTile(
|
|
|
|
title: const Text("Einstellungen"),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
2021-11-16 19:41:35 +01:00
|
|
|
MaterialPageRoute(builder: (context) => const Settings()),
|
2021-09-14 20:55:58 +02:00
|
|
|
);
|
|
|
|
},
|
2021-11-06 11:01:44 +01:00
|
|
|
leading: const Icon(Icons.settings_outlined),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: const Text("Abmelden"),
|
|
|
|
onTap: () async {
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
prefs.setString('api_key', "");
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => Login()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
leading: const Icon(Icons.exit_to_app_outlined),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
var bottomNavBarItems = [
|
|
|
|
const BottomNavigationBarItem(
|
2021-11-06 11:01:44 +01:00
|
|
|
icon: Icon(MdiIcons.homeOutline),
|
2021-09-14 20:55:58 +02:00
|
|
|
label: "Startseite",
|
|
|
|
),
|
|
|
|
const BottomNavigationBarItem(
|
2021-11-16 19:41:35 +01:00
|
|
|
icon: Icon(MdiIcons.timetable), label: "Vertretungsplan"),
|
2021-11-06 11:01:44 +01:00
|
|
|
const BottomNavigationBarItem(
|
2021-11-16 19:41:35 +01:00
|
|
|
icon: Icon(Icons.notifications_outlined), label: "Hinweise"),
|
2021-09-14 20:55:58 +02:00
|
|
|
];
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text("GCG.MeinCantor"),
|
|
|
|
centerTitle: true,
|
|
|
|
),
|
|
|
|
body: _DashboardBottomNavView(
|
|
|
|
key: UniqueKey(), item: bottomNavBarItems[_currentIndex.value]),
|
|
|
|
drawer: Drawer(
|
|
|
|
child: drawerElements,
|
|
|
|
),
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
|
|
showUnselectedLabels: false,
|
|
|
|
items: bottomNavBarItems,
|
|
|
|
currentIndex: _currentIndex.value,
|
|
|
|
onTap: (index) {
|
|
|
|
setState(() {
|
|
|
|
_currentIndex.value = index;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String? get restorationId => widget.restorationId;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
|
|
|
|
registerForRestoration(_currentIndex, 'bottom_navigation_tab_index');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DashboardBottomNavView extends StatelessWidget {
|
|
|
|
const _DashboardBottomNavView({Key? key, required this.item})
|
|
|
|
: super(key: key);
|
|
|
|
final BottomNavigationBarItem item;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (item.label == "Startseite") {
|
|
|
|
double _timeOfDayToDouble(TimeOfDay tod) => tod.hour + tod.minute / 60.0;
|
2021-11-16 19:41:35 +01:00
|
|
|
int lessonCount;
|
2021-09-14 20:55:58 +02:00
|
|
|
if (_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 7, minute: 30))) {
|
|
|
|
lessonCount = 1;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 7, minute: 30)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 8, minute: 20))) {
|
|
|
|
lessonCount = 2;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 8, minute: 20)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 9, minute: 25))) {
|
|
|
|
lessonCount = 3;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 9, minute: 25)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 10, minute: 15))) {
|
|
|
|
lessonCount = 4;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 10, minute: 15)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 11, minute: 30))) {
|
|
|
|
lessonCount = 5;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 11, minute: 30)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 12, minute: 20))) {
|
|
|
|
lessonCount = 6;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 12, minute: 20)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 13, minute: 30))) {
|
|
|
|
lessonCount = 7;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 13, minute: 30)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 14, minute: 20))) {
|
|
|
|
lessonCount = 8;
|
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-11-16 19:41:35 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 14, minute: 20)) &&
|
2021-09-14 20:55:58 +02:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 15, minute: 10))) {
|
|
|
|
lessonCount = 9;
|
2021-11-19 20:12:42 +01:00
|
|
|
} else if (_timeOfDayToDouble(TimeOfDay.now()) >
|
2021-12-13 13:39:06 +01:00
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 15, minute: 10)) &&
|
2021-11-19 20:12:42 +01:00
|
|
|
_timeOfDayToDouble(TimeOfDay.now()) <=
|
|
|
|
_timeOfDayToDouble(const TimeOfDay(hour: 16, minute: 00))) {
|
|
|
|
lessonCount = 10;
|
2021-09-14 20:55:58 +02:00
|
|
|
} else {
|
|
|
|
lessonCount = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
var view = SingleChildScrollView(
|
2021-11-16 19:41:35 +01:00
|
|
|
child: Column(children: [
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
2021-09-14 20:55:58 +02:00
|
|
|
children: [
|
2021-11-16 19:41:35 +01:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(20, 30, 20, 5),
|
|
|
|
child: Text(
|
|
|
|
'Hallo,',
|
|
|
|
style: GoogleFonts.robotoSlab(
|
|
|
|
fontSize: 20,
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: [
|
2021-09-14 20:55:58 +02:00
|
|
|
Padding(
|
2021-11-16 19:41:35 +01:00
|
|
|
padding: const EdgeInsets.fromLTRB(20, 5, 20, 20),
|
|
|
|
child: buildSettingsString(
|
|
|
|
"name",
|
|
|
|
GoogleFonts.robotoSlab(
|
|
|
|
fontSize: 28,
|
|
|
|
fontWeight: FontWeight.w800,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: [
|
2021-11-06 11:01:44 +01:00
|
|
|
Padding(
|
2021-11-16 19:41:35 +01:00
|
|
|
padding: const EdgeInsets.fromLTRB(20, 10, 0, 10),
|
|
|
|
child: Text(
|
|
|
|
'Deine nächste Unterrichtsstunde:',
|
|
|
|
style: GoogleFonts.robotoSlab(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w100,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(20, 20, 20, 10),
|
|
|
|
child: buildTodayClassTimetableLesson(lessonCount),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(20, 20, 20, 10),
|
|
|
|
child: Wrap(
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => const SZ()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: ListTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
|
|
|
child: Icon(
|
|
|
|
MdiIcons.newspaper,
|
|
|
|
color: Palette.accent,
|
|
|
|
size: 48,
|
|
|
|
),
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
subtitle: Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
'Schülerzeitung',
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
)),
|
|
|
|
),
|
2021-12-13 13:39:06 +01:00
|
|
|
width: 170,
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
|
|
|
SizedBox(
|
2021-12-13 13:39:06 +01:00
|
|
|
width: 170,
|
2021-11-16 19:41:35 +01:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => const SB()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: ListTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
|
|
|
child: Icon(
|
|
|
|
MdiIcons.libraryShelves,
|
|
|
|
color: Palette.accent,
|
|
|
|
size: 48,
|
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
subtitle: Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
'Schulbibliothek',
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
2021-12-13 13:39:06 +01:00
|
|
|
width: 170,
|
2021-11-16 19:41:35 +01:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => const SC()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: ListTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
|
|
|
child: Icon(
|
|
|
|
MdiIcons.laptop,
|
|
|
|
color: Palette.accent,
|
|
|
|
size: 48,
|
2021-11-06 11:01:44 +01:00
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
subtitle: Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
'Schulcomputer',
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
2021-12-13 13:39:06 +01:00
|
|
|
width: 170,
|
2021-11-16 19:41:35 +01:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const RoomOverview()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: ListTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
|
|
|
child: Icon(
|
|
|
|
MdiIcons.door,
|
|
|
|
color: Palette.accent,
|
|
|
|
size: 48,
|
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
subtitle: Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
'Raumübersicht',
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
)),
|
2021-09-14 20:55:58 +02:00
|
|
|
),
|
2021-12-13 13:39:06 +01:00
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 170,
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => const News()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: ListTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
|
|
|
|
child: Icon(
|
|
|
|
MdiIcons.newspaperVariantOutline,
|
|
|
|
color: Palette.accent,
|
|
|
|
size: 48,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Center(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
|
|
|
child: Text(
|
|
|
|
'Aktuelles',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
),
|
2021-11-16 19:41:35 +01:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
);
|
2021-09-14 20:55:58 +02:00
|
|
|
return view;
|
|
|
|
} else if (item.label == "Vertretungsplan") {
|
|
|
|
return LayoutBuilder(builder: (context, constraints) {
|
|
|
|
double widgetWidth = constraints.maxWidth;
|
2021-11-16 19:41:35 +01:00
|
|
|
|
|
|
|
int factor;
|
2021-09-14 20:55:58 +02:00
|
|
|
|
|
|
|
if (widgetWidth <= 600) {
|
|
|
|
factor = 1;
|
|
|
|
} else if (widgetWidth <= 1400) {
|
|
|
|
factor = 2;
|
|
|
|
} else if (widgetWidth <= 2000) {
|
|
|
|
factor = 3;
|
2021-11-16 19:41:35 +01:00
|
|
|
} else {
|
|
|
|
factor = 1;
|
2021-09-14 20:55:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// print(screenType);
|
|
|
|
return Center(
|
|
|
|
child: Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
// minHeight: 500, //minimum height
|
|
|
|
// minWidth: 300, // minimum width
|
|
|
|
//maximum height set to 100% of vertical height
|
|
|
|
maxWidth: MediaQuery.of(context).size.width / factor,
|
|
|
|
//maximum width set to 100% of width
|
|
|
|
),
|
|
|
|
child: DefaultTabController(
|
|
|
|
initialIndex: 0,
|
2021-11-06 11:01:44 +01:00
|
|
|
length: 3,
|
2021-09-14 20:55:58 +02:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
elevation: 0,
|
|
|
|
title: const TabBar(
|
|
|
|
tabs: <Widget>[
|
|
|
|
Tab(
|
|
|
|
text: "Heute",
|
|
|
|
icon: Icon(CupertinoIcons.calendar_today),
|
|
|
|
),
|
2021-11-06 11:01:44 +01:00
|
|
|
Tab(
|
|
|
|
text: "Morgen",
|
|
|
|
icon: Icon(CupertinoIcons.calendar_today),
|
|
|
|
),
|
2021-09-14 20:55:58 +02:00
|
|
|
Tab(
|
|
|
|
text: "Neuster Plan",
|
|
|
|
icon: Icon(CupertinoIcons.calendar),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: TabBarView(
|
|
|
|
children: <Widget>[
|
2021-12-13 13:39:06 +01:00
|
|
|
buildTimetable(
|
|
|
|
fetchClassTimetable(
|
|
|
|
"/${DateFormat("yyyyMMdd").format(DateTime.now())}"),
|
|
|
|
"Vertretungsplan für heute"),
|
|
|
|
buildTimetable(
|
|
|
|
fetchClassTimetable(
|
|
|
|
"/${DateFormat("yyyyMMdd").format(DateTime.now().add(const Duration(days: 1)))}"),
|
|
|
|
"Vertretungsplan für morgen"),
|
|
|
|
buildTimetable(fetchClassTimetable("/latest"),
|
|
|
|
"aktueller Vertretungsplan")
|
2021-09-14 20:55:58 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else {
|
2021-11-06 11:01:44 +01:00
|
|
|
return const Center(child: Text("Derzeit nichts hier..."));
|
2021-09-14 20:55:58 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-16 19:41:35 +01:00
|
|
|
}
|