Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 lock horizontal scroll for week and month view #314 #351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading