Skip to content

Commit 372cdcc

Browse files
authored
Merge pull request #418 from SimformSolutionsPvtLtd/fix/issue_417_scroll_physics
fix: Fixes issue #417: 🐛 Fixes calendar scroll physics for day & week view
2 parents 982747f + 689dac2 commit 372cdcc

File tree

7 files changed

+19
-0
lines changed

7 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Added `mainAxisSize`, `mainAxisAlignment`, `rightIconConfig` and `leftIconConfig`.
99
- Adds additional configurations for `CalendarPageHeader`, `MonthPageHeader`, `DayPageHeader` and `WeekPageHeader`.
1010
- Added `titleBuilder` to build custom title for header.
11+
- Fixes issue calendar scroll physics for day & week view. [#417](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/417)
1112
- `Deprecations`:
1213
- deprecated `backgroundColor` and `iconColor` from `CalendarPageHeader`, `DayPageHeader`, `MonthPageHeader` and `WeekPageHeader`.
1314
- **Solution:** use `headerStyle` instead.

example/lib/widgets/day_view_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class DayViewWidget extends StatelessWidget {
2222
showHalfHours: true,
2323
heightPerMinute: 3,
2424
timeLineBuilder: _timeLineBuilder,
25+
scrollPhysics: const BouncingScrollPhysics(),
2526
hourIndicatorSettings: HourIndicatorSettings(
2627
color: Theme.of(context).dividerColor,
2728
),

example/lib/widgets/week_view_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class WeekViewWidget extends StatelessWidget {
1616
width: width,
1717
showLiveTimeLineInAllDays: true,
1818
timeLineWidth: 65,
19+
scrollPhysics: const BouncingScrollPhysics(),
1920
liveTimeIndicatorSettings: LiveTimeIndicatorSettings(
2021
color: Colors.redAccent,
2122
showTime: true,

lib/src/day_view/_internal_day_view_page.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ class InternalDayViewPage<T extends Object?> extends StatefulWidget {
133133
/// Flag to keep scrollOffset of pages on page change
134134
final bool keepScrollOffset;
135135

136+
/// Use this field to disable the calendar scrolling
137+
final ScrollPhysics? scrollPhysics;
138+
136139
/// Defines a single day page.
137140
const InternalDayViewPage({
138141
Key? key,
@@ -161,6 +164,7 @@ class InternalDayViewPage<T extends Object?> extends StatefulWidget {
161164
required this.scrollNotifier,
162165
required this.fullDayEventBuilder,
163166
required this.dayViewScrollController,
167+
required this.scrollPhysics,
164168
required this.scrollListener,
165169
this.lastScrollOffset = 0.0,
166170
required this.dayDetectorBuilder,
@@ -223,6 +227,7 @@ class _InternalDayViewPageState<T extends Object?>
223227
controller: widget.keepScrollOffset
224228
? scrollController
225229
: widget.dayViewScrollController,
230+
physics: widget.scrollPhysics,
226231
child: SizedBox(
227232
height: widget.height,
228233
width: widget.width,

lib/src/day_view/day_view.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
497497
widget.emulateVerticalOffsetBy,
498498
lastScrollOffset: _lastScrollOffset,
499499
dayViewScrollController: _scrollController,
500+
scrollPhysics: widget.scrollPhysics,
500501
scrollListener: _scrollPageListener,
501502
keepScrollOffset: widget.keepScrollOffset,
502503
),

lib/src/week_view/_internal_week_view_page.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class InternalWeekViewPage<T extends Object?> extends StatefulWidget {
160160
/// Flag to keep scrollOffset of pages on page change
161161
final bool keepScrollOffset;
162162

163+
/// Use this field to disable the calendar scrolling
164+
final ScrollPhysics? scrollPhysics;
165+
163166
/// A single page for week view.
164167
const InternalWeekViewPage({
165168
Key? key,
@@ -204,6 +207,7 @@ class InternalWeekViewPage<T extends Object?> extends StatefulWidget {
204207
required this.endHour,
205208
this.fullDayHeaderTitle = '',
206209
required this.fullDayHeaderTextConfig,
210+
required this.scrollPhysics,
207211
required this.scrollListener,
208212
required this.weekViewScrollController,
209213
this.lastScrollOffset = 0.0,
@@ -339,6 +343,7 @@ class _InternalWeekViewPageState<T extends Object?>
339343
controller: widget.keepScrollOffset
340344
? scrollController
341345
: widget.weekViewScrollController,
346+
physics: widget.scrollPhysics,
342347
child: SizedBox(
343348
height: widget.height,
344349
width: widget.width,

lib/src/week_view/week_view.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class WeekView<T extends Object?> extends StatefulWidget {
230230
/// If true this will show week day at bottom position.
231231
final bool showWeekDayAtBottom;
232232

233+
/// Use this field to disable the calendar scrolling
234+
final ScrollPhysics? scrollPhysics;
235+
233236
/// Defines scroll physics for a page of a week view.
234237
///
235238
/// This can be used to disable the horizontal scroll of a page.
@@ -273,6 +276,7 @@ class WeekView<T extends Object?> extends StatefulWidget {
273276
this.weekDayBuilder,
274277
this.weekNumberBuilder,
275278
this.backgroundColor = Colors.white,
279+
this.scrollPhysics,
276280
this.scrollOffset = 0.0,
277281
this.onEventTap,
278282
this.onEventLongTap,
@@ -561,6 +565,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
561565
fullDayHeaderTitle: _fullDayHeaderTitle,
562566
fullDayHeaderTextConfig: _fullDayHeaderTextConfig,
563567
lastScrollOffset: _lastScrollOffset,
568+
scrollPhysics: widget.scrollPhysics,
564569
scrollListener: _scrollPageListener,
565570
keepScrollOffset: widget.keepScrollOffset,
566571
),

0 commit comments

Comments
 (0)