version: 7.0.1
Me again.
After https://github.com/patchthecode/JTAppleCalendar/issues/384 I got a weekly calendar with horizontal scrolling feature.
However, my app does not want users to select the future dates. So I want to disable the scroll to the future weeks.
How can I implement this feature?
For example.
Today is Apr. 19, so my calendar looks like
| 16 17 18 (19) 20 21 22 |
And if the user want to scroll back (left), it will become
| 9 10 11 12 13 14 15 |
While, if the user want to scroll to the future (right), I want the calendar stay on the week start from 16.
I tried to set the end date as today, but I still can scroll to the end of this month.
I tried to use deleteSections() or deleteItems(), but I cannot get the index for the target from date.
I also considered whether there is a shouldScroll delegation function, but I failed to find one.
Could you show me a way to work this out?
sounds like you want a date boundary ?
Thank you very much! This is exactly what I need.
Seems the data structure of visibleDates.monthDates had been changed from [Date] to [(Date, IndexPath]. And the monthDates are the dates I am scrolling out instead of the dates scrolling into the visible range.
Paste my code here to reduce the confusion.
func scrollDidEndDecelerating(for calendar: JTAppleCalendarView) {
guard let end = self.visibleEndDate else {
return
}
let visibleDates = calendar.visibleDates()
if visibleDates.monthDates.contains(where: {$0.date >= end}) {
calendar.scrollToDate(end)
}
}
Awesome. Glad to help!
cheers 馃嵒