From ad3e4824af766a7f1c38466ad6b3fdc10732d336 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 f2c885f7..9a2b17f3 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) - 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) 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 33f00993..5f07984d 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -162,12 +162,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 ffe045c0..f424e4a9 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -688,7 +688,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 83b97563..ce40bb81 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -641,6 +641,9 @@ class WeekViewState extends State> { events: events, boxConstraints: BoxConstraints(maxHeight: 65), date: dateTime, + onEventTap: widget.onEventTap, + onEventDoubleTap: widget.onEventDoubleTap, + onEventLongPress: widget.onEventLongTap, ); }