Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude semantics on outside days when not visible #826

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions lib/src/table_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,6 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> {
}

void _onDayTapped(DateTime day) {
final isOutside = day.month != _focusedDay.value.month;
if (isOutside && _shouldBlockOutsideDays) {
return;
}

if (_isDayDisabled(day)) {
return widget.onDisabledDayTapped?.call(day);
}
Expand All @@ -374,11 +369,6 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> {
}

void _onDayLongPressed(DateTime day) {
final isOutside = day.month != _focusedDay.value.month;
if (isOutside && _shouldBlockOutsideDays) {
return;
}

if (_isDayDisabled(day)) {
return widget.onDisabledDayLongPressed?.call(day);
}
Expand Down Expand Up @@ -556,6 +546,14 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> {
return dowCell;
},
dayBuilder: (context, day, focusedMonth) {
final isOutside = day.month != focusedMonth.month;

if (isOutside && _shouldBlockOutsideDays) {
return ExcludeSemantics(
child: Container(),
);
}

return GestureDetector(
behavior: widget.dayHitTestBehavior,
onTap: () => _onDayTapped(day),
Expand All @@ -570,12 +568,6 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> {
}

Widget _buildCell(DateTime day, DateTime focusedDay) {
final isOutside = day.month != focusedDay.month;

if (isOutside && _shouldBlockOutsideDays) {
return Container();
}

return LayoutBuilder(
builder: (context, constraints) {
final shorterSide = constraints.maxHeight > constraints.maxWidth
Expand Down Expand Up @@ -618,6 +610,7 @@ class _TableCalendarState<T> extends State<TableCalendar<T>> {
final isToday = isSameDay(day, widget.currentDay);
final isDisabled = _isDayDisabled(day);
final isWeekend = _isWeekend(day, weekendDays: widget.weekendDays);
final isOutside = day.month != focusedDay.month;

Widget content = CellContent(
key: ValueKey('CellContent-${day.year}-${day.month}-${day.day}'),
Expand Down