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

Prevent navigation outside minimum and maximum date range #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 22 additions & 6 deletions src/Calendar.Plugin/Shared/Controls/Calendar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,22 +1235,38 @@ private int GetWeekNumber(DateTime date)

private void PrevUnit()
{
ShownDate = _viewLayoutEngine.GetPreviousUnit(ShownDate);
var targetDate = _viewLayoutEngine.GetPreviousUnit(ShownDate);

ShownDate = targetDate < MinimumDate
? MinimumDate
: targetDate;
}

private void NextUnit()
{
ShownDate = _viewLayoutEngine.GetNextUnit(ShownDate);
var targetDate = _viewLayoutEngine.GetNextUnit(ShownDate);

ShownDate = targetDate > MaximumDate
? MaximumDate
: targetDate;
}

private void NextYear(object obj)
private void PrevYear(object obj)
{
ShownDate = ShownDate.AddYears(1);
var targetDate = ShownDate.AddYears(-1);

ShownDate = targetDate < MinimumDate
? MinimumDate
: targetDate;
}

private void PrevYear(object obj)
private void NextYear(object obj)
{
ShownDate = ShownDate.AddYears(-1);
var targetDate = ShownDate.AddYears(1);

ShownDate = targetDate > MaximumDate
? MaximumDate
: targetDate;
}

private void ToggleCalendarSectionVisibility()
Expand Down