diff --git a/CHANGELOG.md b/CHANGELOG.md index 543e1f8a..e3180dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 73ef9bee..9217debf 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -145,8 +145,9 @@ class DayView 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. + final double? scrollOffset; /// This method will be called when user taps on event tile. final CellTapCallback? onEventTap; @@ -184,7 +185,7 @@ class DayView 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; @@ -214,7 +215,7 @@ class DayView extends StatefulWidget { this.eventArranger, this.verticalLineOffset = 10, this.backgroundColor = Colors.white, - this.scrollOffset = 0.0, + this.scrollOffset, this.onEventTap, this.onDateLongPress, this.onDateTap, @@ -298,8 +299,9 @@ class DayViewState extends State> { _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(); _assignBuilders(); @@ -323,10 +325,6 @@ class DayViewState extends State> { // user adds new events. ..addListener(_reloadCallback); } - - WidgetsBinding.instance.addPostFrameCallback((_) { - animateToDuration(widget.startDuration); - }); } @override @@ -799,8 +797,7 @@ class DayViewState extends State> { // 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,