show classname instead of teacher name in teacher timetable view

This commit is contained in:
2026-08-09 12:19:57 +02:00
parent 39c16bd4ea
commit 889d8f67c5
21 changed files with 292 additions and 81 deletions
@@ -28,6 +28,10 @@ class TimetableCalendarView extends StatefulWidget {
final void Function(DateTime start, DateTime end)? onCreateEvent;
final List<CustomTimetableEvent> customEvents;
/// True for teacher plans — tiles then show the class instead of the
/// teacher name (see [TimetableAppointmentFactory.showClassInsteadOfTeacher]).
final bool showClassInsteadOfTeacher;
const TimetableCalendarView({
super.key,
required this.state,
@@ -35,6 +39,7 @@ class TimetableCalendarView extends StatefulWidget {
required this.onAppointmentTap,
this.onCreateEvent,
this.customEvents = const [],
this.showClassInsteadOfTeacher = false,
});
@override
@@ -46,9 +51,9 @@ class TimetableCalendarViewState extends State<TimetableCalendarView> {
GlobalKey<CustomWorkWeekCalendarState>();
List<Appointment>? _cachedAppointments;
int? _lastDataVersion;
TimetableSettings? _lastTimetableSettings;
List<CustomTimetableEvent>? _lastCustomEvents;
// TimetableSettings and List define no `==`, so record equality degrades to
// the same identity checks the cache always used.
(int, TimetableSettings, List<CustomTimetableEvent>, bool)? _cacheKey;
DateTime _initialDisplayDate() => DateTime.now().addDays(2);
@@ -63,15 +68,16 @@ class TimetableCalendarViewState extends State<TimetableCalendarView> {
.watch<SettingsCubit>()
.val()
.timetableSettings;
if (_cachedAppointments != null &&
_lastDataVersion == state.dataVersion &&
identical(_lastTimetableSettings, timetableSettings) &&
identical(_lastCustomEvents, widget.customEvents)) {
final key = (
state.dataVersion,
timetableSettings,
widget.customEvents,
widget.showClassInsteadOfTeacher,
);
if (_cachedAppointments != null && _cacheKey == key) {
return _cachedAppointments!;
}
_lastDataVersion = state.dataVersion;
_lastTimetableSettings = timetableSettings;
_lastCustomEvents = widget.customEvents;
_cacheKey = key;
return _cachedAppointments = TimetableAppointmentFactory(
lessons: state.getAllKnownLessons().toList(),
@@ -80,6 +86,7 @@ class TimetableCalendarViewState extends State<TimetableCalendarView> {
holidays: state.schoolHolidays?.result ?? const [],
settings: timetableSettings,
now: DateTime.now(),
showClassInsteadOfTeacher: widget.showClassInsteadOfTeacher,
).build();
}