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

fix: šŸ› fix full day event on tap with on tap callback in full day eveā€¦ #360

Merged
Show file tree
Hide file tree
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
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)
- Fixed live time indicator not displaying on correct position when start and end hour is set. [#366](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/366)
- Fixed synchronization of scroll between pages in day and week view. [#186](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/186)
- Added showWeekTileBorder field whether to show border for header in month view. [#306](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/306)
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 @@ -167,12 +167,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 @@ -706,7 +706,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 @@ -680,6 +680,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
Loading