From 1171a6c9911b2cc7f96aa3fb4afcaa8f89e47b0c Mon Sep 17 00:00:00 2001 From: Jaimin Rana Date: Wed, 1 Nov 2023 16:48:54 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9BDay=20view=20auto=20scroll?= =?UTF-8?q?=20to=20initial=20duration=20when=20using=20[scrollOffset]=20&?= =?UTF-8?q?=20[startingDuration]=20#269.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++-- lib/src/day_view/day_view.dart | 21 +++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 543e1f8a..2b874b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# [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 +12,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,