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.

This commit is contained in:
2026-07-04 23:54:50 +02:00
parent 74a2ddd17f
commit b14e8c8ea2
2 changed files with 18 additions and 4 deletions
@@ -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,
);
}
}
@@ -167,10 +167,24 @@ class TimetableCalendarViewState extends State<TimetableCalendarView> {
)
? 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) {