Added explicit timetable objects with defined types

This commit is contained in:
2023-06-19 10:54:23 +02:00
parent 3d6e0cec0e
commit b7bb3805a2
11 changed files with 235 additions and 171 deletions

View File

@ -26,13 +26,13 @@ class AppointmentDetails {
GetRoomsResponseObject room;
try {
subject = webuntisData.getSubjectsResponse.result.firstWhere((subject) => subject.id == timetableData.su[0]['id']);
subject = webuntisData.getSubjectsResponse.result.firstWhere((subject) => subject.id == timetableData.su[0].id);
} catch(e) {
subject = GetSubjectsResponseObject(0, "?", "Lesefehler", "?", true);
}
try {
room = webuntisData.getRoomsResponse.result.firstWhere((room) => room.id == timetableData.ro[0]['id']);
room = webuntisData.getRoomsResponse.result.firstWhere((room) => room.id == timetableData.ro[0].id);
} catch(e) {
room = GetRoomsResponseObject(0, "?", "Lesefehler", true, "?");
}
@ -72,7 +72,7 @@ class AppointmentDetails {
),
ListTile(
leading: const Icon(Icons.person),
title: Text("Lehrkraft: (${timetableData.te[0]['name']}) ${timetableData.te[0]['longname']}"),
title: Text("Lehrkraft: (${timetableData.te[0].name}) ${timetableData.te[0].longname}"),
trailing: IconButton(
icon: const Icon(Icons.textsms_outlined),
onPressed: () {
@ -86,7 +86,7 @@ class AppointmentDetails {
),
ListTile(
leading: const Icon(Icons.people),
title: Text("Klasse(n): ${timetableData.kl.map((e) => e['name']).join(", ")}"),
title: Text("Klasse(n): ${timetableData.kl.map((e) => e.name).join(", ")}"),
),
DebugTile(timetableData.toJson()).asTile(context),
],

View File

@ -192,11 +192,11 @@ class _TimetableState extends State<Timetable> {
id: element,
startTime: startTime,
endTime: endTime,
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0]['id']).alternateName,
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).alternateName,
location: ""
"${rooms.result.firstWhere((room) => room.id == element.ro[0]['id']).name}"
"${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}"
"\n"
"${element.te.first['longname']}",
"${element.te.first.longname}",
notes: element.activityType,
color: _getEventColor(element.code, startTime, endTime),
);