Skip to content

Commit

Permalink
fix: 🐛 onDateTap return wrong date when startHour is set #341 (#350)
Browse files Browse the repository at this point in the history
- add startHour minutes (startHour * 60) to DateTime which then passed as arguments to onDateTap
  • Loading branch information
apurva010 authored May 1, 2024
1 parent fadd7f5 commit 189d10e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/src/components/common_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class DefaultPressDetector extends StatelessWidget {
required this.minuteSlotSize,
this.onDateTap,
this.onDateLongPress,
this.startHour = 0,
});

final DateTime date;
Expand All @@ -142,6 +143,7 @@ class DefaultPressDetector extends StatelessWidget {
final MinuteSlotSize minuteSlotSize;
final DateTapCallback? onDateTap;
final DatePressCallback? onDateLongPress;
final int startHour;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -183,7 +185,7 @@ class DefaultPressDetector extends StatelessWidget {
date.month,
date.day,
0,
(minuteSlotSize.minutes * slot),
(minuteSlotSize.minutes * slot) + (startHour * 60),
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
minuteSlotSize: minuteSlotSize,
onDateTap: widget.onDateTap,
onDateLongPress: widget.onDateLongPress,
startHour: _startHour,
);

/// Default timeline builder this builder will be used if
Expand Down
1 change: 1 addition & 0 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
minuteSlotSize: minuteSlotSize,
onDateTap: widget.onDateTap,
onDateLongPress: widget.onDateLongPress,
startHour: _startHour,
);

/// Default builder for week line.
Expand Down

0 comments on commit 189d10e

Please sign in to comment.