From 0882a3364b22e433005705abe9a132fbbb42596a Mon Sep 17 00:00:00 2001 From: Shubham Jitiya Date: Tue, 5 Nov 2024 11:50:35 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20Fixes=20issue=20#417:=20=F0=9F=90=9B=20F?= =?UTF-8?q?ixes=20calendar=20scroll=20physics=20for=20day=20&=20week=20vie?= =?UTF-8?q?w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- example/lib/widgets/day_view_widget.dart | 1 + example/lib/widgets/week_view_widget.dart | 1 + lib/src/day_view/_internal_day_view_page.dart | 5 +++++ lib/src/day_view/day_view.dart | 1 + lib/src/week_view/_internal_week_view_page.dart | 5 +++++ lib/src/week_view/week_view.dart | 5 +++++ 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b573f981..2cb8e4f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Added `mainAxisSize`, `mainAxisAlignment`, `rightIconConfig` and `leftIconConfig`. - Adds additional configurations for `CalendarPageHeader`, `MonthPageHeader`, `DayPageHeader` and `WeekPageHeader`. - Added `titleBuilder` to build custom title for header. +- Fixes issue calendar scroll physics for day & week view - `Deprecations`: - deprecated `backgroundColor` and `iconColor` from `CalendarPageHeader`, `DayPageHeader`, `MonthPageHeader` and `WeekPageHeader`. - **Solution:** use `headerStyle` instead. @@ -192,4 +193,4 @@ # [0.0.1 - 26 Aug 2021](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.1) -- Initial release \ No newline at end of file +- Initial release diff --git a/example/lib/widgets/day_view_widget.dart b/example/lib/widgets/day_view_widget.dart index 9ec788e8..664253ce 100644 --- a/example/lib/widgets/day_view_widget.dart +++ b/example/lib/widgets/day_view_widget.dart @@ -22,6 +22,7 @@ class DayViewWidget extends StatelessWidget { showHalfHours: true, heightPerMinute: 3, timeLineBuilder: _timeLineBuilder, + scrollPhysics: const BouncingScrollPhysics(), hourIndicatorSettings: HourIndicatorSettings( color: Theme.of(context).dividerColor, ), diff --git a/example/lib/widgets/week_view_widget.dart b/example/lib/widgets/week_view_widget.dart index 294ab5b1..8b158afc 100644 --- a/example/lib/widgets/week_view_widget.dart +++ b/example/lib/widgets/week_view_widget.dart @@ -16,6 +16,7 @@ class WeekViewWidget extends StatelessWidget { width: width, showLiveTimeLineInAllDays: true, timeLineWidth: 65, + scrollPhysics: const BouncingScrollPhysics(), liveTimeIndicatorSettings: LiveTimeIndicatorSettings( color: Colors.redAccent, showTime: true, diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index 39965140..591bbdb1 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -133,6 +133,9 @@ class InternalDayViewPage extends StatefulWidget { /// Flag to keep scrollOffset of pages on page change final bool keepScrollOffset; + /// Use this field to disable the calendar scrolling + final ScrollPhysics? scrollPhysics; + /// Defines a single day page. const InternalDayViewPage({ Key? key, @@ -161,6 +164,7 @@ class InternalDayViewPage extends StatefulWidget { required this.scrollNotifier, required this.fullDayEventBuilder, required this.dayViewScrollController, + required this.scrollPhysics, required this.scrollListener, this.lastScrollOffset = 0.0, required this.dayDetectorBuilder, @@ -223,6 +227,7 @@ class _InternalDayViewPageState controller: widget.keepScrollOffset ? scrollController : widget.dayViewScrollController, + physics: widget.scrollPhysics, child: SizedBox( height: widget.height, width: widget.width, diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 71b041bf..49c79b73 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -497,6 +497,7 @@ class DayViewState extends State> { widget.emulateVerticalOffsetBy, lastScrollOffset: _lastScrollOffset, dayViewScrollController: _scrollController, + scrollPhysics: widget.scrollPhysics, scrollListener: _scrollPageListener, keepScrollOffset: widget.keepScrollOffset, ), diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index 3549dbf3..04842eb6 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -160,6 +160,9 @@ class InternalWeekViewPage extends StatefulWidget { /// Flag to keep scrollOffset of pages on page change final bool keepScrollOffset; + /// Use this field to disable the calendar scrolling + final ScrollPhysics? scrollPhysics; + /// A single page for week view. const InternalWeekViewPage({ Key? key, @@ -204,6 +207,7 @@ class InternalWeekViewPage extends StatefulWidget { required this.endHour, this.fullDayHeaderTitle = '', required this.fullDayHeaderTextConfig, + required this.scrollPhysics, required this.scrollListener, required this.weekViewScrollController, this.lastScrollOffset = 0.0, @@ -339,6 +343,7 @@ class _InternalWeekViewPageState controller: widget.keepScrollOffset ? scrollController : widget.weekViewScrollController, + physics: widget.scrollPhysics, child: SizedBox( height: widget.height, width: widget.width, diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 38a524b1..dafd27e4 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -230,6 +230,9 @@ class WeekView extends StatefulWidget { /// If true this will show week day at bottom position. final bool showWeekDayAtBottom; + /// Use this field to disable the calendar scrolling + final ScrollPhysics? scrollPhysics; + /// Defines scroll physics for a page of a week view. /// /// This can be used to disable the horizontal scroll of a page. @@ -273,6 +276,7 @@ class WeekView extends StatefulWidget { this.weekDayBuilder, this.weekNumberBuilder, this.backgroundColor = Colors.white, + this.scrollPhysics, this.scrollOffset = 0.0, this.onEventTap, this.onEventLongTap, @@ -561,6 +565,7 @@ class WeekViewState extends State> { fullDayHeaderTitle: _fullDayHeaderTitle, fullDayHeaderTextConfig: _fullDayHeaderTextConfig, lastScrollOffset: _lastScrollOffset, + scrollPhysics: widget.scrollPhysics, scrollListener: _scrollPageListener, keepScrollOffset: widget.keepScrollOffset, ),