diff --git a/README.md b/README.md index a5267943..3b1ef1ca 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ MonthView( startDay: WeekDays.sunday, // To change the first day of the week. // This callback will only work if cellBuilder is null. onEventTap: (event, date) => print(event), + onEventLongTap: (event, date) => print(event), onDateLongPress: (date) => print(date), headerBuilder: MonthHeader.hidden // To hide month header ); @@ -174,6 +175,7 @@ DayView( heightPerMinute: 1, // height occupied by 1 minute time span. eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged. onEventTap: (events, date) => print(events), + onEventLongTap: (events, date) => print(events), onDateLongPress: (date) => print(date), startHour: 5 // To set the first hour displayed (ex: 05:00) hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) { @@ -204,6 +206,7 @@ WeekView( heightPerMinute: 1, // height occupied by 1 minute time span. eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged. onEventTap: (events, date) => print(events), + onEventTap: (events, date) => print(events), onDateLongPress: (date) => print(date), startDay: WeekDays.sunday, // To change the first day of the week. startHour: 5 // To set the first hour displayed (ex: 05:00) diff --git a/example/lib/widgets/day_view_widget.dart b/example/lib/widgets/day_view_widget.dart index c6225c90..9ec788e8 100644 --- a/example/lib/widgets/day_view_widget.dart +++ b/example/lib/widgets/day_view_widget.dart @@ -34,6 +34,10 @@ class DayViewWidget extends StatelessWidget { ), ); }, + onEventLongTap: (events, date) { + SnackBar snackBar = SnackBar(content: Text("on LongTap")); + ScaffoldMessenger.of(context).showSnackBar(snackBar); + }, halfHourIndicatorSettings: HourIndicatorSettings( color: Theme.of(context).dividerColor, lineStyle: LineStyle.dashed, diff --git a/example/lib/widgets/month_view_widget.dart b/example/lib/widgets/month_view_widget.dart index 9f287382..f0aa051c 100644 --- a/example/lib/widgets/month_view_widget.dart +++ b/example/lib/widgets/month_view_widget.dart @@ -27,6 +27,10 @@ class MonthViewWidget extends StatelessWidget { ), ); }, + onEventLongTap: (event, date) { + SnackBar snackBar = SnackBar(content: Text("on LongTap")); + ScaffoldMessenger.of(context).showSnackBar(snackBar); + }, ); } } diff --git a/example/lib/widgets/week_view_widget.dart b/example/lib/widgets/week_view_widget.dart index 4d377023..294ab5b1 100644 --- a/example/lib/widgets/week_view_widget.dart +++ b/example/lib/widgets/week_view_widget.dart @@ -29,6 +29,10 @@ class WeekViewWidget extends StatelessWidget { ), ); }, + onEventLongTap: (events, date) { + SnackBar snackBar = SnackBar(content: Text("on LongTap")); + ScaffoldMessenger.of(context).showSnackBar(snackBar); + }, ); } } diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index 7c2235d7..a78aaa8d 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -326,6 +326,9 @@ class EventGenerator extends StatelessWidget { /// Called when user taps on event tile. final CellTapCallback? onTileTap; + /// Called when user long press on event tile. + final CellTapCallback? onTileLongTap; + final EventScrollConfiguration scrollNotifier; /// A widget that display event tiles in day/week view. @@ -340,6 +343,7 @@ class EventGenerator extends StatelessWidget { required this.eventTileBuilder, required this.date, required this.onTileTap, + required this.onTileLongTap, required this.scrollNotifier, }) : super(key: key); @@ -361,6 +365,7 @@ class EventGenerator extends StatelessWidget { left: events[index].left, right: events[index].right, child: GestureDetector( + onLongPress: () => onTileLongTap?.call(events[index].events, date), onTap: () => onTileTap?.call(events[index].events, date), child: Builder(builder: (context) { if (scrollNotifier.shouldScroll && diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index 57ae6796..5b8bdbff 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -86,6 +86,9 @@ class FilledCell extends StatelessWidget { /// Called when user taps on any event tile. final TileTapCallback? onTileTap; + /// Called when user long press on any event tile. + final TileTapCallback? onTileLongTap; + /// defines that [date] is in current month or not. final bool isInMonth; @@ -109,6 +112,7 @@ class FilledCell extends StatelessWidget { this.backgroundColor = Colors.blue, this.highlightColor = Colors.blue, this.onTileTap, + this.onTileLongTap, this.tileColor = Colors.blue, this.highlightRadius = 11, this.titleColor = Constants.black, @@ -156,6 +160,8 @@ class FilledCell extends StatelessWidget { (index) => GestureDetector( onTap: () => onTileTap?.call(events[index], events[index].date), + onLongPress: () => onTileLongTap?.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 02560dce..2437a34c 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -73,6 +73,9 @@ class InternalDayViewPage extends StatelessWidget { /// Called when user taps on event tile. final CellTapCallback? onTileTap; + /// Called when user long press on event tile. + final CellTapCallback? onTileLongTap; + /// Called when user long press on calendar. final DatePressCallback? onDateLongPress; @@ -136,6 +139,7 @@ class InternalDayViewPage extends StatelessWidget { required this.eventArranger, required this.verticalLineOffset, required this.onTileTap, + required this.onTileLongTap, required this.onDateLongPress, required this.onDateTap, required this.minuteSlotSize, @@ -228,6 +232,7 @@ class InternalDayViewPage extends StatelessWidget { child: EventGenerator( height: height, date: date, + onTileLongTap: onTileLongTap, 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 3b35afdb..d7a8b36a 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -167,6 +167,9 @@ class DayView extends StatefulWidget { /// This method will be called when user taps on event tile. final CellTapCallback? onEventTap; + /// This method will be called when user long press on event tile. + final CellTapCallback? onEventLongTap; + /// This method will be called when user long press on calendar. final DatePressCallback? onDateLongPress; @@ -246,6 +249,7 @@ class DayView extends StatefulWidget { this.backgroundColor = Colors.white, this.scrollOffset, this.onEventTap, + this.onEventLongTap, this.onDateLongPress, this.onDateTap, this.minuteSlotSize = MinuteSlotSize.minutes60, @@ -451,6 +455,7 @@ class DayViewState extends State> { hourLinePainter: _hourLinePainter, date: date, onTileTap: widget.onEventTap, + onTileLongTap: widget.onEventLongTap, onDateLongPress: widget.onDateLongPress, onDateTap: widget.onDateTap, showLiveLine: widget.showLiveTimeLineInAllDays || diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 2b1f148e..986ae612 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -51,6 +51,12 @@ class MonthView extends StatefulWidget { /// This function will only work if [cellBuilder] is null. final TileTapCallback? onEventTap; + /// This function will be called when user will long press on a single event + /// tile inside a cell. + /// + /// This function will only work if [cellBuilder] is null. + final TileTapCallback? onEventLongTap; + /// Builds the name of the weeks. /// /// Used default week builder if null. @@ -173,6 +179,7 @@ class MonthView extends StatefulWidget { this.onPageChange, this.onCellTap, this.onEventTap, + this.onEventLongTap, this.onDateLongPress, this.startDay = WeekDays.monday, this.headerStringBuilder, @@ -522,6 +529,7 @@ class MonthViewState extends State> { backgroundColor: isInMonth ? Constants.white : Constants.offWhite, events: events, onTileTap: widget.onEventTap, + onTileLongTap: widget.onEventLongTap, dateStringBuilder: widget.dateStringBuilder, ); } diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index baf789a9..3319ae8a 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -93,6 +93,9 @@ class InternalWeekViewPage extends StatelessWidget { /// Called when user taps on event tile. final CellTapCallback? onTileTap; + /// Called when user long press on event tile. + final CellTapCallback? onTileLongTap; + /// Defines which days should be displayed in one week. /// /// By default all the days will be visible. @@ -163,6 +166,7 @@ class InternalWeekViewPage extends StatelessWidget { required this.weekTitleWidth, required this.scrollController, required this.onTileTap, + required this.onTileLongTap, required this.onDateLongPress, required this.onDateTap, required this.weekDays, @@ -323,6 +327,7 @@ class InternalWeekViewPage extends StatelessWidget { height: height, date: filteredDates[index], onTileTap: onTileTap, + onTileLongTap: onTileLongTap, 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 6e94bc8f..593a4814 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -148,6 +148,9 @@ class WeekView extends StatefulWidget { /// Called when user taps on event tile. final CellTapCallback? onEventTap; + /// Called when user long press on event tile. + final CellTapCallback? onEventLongTap; + /// Show weekends or not /// /// Default value is true. @@ -253,6 +256,7 @@ class WeekView extends StatefulWidget { this.backgroundColor = Colors.white, this.scrollOffset = 0.0, this.onEventTap, + this.onEventLongTap, this.onDateLongPress, this.onDateTap, this.weekDays = WeekDays.values, @@ -479,6 +483,7 @@ class WeekViewState extends State> { _liveTimeIndicatorSettings, timeLineBuilder: _timeLineBuilder, onTileTap: widget.onEventTap, + onTileLongTap: widget.onEventLongTap, onDateLongPress: widget.onDateLongPress, onDateTap: widget.onDateTap, eventTileBuilder: _eventTileBuilder,