implemented DST-safe date arithmetic with new addDays and subtractDays extensions, updated timetable state to reset view and scroll boundaries on initialization to prevent stale views, added hard caps to calendar navigation, and updated version to 1.0.3+52
This commit is contained in:
@@ -23,12 +23,12 @@ class SpecialRegionsBuilder {
|
||||
|
||||
List<TimeRegion> build() {
|
||||
final rangeStart = DateTime.now()
|
||||
.subtract(const Duration(days: 14))
|
||||
.subtractDays(14)
|
||||
.nextWeekday(DateTime.monday);
|
||||
// Far enough out to cover comfortable scrolling without rebuilding;
|
||||
// Syncfusion only paints regions that intersect the visible window so
|
||||
// the extra entries don't hurt rendering cost.
|
||||
final rangeEnd = DateTime.now().add(const Duration(days: 180));
|
||||
final rangeEnd = DateTime.now().addDays(180);
|
||||
|
||||
final holidayRegions = _buildHolidayRegions().toList();
|
||||
final holidayDays = holidayRegions
|
||||
@@ -42,11 +42,7 @@ class SpecialRegionsBuilder {
|
||||
// explicit per-day regions and just skipping holidays is robust.
|
||||
final breakPeriods = schedule.periods.where((p) => p.isBreak).toList();
|
||||
final breakRegions = <TimeRegion>[];
|
||||
for (
|
||||
var day = rangeStart;
|
||||
!day.isAfter(rangeEnd);
|
||||
day = day.add(const Duration(days: 1))
|
||||
) {
|
||||
for (var day = rangeStart; !day.isAfter(rangeEnd); day = day.addDays(1)) {
|
||||
if (holidayDays.contains(_dayKey(day))) continue;
|
||||
for (final p in breakPeriods) {
|
||||
final start = day.copyWith(
|
||||
@@ -77,7 +73,7 @@ class SpecialRegionsBuilder {
|
||||
// otherwise be skipped.
|
||||
final dayCount = endDay.difference(startDay).inDays + 1;
|
||||
for (var i = 0; i < dayCount; i++) {
|
||||
final day = startDay.add(Duration(days: i));
|
||||
final day = startDay.addDays(i);
|
||||
final key = _dayKey(day);
|
||||
byDay.putIfAbsent(key, () => _HolidayDay(day, [])).names.add(
|
||||
holiday.name,
|
||||
|
||||
Reference in New Issue
Block a user