From b14e8c8ea2550b7e7715dc821a8d093e379c6784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sat, 4 Jul 2026 23:54:50 +0200 Subject: [PATCH] improved timetable date range calculation to ensure the current week remains accessible during holiday gaps or when persisted bounds are stale, and updated holiday labels to prioritize long names over short names in the calendar view. --- .../widgets/special_regions_builder.dart | 2 +- .../widgets/timetable_calendar_view.dart | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/view/pages/timetable/widgets/special_regions_builder.dart b/lib/view/pages/timetable/widgets/special_regions_builder.dart index 79a764a..1b188f1 100644 --- a/lib/view/pages/timetable/widgets/special_regions_builder.dart +++ b/lib/view/pages/timetable/widgets/special_regions_builder.dart @@ -83,7 +83,7 @@ class SpecialRegionsBuilder { final day = startDay.addDays(i); final key = _dayKey(day); byDay.putIfAbsent(key, () => _HolidayDay(day, [])).names.add( - holiday.shortName, + holiday.longName.isNotEmpty ? holiday.longName : holiday.shortName, ); } } diff --git a/lib/view/pages/timetable/widgets/timetable_calendar_view.dart b/lib/view/pages/timetable/widgets/timetable_calendar_view.dart index 203a739..093e996 100644 --- a/lib/view/pages/timetable/widgets/timetable_calendar_view.dart +++ b/lib/view/pages/timetable/widgets/timetable_calendar_view.dart @@ -167,10 +167,24 @@ class TimetableCalendarViewState extends State { ) ? todayMonday.addDays(_maxWeeksForward * 7 + 6) : effectiveMax; + // When the resulting range does not cover the current week — the summer gap + // between two school years, or a stale persisted bound — fall back to the + // full fixed window around today. Otherwise the PageView clamps the initial + // page to the last week before the holidays (hiding the "Schulfrei" region) + // and forward scrolling collapses to the current week only. + final currentWeekEnd = todayMonday.addDays(DateTime.daysPerWeek - 1); + final outsideRange = + cappedMax.isBefore(todayMonday) || cappedMin.isAfter(currentWeekEnd); + final finalMin = outsideRange + ? todayMonday.subtractDays(_maxWeeksBack * 7) + : cappedMin; + final finalMax = outsideRange + ? todayMonday.addDays(_maxWeeksForward * 7 + 6) + : cappedMax; final daysToMonday = - (DateTime.monday - cappedMin.weekday) % DateTime.daysPerWeek; - final mondayMin = cappedMin.addDays(daysToMonday); - return (mondayMin, cappedMax); + (DateTime.monday - finalMin.weekday) % DateTime.daysPerWeek; + final mondayMin = finalMin.addDays(daysToMonday); + return (mondayMin, finalMax); } static DateTime _mondayOf(DateTime d) {