Skip to content

Commit

Permalink
🏁 provide start day while navigating to next page in week view. (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
PRBaraiya authored Jun 2, 2022
1 parent 475fff9 commit 885a67d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
_currentDate = DateTime(
_currentDate.year,
_currentDate.month + (value - _currentIndex),
_currentDate.day,
);
_currentIndex = value;
});
Expand Down Expand Up @@ -517,8 +516,7 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
}

/// Returns the current visible date in month view.
DateTime get currentDate =>
DateTime(_currentDate.year, _currentDate.month, _currentDate.day);
DateTime get currentDate => DateTime(_currentDate.year, _currentDate.month);
}

/// A single month page.
Expand Down
8 changes: 5 additions & 3 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
"Provided minimum date: $_minDate, maximum date: $_maxDate",
);

_totalWeeks = _minDate.getWeekDifference(_maxDate) + 1;
_totalWeeks =
_minDate.getWeekDifference(_maxDate, start: widget.startDay) + 1;
}

/// Default builder for week line.
Expand Down Expand Up @@ -621,7 +622,8 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
if (week.isBefore(_minDate) || week.isAfter(_maxDate)) {
throw "Invalid date selected.";
}
_pageController.jumpToPage(_minDate.getWeekDifference(week));
_pageController
.jumpToPage(_minDate.getWeekDifference(week, start: widget.startDay));
}

/// Animate to page which gives day calendar for [week].
Expand All @@ -635,7 +637,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
throw "Invalid date selected.";
}
await _pageController.animateToPage(
_minDate.getWeekDifference(week),
_minDate.getWeekDifference(week, start: widget.startDay),
duration: duration ?? widget.pageTransitionDuration,
curve: curve ?? widget.pageTransitionCurve,
);
Expand Down

0 comments on commit 885a67d

Please sign in to comment.