|
...
|
...
|
@@ -409,7 +409,7 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _updateFocusOnTapJumpYear(DateTime day) {
|
|
|
|
void _updateFocusOnTapJumpYear(DateTime day) {
|
|
|
|
if (widget.pageJumpingEnabled) {
|
|
|
|
_focusedDay.value = day;
|
|
|
|
return;
|
|
...
|
...
|
@@ -468,10 +468,10 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> { |
|
|
|
_focusedDay.value.month,
|
|
|
|
_focusedDay.value.day,
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
_updateFocusOnTapJumpYear(focusedDay);
|
|
|
|
widget.onPageChanged?.call(focusedDay);
|
|
|
|
_pageController.previousPage(
|
|
|
|
_pageController.previousPage(
|
|
|
|
duration: widget.pageAnimationDuration,
|
|
|
|
curve: widget.pageAnimationCurve,
|
|
|
|
);
|
|
...
|
...
|
@@ -528,92 +528,97 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> { |
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
flex: widget.shouldFillViewport ? 1 : 0,
|
|
|
|
child: TableCalendarBase(
|
|
|
|
onCalendarCreated: (pageController) {
|
|
|
|
_pageController = pageController;
|
|
|
|
widget.onCalendarCreated?.call(pageController);
|
|
|
|
},
|
|
|
|
focusedDay: _focusedDay.value,
|
|
|
|
calendarFormat: widget.calendarFormat,
|
|
|
|
availableGestures: widget.availableGestures,
|
|
|
|
firstDay: widget.firstDay,
|
|
|
|
lastDay: widget.lastDay,
|
|
|
|
startingDayOfWeek: widget.startingDayOfWeek,
|
|
|
|
dowDecoration: widget.daysOfWeekStyle.decoration,
|
|
|
|
rowDecoration: widget.calendarStyle.rowDecoration,
|
|
|
|
tableBorder: widget.calendarStyle.tableBorder,
|
|
|
|
tablePadding: widget.calendarStyle.tablePadding,
|
|
|
|
dowVisible: widget.daysOfWeekVisible,
|
|
|
|
dowHeight: widget.daysOfWeekHeight,
|
|
|
|
rowHeight: widget.rowHeight,
|
|
|
|
formatAnimationDuration: widget.formatAnimationDuration,
|
|
|
|
formatAnimationCurve: widget.formatAnimationCurve,
|
|
|
|
pageAnimationEnabled: widget.pageAnimationEnabled,
|
|
|
|
pageAnimationDuration: widget.pageAnimationDuration,
|
|
|
|
pageAnimationCurve: widget.pageAnimationCurve,
|
|
|
|
availableCalendarFormats: widget.availableCalendarFormats,
|
|
|
|
simpleSwipeConfig: widget.simpleSwipeConfig,
|
|
|
|
sixWeekMonthsEnforced: widget.sixWeekMonthsEnforced,
|
|
|
|
onVerticalSwipe: _swipeCalendarFormat,
|
|
|
|
onPageChanged: (focusedDay) {
|
|
|
|
_focusedDay.value = focusedDay;
|
|
|
|
widget.onPageChanged?.call(focusedDay);
|
|
|
|
},
|
|
|
|
weekNumbersVisible: widget.weekNumbersVisible,
|
|
|
|
weekNumberBuilder: (BuildContext context, DateTime day) {
|
|
|
|
final weekNumber = _calculateWeekNumber(day);
|
|
|
|
final cell = widget.calendarBuilders.weekNumberBuilder
|
|
|
|
?.call(context, weekNumber);
|
|
|
|
|
|
|
|
return cell ??
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
weekNumber.toString(),
|
|
|
|
style: widget.calendarStyle.weekNumberTextStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
dowBuilder: (BuildContext context, DateTime day) {
|
|
|
|
Widget? dowCell =
|
|
|
|
widget.calendarBuilders.dowBuilder?.call(context, day);
|
|
|
|
|
|
|
|
if (dowCell == null) {
|
|
|
|
final weekdayString = widget.daysOfWeekStyle.dowTextFormatter
|
|
|
|
?.call(day, widget.locale) ??
|
|
|
|
DateFormat.E(widget.locale).format(day);
|
|
|
|
|
|
|
|
final isWeekend =
|
|
|
|
_isWeekend(day, weekendDays: widget.weekendDays);
|
|
|
|
|
|
|
|
dowCell = Center(
|
|
|
|
child: ExcludeSemantics(
|
|
|
|
child: Text(
|
|
|
|
weekdayString,
|
|
|
|
style: isWeekend
|
|
|
|
? widget.daysOfWeekStyle.weekendStyle
|
|
|
|
: widget.daysOfWeekStyle.weekdayStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dowCell;
|
|
|
|
},
|
|
|
|
dayBuilder: (context, day, focusedMonth) {
|
|
|
|
return GestureDetector(
|
|
|
|
behavior: widget.dayHitTestBehavior,
|
|
|
|
onTap: () => _onDayTapped(day),
|
|
|
|
onLongPress: () => _onDayLongPressed(day),
|
|
|
|
child: _buildCell(day, focusedMonth),
|
|
|
|
ValueListenableBuilder<DateTime>(
|
|
|
|
valueListenable: _focusedDay,
|
|
|
|
builder: (context, value, _) {
|
|
|
|
return Flexible(
|
|
|
|
flex: widget.shouldFillViewport ? 1 : 0,
|
|
|
|
child: TableCalendarBase(
|
|
|
|
onCalendarCreated: (pageController) {
|
|
|
|
_pageController = pageController;
|
|
|
|
widget.onCalendarCreated?.call(pageController);
|
|
|
|
},
|
|
|
|
focusedDay: _focusedDay.value,
|
|
|
|
calendarFormat: widget.calendarFormat,
|
|
|
|
availableGestures: widget.availableGestures,
|
|
|
|
firstDay: widget.firstDay,
|
|
|
|
lastDay: widget.lastDay,
|
|
|
|
startingDayOfWeek: widget.startingDayOfWeek,
|
|
|
|
dowDecoration: widget.daysOfWeekStyle.decoration,
|
|
|
|
rowDecoration: widget.calendarStyle.rowDecoration,
|
|
|
|
tableBorder: widget.calendarStyle.tableBorder,
|
|
|
|
tablePadding: widget.calendarStyle.tablePadding,
|
|
|
|
dowVisible: widget.daysOfWeekVisible,
|
|
|
|
dowHeight: widget.daysOfWeekHeight,
|
|
|
|
rowHeight: widget.rowHeight,
|
|
|
|
formatAnimationDuration: widget.formatAnimationDuration,
|
|
|
|
formatAnimationCurve: widget.formatAnimationCurve,
|
|
|
|
pageAnimationEnabled: widget.pageAnimationEnabled,
|
|
|
|
pageAnimationDuration: widget.pageAnimationDuration,
|
|
|
|
pageAnimationCurve: widget.pageAnimationCurve,
|
|
|
|
availableCalendarFormats: widget.availableCalendarFormats,
|
|
|
|
simpleSwipeConfig: widget.simpleSwipeConfig,
|
|
|
|
sixWeekMonthsEnforced: widget.sixWeekMonthsEnforced,
|
|
|
|
onVerticalSwipe: _swipeCalendarFormat,
|
|
|
|
onPageChanged: (focusedDay) {
|
|
|
|
_focusedDay.value = focusedDay;
|
|
|
|
widget.onPageChanged?.call(focusedDay);
|
|
|
|
},
|
|
|
|
weekNumbersVisible: widget.weekNumbersVisible,
|
|
|
|
weekNumberBuilder: (BuildContext context, DateTime day) {
|
|
|
|
final weekNumber = _calculateWeekNumber(day);
|
|
|
|
final cell = widget.calendarBuilders.weekNumberBuilder
|
|
|
|
?.call(context, weekNumber);
|
|
|
|
|
|
|
|
return cell ??
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
weekNumber.toString(),
|
|
|
|
style: widget.calendarStyle.weekNumberTextStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
dowBuilder: (BuildContext context, DateTime day) {
|
|
|
|
Widget? dowCell =
|
|
|
|
widget.calendarBuilders.dowBuilder?.call(context, day);
|
|
|
|
|
|
|
|
if (dowCell == null) {
|
|
|
|
final weekdayString = widget
|
|
|
|
.daysOfWeekStyle.dowTextFormatter
|
|
|
|
?.call(day, widget.locale) ??
|
|
|
|
DateFormat.E(widget.locale).format(day);
|
|
|
|
|
|
|
|
final isWeekend =
|
|
|
|
_isWeekend(day, weekendDays: widget.weekendDays);
|
|
|
|
|
|
|
|
dowCell = Center(
|
|
|
|
child: ExcludeSemantics(
|
|
|
|
child: Text(
|
|
|
|
weekdayString,
|
|
|
|
style: isWeekend
|
|
|
|
? widget.daysOfWeekStyle.weekendStyle
|
|
|
|
: widget.daysOfWeekStyle.weekdayStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dowCell;
|
|
|
|
},
|
|
|
|
dayBuilder: (context, day, focusedMonth) {
|
|
|
|
return GestureDetector(
|
|
|
|
behavior: widget.dayHitTestBehavior,
|
|
|
|
onTap: () => _onDayTapped(day),
|
|
|
|
onLongPress: () => _onDayLongPressed(day),
|
|
|
|
child: _buildCell(day, focusedMonth),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
...
|
...
|
@@ -819,7 +824,7 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool _isBeforeYear(DateTime day, DateTime month) {
|
|
|
|
bool _isBeforeYear(DateTime day, DateTime month) {
|
|
|
|
if (day.year == month.year) {
|
|
|
|
return day.month < month.month;
|
|
|
|
} else {
|
...
|
...
|
|