Skip to content

Commit

Permalink
Merge pull request #418 from SimformSolutionsPvtLtd/fix/issue_417_scr…
Browse files Browse the repository at this point in the history
…oll_physics

fix: Fixes issue #417: 🐛 Fixes calendar scroll physics for day & week view
  • Loading branch information
PRBaraiya authored Nov 6, 2024
2 parents 982747f + 689dac2 commit 372cdcc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. [#417](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/417)
- `Deprecations`:
- deprecated `backgroundColor` and `iconColor` from `CalendarPageHeader`, `DayPageHeader`, `MonthPageHeader` and `WeekPageHeader`.
- **Solution:** use `headerStyle` instead.
Expand Down
1 change: 1 addition & 0 deletions example/lib/widgets/day_view_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DayViewWidget extends StatelessWidget {
showHalfHours: true,
heightPerMinute: 3,
timeLineBuilder: _timeLineBuilder,
scrollPhysics: const BouncingScrollPhysics(),
hourIndicatorSettings: HourIndicatorSettings(
color: Theme.of(context).dividerColor,
),
Expand Down
1 change: 1 addition & 0 deletions example/lib/widgets/week_view_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class WeekViewWidget extends StatelessWidget {
width: width,
showLiveTimeLineInAllDays: true,
timeLineWidth: 65,
scrollPhysics: const BouncingScrollPhysics(),
liveTimeIndicatorSettings: LiveTimeIndicatorSettings(
color: Colors.redAccent,
showTime: true,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/day_view/_internal_day_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class InternalDayViewPage<T extends Object?> 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,
Expand Down Expand Up @@ -161,6 +164,7 @@ class InternalDayViewPage<T extends Object?> extends StatefulWidget {
required this.scrollNotifier,
required this.fullDayEventBuilder,
required this.dayViewScrollController,
required this.scrollPhysics,
required this.scrollListener,
this.lastScrollOffset = 0.0,
required this.dayDetectorBuilder,
Expand Down Expand Up @@ -223,6 +227,7 @@ class _InternalDayViewPageState<T extends Object?>
controller: widget.keepScrollOffset
? scrollController
: widget.dayViewScrollController,
physics: widget.scrollPhysics,
child: SizedBox(
height: widget.height,
width: widget.width,
Expand Down
1 change: 1 addition & 0 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
widget.emulateVerticalOffsetBy,
lastScrollOffset: _lastScrollOffset,
dayViewScrollController: _scrollController,
scrollPhysics: widget.scrollPhysics,
scrollListener: _scrollPageListener,
keepScrollOffset: widget.keepScrollOffset,
),
Expand Down
5 changes: 5 additions & 0 deletions lib/src/week_view/_internal_week_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class InternalWeekViewPage<T extends Object?> 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,
Expand Down Expand Up @@ -204,6 +207,7 @@ class InternalWeekViewPage<T extends Object?> extends StatefulWidget {
required this.endHour,
this.fullDayHeaderTitle = '',
required this.fullDayHeaderTextConfig,
required this.scrollPhysics,
required this.scrollListener,
required this.weekViewScrollController,
this.lastScrollOffset = 0.0,
Expand Down Expand Up @@ -339,6 +343,7 @@ class _InternalWeekViewPageState<T extends Object?>
controller: widget.keepScrollOffset
? scrollController
: widget.weekViewScrollController,
physics: widget.scrollPhysics,
child: SizedBox(
height: widget.height,
width: widget.width,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class WeekView<T extends Object?> 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.
Expand Down Expand Up @@ -273,6 +276,7 @@ class WeekView<T extends Object?> extends StatefulWidget {
this.weekDayBuilder,
this.weekNumberBuilder,
this.backgroundColor = Colors.white,
this.scrollPhysics,
this.scrollOffset = 0.0,
this.onEventTap,
this.onEventLongTap,
Expand Down Expand Up @@ -561,6 +565,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
fullDayHeaderTitle: _fullDayHeaderTitle,
fullDayHeaderTextConfig: _fullDayHeaderTextConfig,
lastScrollOffset: _lastScrollOffset,
scrollPhysics: widget.scrollPhysics,
scrollListener: _scrollPageListener,
keepScrollOffset: widget.keepScrollOffset,
),
Expand Down

0 comments on commit 372cdcc

Please sign in to comment.