Skip to content

Commit

Permalink
Merge pull request #279 from SimformSolutionsPvtLtd/fix/issue_269_day…
Browse files Browse the repository at this point in the history
…_view_unwanted_scroll

fix: 🐛Day view auto scroll to initial duration when using [scrollOffs…
  • Loading branch information
PRBaraiya authored Nov 1, 2023
2 parents 6ae1800 + bf6a574 commit 3e1a213
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# [1.0.5] (UnReleased)

- Fixed issue related to auto scroll to initial duration for day
view-[#269](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/269)

# [1.0.4 - 9 Aug 2023](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.4)

- Fixed
Expand All @@ -8,10 +13,9 @@
Issue [#237 - DayView & MonthView layout issue in landscape mode](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/237)
- Added Feature
[#57 - Change default start hour in DayView](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/57)
- Fixed
- Fixed
Issue [#225 - Unwanted space at top in DayView while using sliver](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/225)


# [1.0.3 - 3 Apr 2023](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.3)

- Added
Expand Down
24 changes: 12 additions & 12 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ class DayView<T extends Object?> extends StatefulWidget {
/// Background colour of day view page.
final Color? backgroundColor;

/// Scroll offset of day view page.
final double scrollOffset;
/// Defines initial offset of first page that will be displayed when
/// [DayView] is initialized.
///
/// If [scrollOffset] is null then [startDuration] will be considered for
/// initial offset.
final double? scrollOffset;

/// This method will be called when user taps on event tile.
final CellTapCallback<T>? onEventTap;
Expand Down Expand Up @@ -184,7 +188,7 @@ class DayView<T extends Object?> extends StatefulWidget {

final bool showHalfHours;

/// Duration from where default day view will be visible
/// It define the starting duration from where day view page will be visible
/// By default it will be Duration(hours:0)
final Duration startDuration;

Expand Down Expand Up @@ -214,7 +218,7 @@ class DayView<T extends Object?> extends StatefulWidget {
this.eventArranger,
this.verticalLineOffset = 10,
this.backgroundColor = Colors.white,
this.scrollOffset = 0.0,
this.scrollOffset,
this.onEventTap,
this.onDateLongPress,
this.onDateTap,
Expand Down Expand Up @@ -298,8 +302,9 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
_regulateCurrentDate();

_calculateHeights();
_scrollController =
ScrollController(initialScrollOffset: widget.scrollOffset);
_scrollController = ScrollController(
initialScrollOffset: widget.scrollOffset ??
widget.startDuration.inMinutes * widget.heightPerMinute);
_pageController = PageController(initialPage: _currentIndex);
_eventArranger = widget.eventArranger ?? SideEventArranger<T>();
_assignBuilders();
Expand All @@ -323,10 +328,6 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
// user adds new events.
..addListener(_reloadCallback);
}

WidgetsBinding.instance.addPostFrameCallback((_) {
animateToDuration(widget.startDuration);
});
}

@override
Expand Down Expand Up @@ -799,8 +800,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
// above 24 hrs then we take it max as 24 hours only
final offset = offSetForSingleMinute *
(startDurationInMinutes > 3600 ? 3600 : startDurationInMinutes);
debugPrint("offSet $offset");
_scrollController.animateTo(
animateTo(
offset.toDouble(),
duration: duration,
curve: curve,
Expand Down

0 comments on commit 3e1a213

Please sign in to comment.