From bba1806c9ed09d302385646ee024dcb1ac173939 Mon Sep 17 00:00:00 2001 From: Apurva Kanthraviya Date: Tue, 7 May 2024 20:11:34 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20full=20day=20event?= =?UTF-8?q?=20on=20tap=20with=20on=20tap=20callback=20in=20full=20day=20ev?= =?UTF-8?q?ent=20view=20#260?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + lib/src/components/day_view_components.dart | 14 ++++++++++++-- lib/src/components/month_view_components.dart | 11 +++++------ lib/src/day_view/day_view.dart | 8 +++++++- lib/src/week_view/week_view.dart | 3 +++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e77186..884dc6b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/src/components/day_view_components.dart b/lib/src/components/day_view_components.dart index 98eb623e..745a19b1 100644 --- a/lib/src/components/day_view_components.dart +++ b/lib/src/components/day_view_components.dart @@ -199,6 +199,8 @@ class FullDayEventView extends StatelessWidget { this.titleStyle, this.onEventTap, required this.date, + this.onEventDoubleTap, + this.onEventLongPress, }) : super(key: key); /// Constraints for view @@ -217,7 +219,13 @@ class FullDayEventView extends StatelessWidget { final TextStyle? titleStyle; /// Called when user taps on event tile. - final TileTapCallback? onEventTap; + final CellTapCallback? onEventTap; + + /// Called when user long press on event tile. + final CellTapCallback? onEventLongPress; + + /// Called when user double taps on any event tile. + final CellTapCallback? onEventDoubleTap; /// Defines date for which events will be displayed. final DateTime date; @@ -231,7 +239,9 @@ class FullDayEventView 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), diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index dd32755c..f64c0016 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -167,12 +167,11 @@ class FilledCell 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, diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 076025f9..166c32d3 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -706,7 +706,13 @@ class DayViewState extends State> { Widget _defaultFullDayEventBuilder( List> 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, diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 9b549e6e..dd61214c 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -680,6 +680,9 @@ class WeekViewState extends State> { events: events, boxConstraints: BoxConstraints(maxHeight: 65), date: dateTime, + onEventTap: widget.onEventTap, + onEventDoubleTap: widget.onEventDoubleTap, + onEventLongPress: widget.onEventLongTap, ); }