Skip to content

Commit

Permalink
fix: 🐛 lock horizontal scroll for week and month view #314 (#351)
Browse files Browse the repository at this point in the history
- add pageViewPhysics for week and month view to change scroll behaviour of page view
  • Loading branch information
apurva010 authored May 1, 2024
1 parent 189d10e commit f5bf6b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- # [1.1.1] (UnReleased)
- Added support for horizontal scroll physics of week and month view page. [#314](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/314)
- Fixed issue related to onDateTap no triggered in WeekView and dayView. [#332](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/332)
# [1.1.0 - 28 Feb 2024](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.1.0)
- Fixed issue related to Hiding Header [#299](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/pull/299)
Expand Down
7 changes: 7 additions & 0 deletions lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ class MonthView<T extends Object?> extends StatefulWidget {
/// Default value is [ClampingScrollPhysics].
final ScrollPhysics pagePhysics;

/// Defines scroll physics for a page of a month view.
///
/// This can be used to disable the horizontal scroll of a page.
final ScrollPhysics? pageViewPhysics;

/// Main [Widget] to display month view.
const MonthView({
Key? key,
Expand Down Expand Up @@ -177,6 +182,7 @@ class MonthView<T extends Object?> extends StatefulWidget {
this.safeAreaOption = const SafeAreaOption(),
this.onHeaderTitleTap,
this.pagePhysics = const ClampingScrollPhysics(),
this.pageViewPhysics,
}) : assert(!(onHeaderTitleTap != null && headerBuilder != null),
"can't use [onHeaderTitleTap] & [headerBuilder] simultaneously"),
super(key: key);
Expand Down Expand Up @@ -306,6 +312,7 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
Expanded(
child: PageView.builder(
controller: _pageController,
physics: widget.pageViewPhysics,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final date = DateTime(_minDate.year, _minDate.month + index);
Expand Down
7 changes: 7 additions & 0 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ class WeekView<T extends Object?> extends StatefulWidget {
/// If true this will show week day at bottom position.
final bool showWeekDayAtBottom;

/// Defines scroll physics for a page of a week view.
///
/// This can be used to disable the horizontal scroll of a page.
final ScrollPhysics? pageViewPhysics;

/// Main widget for week view.
const WeekView({
Key? key,
Expand Down Expand Up @@ -268,6 +273,7 @@ class WeekView<T extends Object?> extends StatefulWidget {
this.showQuarterHours = false,
this.emulateVerticalOffsetBy = 0,
this.showWeekDayAtBottom = false,
this.pageViewPhysics,
}) : assert(!(onHeaderTitleTap != null && weekPageHeaderBuilder != null),
"can't use [onHeaderTitleTap] & [weekPageHeaderBuilder] simultaneously"),
assert((timeLineOffset) >= 0,
Expand Down Expand Up @@ -450,6 +456,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
child: PageView.builder(
itemCount: _totalWeeks,
controller: _pageController,
physics: widget.pageViewPhysics,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final dates = DateTime(_minDate.year, _minDate.month,
Expand Down

0 comments on commit f5bf6b5

Please sign in to comment.