From 4aa88c95c66cd11eba761d099020b33526aa110d Mon Sep 17 00:00:00 2001 From: Apurva Kanthraviya Date: Wed, 1 May 2024 19:48:24 +0530 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8add=20on=20event=20double=20ta?= =?UTF-8?q?p=20callback=20in=20day,=20week,=20month=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/components/_internal_components.dart | 5 ++ lib/src/components/month_view_components.dart | 6 ++ lib/src/day_view/_internal_day_view_page.dart | 5 ++ lib/src/day_view/day_view.dart | 5 ++ lib/src/month_view/month_view.dart | 5 ++ .../week_view/_internal_week_view_page.dart | 87 ++++++++++--------- lib/src/week_view/week_view.dart | 5 ++ 7 files changed, 77 insertions(+), 41 deletions(-) diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index a78aaa8d..55a69cdb 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -329,6 +329,9 @@ class EventGenerator extends StatelessWidget { /// Called when user long press on event tile. final CellTapCallback? onTileLongTap; + /// Called when user double tap on any event tile + final CellTapCallback? onTileDoubleTap; + final EventScrollConfiguration scrollNotifier; /// A widget that display event tiles in day/week view. @@ -345,6 +348,7 @@ class EventGenerator extends StatelessWidget { required this.onTileTap, required this.onTileLongTap, required this.scrollNotifier, + required this.onTileDoubleTap, }) : super(key: key); /// Arrange events and returns list of [Widget] that displays event @@ -367,6 +371,7 @@ class EventGenerator extends StatelessWidget { child: GestureDetector( onLongPress: () => onTileLongTap?.call(events[index].events, date), onTap: () => onTileTap?.call(events[index].events, date), + onDoubleTap: () => onTileDoubleTap?.call(events[index].events, date), child: Builder(builder: (context) { if (scrollNotifier.shouldScroll && events[index] diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index 5b8bdbff..33f00993 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -89,6 +89,9 @@ class FilledCell extends StatelessWidget { /// Called when user long press on any event tile. final TileTapCallback? onTileLongTap; + /// Called when user double tap on any event tile. + final TileTapCallback? onTileDoubleTap; + /// defines that [date] is in current month or not. final bool isInMonth; @@ -118,6 +121,7 @@ class FilledCell extends StatelessWidget { this.titleColor = Constants.black, this.highlightedTitleColor = Constants.white, this.dateStringBuilder, + this.onTileDoubleTap, }) : super(key: key); @override @@ -162,6 +166,8 @@ class FilledCell extends StatelessWidget { onTileTap?.call(events[index], events[index].date), onLongPress: () => onTileLongTap?.call( events[index], events[index].date), + onDoubleTap: () => onTileDoubleTap?.call( + events[index], events[index].date), child: Container( decoration: BoxDecoration( color: events[index].color, diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index 2437a34c..0faafa0e 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -76,6 +76,9 @@ class InternalDayViewPage extends StatelessWidget { /// Called when user long press on event tile. final CellTapCallback? onTileLongTap; + /// Called when user double tap on any event tile. + final CellTapCallback? onTileDoubleTap; + /// Called when user long press on calendar. final DatePressCallback? onDateLongPress; @@ -153,6 +156,7 @@ class InternalDayViewPage extends StatelessWidget { required this.startHour, required this.quarterHourIndicatorSettings, required this.emulateVerticalOffsetBy, + required this.onTileDoubleTap, }) : super(key: key); @override @@ -233,6 +237,7 @@ class InternalDayViewPage extends StatelessWidget { height: height, date: date, onTileLongTap: onTileLongTap, + onTileDoubleTap: onTileDoubleTap, onTileTap: onTileTap, eventArranger: eventArranger, events: controller.getEventsOnDay( diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index d7a8b36a..ffe045c0 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -170,6 +170,9 @@ class DayView extends StatefulWidget { /// This method will be called when user long press on event tile. final CellTapCallback? onEventLongTap; + /// This method will be called when user double taps on event tile. + final CellTapCallback? onEventDoubleTap; + /// This method will be called when user long press on calendar. final DatePressCallback? onDateLongPress; @@ -267,6 +270,7 @@ class DayView extends StatefulWidget { this.startDuration = const Duration(hours: 0), this.onHeaderTitleTap, this.emulateVerticalOffsetBy = 0, + this.onEventDoubleTap, }) : assert(!(onHeaderTitleTap != null && dayTitleBuilder != null), "can't use [onHeaderTitleTap] & [dayTitleBuilder] simultaneously"), assert(timeLineOffset >= 0, @@ -458,6 +462,7 @@ class DayViewState extends State> { onTileLongTap: widget.onEventLongTap, onDateLongPress: widget.onDateLongPress, onDateTap: widget.onDateTap, + onTileDoubleTap: widget.onEventDoubleTap, showLiveLine: widget.showLiveTimeLineInAllDays || date.compareWithoutTime(DateTime.now()), timeLineOffset: widget.timeLineOffset, diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 986ae612..4c62e989 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -57,6 +57,9 @@ class MonthView extends StatefulWidget { /// This function will only work if [cellBuilder] is null. final TileTapCallback? onEventLongTap; + /// This method will be called when user double taps on event tile. + final TileTapCallback? onEventDoubleTap; + /// Builds the name of the weeks. /// /// Used default week builder if null. @@ -190,6 +193,7 @@ class MonthView extends StatefulWidget { this.onHeaderTitleTap, this.pagePhysics = const ClampingScrollPhysics(), this.pageViewPhysics, + this.onEventDoubleTap, }) : assert(!(onHeaderTitleTap != null && headerBuilder != null), "can't use [onHeaderTitleTap] & [headerBuilder] simultaneously"), super(key: key); @@ -531,6 +535,7 @@ class MonthViewState extends State> { onTileTap: widget.onEventTap, onTileLongTap: widget.onEventLongTap, dateStringBuilder: widget.dateStringBuilder, + onTileDoubleTap: widget.onEventDoubleTap, ); } diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index 3319ae8a..fb5e711b 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -96,6 +96,9 @@ class InternalWeekViewPage extends StatelessWidget { /// Called when user long press on event tile. final CellTapCallback? onTileLongTap; + /// Called when user double tap on any event tile. + final CellTapCallback? onTileDoubleTap; + /// Defines which days should be displayed in one week. /// /// By default all the days will be visible. @@ -139,47 +142,48 @@ class InternalWeekViewPage extends StatelessWidget { final double emulateVerticalOffsetBy; /// A single page for week view. - const InternalWeekViewPage( - {Key? key, - required this.showVerticalLine, - required this.weekTitleHeight, - required this.weekDayBuilder, - required this.weekNumberBuilder, - required this.width, - required this.dates, - required this.eventTileBuilder, - required this.controller, - required this.timeLineBuilder, - required this.hourIndicatorSettings, - required this.hourLinePainter, - required this.halfHourIndicatorSettings, - required this.quarterHourIndicatorSettings, - required this.showLiveLine, - required this.liveTimeIndicatorSettings, - required this.heightPerMinute, - required this.timeLineWidth, - required this.timeLineOffset, - required this.height, - required this.hourHeight, - required this.eventArranger, - required this.verticalLineOffset, - required this.weekTitleWidth, - required this.scrollController, - required this.onTileTap, - required this.onTileLongTap, - required this.onDateLongPress, - required this.onDateTap, - required this.weekDays, - required this.minuteSlotSize, - required this.scrollConfiguration, - required this.startHour, - required this.fullDayEventBuilder, - required this.weekDetectorBuilder, - required this.showWeekDayAtBottom, - required this.showHalfHours, - required this.showQuarterHours, - required this.emulateVerticalOffsetBy}) - : super(key: key); + const InternalWeekViewPage({ + Key? key, + required this.showVerticalLine, + required this.weekTitleHeight, + required this.weekDayBuilder, + required this.weekNumberBuilder, + required this.width, + required this.dates, + required this.eventTileBuilder, + required this.controller, + required this.timeLineBuilder, + required this.hourIndicatorSettings, + required this.hourLinePainter, + required this.halfHourIndicatorSettings, + required this.quarterHourIndicatorSettings, + required this.showLiveLine, + required this.liveTimeIndicatorSettings, + required this.heightPerMinute, + required this.timeLineWidth, + required this.timeLineOffset, + required this.height, + required this.hourHeight, + required this.eventArranger, + required this.verticalLineOffset, + required this.weekTitleWidth, + required this.scrollController, + required this.onTileTap, + required this.onTileLongTap, + required this.onDateLongPress, + required this.onDateTap, + required this.weekDays, + required this.minuteSlotSize, + required this.scrollConfiguration, + required this.startHour, + required this.fullDayEventBuilder, + required this.weekDetectorBuilder, + required this.showWeekDayAtBottom, + required this.showHalfHours, + required this.showQuarterHours, + required this.emulateVerticalOffsetBy, + required this.onTileDoubleTap, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -328,6 +332,7 @@ class InternalWeekViewPage extends StatelessWidget { date: filteredDates[index], onTileTap: onTileTap, onTileLongTap: onTileLongTap, + onTileDoubleTap: onTileDoubleTap, width: weekTitleWidth, eventArranger: eventArranger, eventTileBuilder: eventTileBuilder, diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 593a4814..83b97563 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -151,6 +151,9 @@ class WeekView extends StatefulWidget { /// Called when user long press on event tile. final CellTapCallback? onEventLongTap; + /// Called when user double taps on any event tile. + final CellTapCallback? onEventDoubleTap; + /// Show weekends or not /// /// Default value is true. @@ -278,6 +281,7 @@ class WeekView extends StatefulWidget { this.emulateVerticalOffsetBy = 0, this.showWeekDayAtBottom = false, this.pageViewPhysics, + this.onEventDoubleTap, }) : assert(!(onHeaderTitleTap != null && weekPageHeaderBuilder != null), "can't use [onHeaderTitleTap] & [weekPageHeaderBuilder] simultaneously"), assert((timeLineOffset) >= 0, @@ -486,6 +490,7 @@ class WeekViewState extends State> { onTileLongTap: widget.onEventLongTap, onDateLongPress: widget.onDateLongPress, onDateTap: widget.onDateTap, + onTileDoubleTap: widget.onEventDoubleTap, eventTileBuilder: _eventTileBuilder, heightPerMinute: widget.heightPerMinute, hourIndicatorSettings: _hourIndicatorSettings,