Skip to content

Commit

Permalink
fix: 🐛 fix full day event on tap with on tap callback in full day eve…
Browse files Browse the repository at this point in the history
…nt view #260
  • Loading branch information
apurva010 committed May 7, 2024
1 parent 1770d66 commit ad3e482
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- # [1.1.1] (UnReleased)
- Added event tap, double tap and long press for full day event in day and week view. [#260](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/260)
- Added support for double tapping gestures on any event in day, week, and month view. [#195](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/195)
- Added support for horizontal scroll physics of week and month view page. [#314](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/314)
- Fixed issue related to the live time indicator is that it is not in the correct position when startHour is set for the week and day view. [#346](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/346)
Expand Down
14 changes: 12 additions & 2 deletions lib/src/components/day_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ class FullDayEventView<T> extends StatelessWidget {
this.titleStyle,
this.onEventTap,
required this.date,
this.onEventDoubleTap,
this.onEventLongPress,
}) : super(key: key);

/// Constraints for view
Expand All @@ -217,7 +219,13 @@ class FullDayEventView<T> extends StatelessWidget {
final TextStyle? titleStyle;

/// Called when user taps on event tile.
final TileTapCallback<T>? onEventTap;
final CellTapCallback<T>? onEventTap;

/// Called when user long press on event tile.
final CellTapCallback<T>? onEventLongPress;

/// Called when user double taps on any event tile.
final CellTapCallback<T>? onEventDoubleTap;

/// Defines date for which events will be displayed.
final DateTime date;
Expand All @@ -231,7 +239,9 @@ class FullDayEventView<T> extends StatelessWidget {
padding: padding ?? EdgeInsets.zero,
shrinkWrap: true,
itemBuilder: (context, index) => InkWell(
onTap: () => onEventTap?.call(events[index], date),
onLongPress: () => onEventLongPress?.call(events, date),
onTap: () => onEventTap?.call(events, date),
onDoubleTap: () => onEventDoubleTap?.call(events, date),
child: itemView?.call(events[index]) ??
Container(
margin: const EdgeInsets.all(5.0),
Expand Down
11 changes: 5 additions & 6 deletions lib/src/components/month_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ class FilledCell<T extends Object?> extends StatelessWidget {
children: List.generate(
events.length,
(index) => GestureDetector(
onTap: () =>
onTileTap?.call(events[index], events[index].date),
onLongPress: () => onTileLongTap?.call(
events[index], events[index].date),
onDoubleTap: () => onTileDoubleTap?.call(
events[index], events[index].date),
onTap: () => onTileTap?.call(events[index], date),
onLongPress: () =>
onTileLongTap?.call(events[index], date),
onDoubleTap: () =>
onTileDoubleTap?.call(events[index], date),
child: Container(
decoration: BoxDecoration(
color: events[index].color,
Expand Down
8 changes: 7 additions & 1 deletion lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,13 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {

Widget _defaultFullDayEventBuilder(
List<CalendarEventData<T>> events, DateTime date) =>
FullDayEventView(events: events, date: date);
FullDayEventView(
events: events,
date: date,
onEventTap: widget.onEventTap,
onEventDoubleTap: widget.onEventDoubleTap,
onEventLongPress: widget.onEventLongTap,
);

HourLinePainter _defaultHourLinePainter(
Color lineColor,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
events: events,
boxConstraints: BoxConstraints(maxHeight: 65),
date: dateTime,
onEventTap: widget.onEventTap,
onEventDoubleTap: widget.onEventDoubleTap,
onEventLongPress: widget.onEventLongTap,
);
}

Expand Down

0 comments on commit ad3e482

Please sign in to comment.