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:
@@ -83,7 +83,7 @@ class SpecialRegionsBuilder {
|
|||||||
final day = startDay.addDays(i);
|
final day = startDay.addDays(i);
|
||||||
final key = _dayKey(day);
|
final key = _dayKey(day);
|
||||||
byDay.putIfAbsent(key, () => _HolidayDay(day, [])).names.add(
|
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)
|
? todayMonday.addDays(_maxWeeksForward * 7 + 6)
|
||||||
: effectiveMax;
|
: 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 =
|
final daysToMonday =
|
||||||
(DateTime.monday - cappedMin.weekday) % DateTime.daysPerWeek;
|
(DateTime.monday - finalMin.weekday) % DateTime.daysPerWeek;
|
||||||
final mondayMin = cappedMin.addDays(daysToMonday);
|
final mondayMin = finalMin.addDays(daysToMonday);
|
||||||
return (mondayMin, cappedMax);
|
return (mondayMin, finalMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DateTime _mondayOf(DateTime d) {
|
static DateTime _mondayOf(DateTime d) {
|
||||||
|
|||||||
Reference in New Issue
Block a user