-
Notifications
You must be signed in to change notification settings - Fork 810
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
Update all calendarView cells when new date is selected. #554
Comments
OK. I'm @ work. I'll read it in more after im done. |
ok, whenever you call calendarView.selectDates([date], triggerSelectionDelegate: false) This will cause the In the cellForItem function, put the stuff in there the configure the cell. Let me know if this helped? |
I havent looked at you new question thoroughly yet, but |
Yes!!! That would solve this issue perfectly! |
Yes, the code on master branch has this update. But I am still working on it. Devs will have to implement the I did not want devs to implement this function by because synchronization issues due to Apple cell pre-fetching, the apple documents recommended that we implement it. I am currently doing more research on this to come up with a more elegant solution. To test master branch, put this in your pod file, then do a
|
I just added the pod. Next steps: applying changes and testing it. I'll surely let you know how it goes soon. |
ouch. thats a bad issue. @santiagoprieto by the way, here are the changes I was talking about earlier about master branch -> #553 |
@santiagoprieto if youre still online can you join me here? https://gitter.im/patchthecode/JTAppleCalendar I do not understand how you got so many right selections. |
Hahaha no worries, man. For now I can move forward with this and later improve it. |
OK i misunderstood. I thought the screen shot you showed above was a bug i introduced accidentally. If it is not, then I guess I can close this issue? |
Oh! Sorry. I just saw your message about joining you in gitter. I did some extra tests to see what functions were being called to create the array of selected dates and I figured out what was going on. It was something very lame on my side. When I read the below:
I forgot to remove the deque part:
So basically I was dequeuing new cells every time. 😲 Anyway, I thought you'd like to know that now it's working like a charm. It feels soooo good. Thanks for your patience and sorry for freaking you out about a possible bug. Awesome work with these new features!!! Here's the final code func calendar(_ calendar: JTAppleCalendarView, didScrollToDateSegmentWith visibleDates: DateSegmentInfo) {
setupCalendarView(from: visibleDates)
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date:Date, cellState: CellState, indexPath:IndexPath) ->JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "DayCell", for: indexPath) as! DayCell
cell.label.text = cellState.text
cell.handleSelected(cellState: cellState)
return cell
}
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
guard let cell = cell as? DayCell else {return}
cell.handleSelected(cellState: cellState)
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
if cellState.selectionType == SelectionType.userInitiated {
updateDatesWithSelected(deliverDate: date, cell: cell, cellState:cellState)
} else {
guard let cell = cell as? DayCell else {return}
cell.handleSelected(cellState: cellState)
}
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
if cellState.selectionType == SelectionType.userInitiated {
updateDatesWithSelected(deliverDate: date, cell:cell, cellState:cellState)
} else {
guard let cell = cell as? DayCell else {return}
cell.handleSelected(cellState: cellState)
}
} |
Awesome man. Good stuff. |
Hey Jay, I currently added JTAppleCalendar v 7.0 to my app and I'm loving it! Thanks for the great work and saving the dev community a ton of time. I feel lame asking this but haven't found a way to solve my issue, which seems to be like something that's super simple that I'm not doing. Any pointers or support would be hugely appreciated!
A) What's happening
In the didSelectDate method, I'm adding a function with the hope of triggering multiple date calculations, but as I added this function here, it created an infinite loop when loading the viewController. I believe this is happening because the calendarView.selectDates([date]) calls the didSelectDate method. So I changed it to calendarView.selectDates([date], triggerSelectionDelegate: false) which solved the infinite loop issue! However, now as you select a new date it won't update the rest of the cells.
B) What I would want to happen
This is important to my app because the selected date has a "tail of dates". As it's a mailing service, the selected date is the "Deliver By" date, and the tail of dates shows the user the shipping time required. My hope is that by pressing the selected date, the rest of the cells update to show this tail.
Screenshot of how that tail looks:
Screenshot of how that tail looks when a new date is selected:
The latest code I'm using:
The text was updated successfully, but these errors were encountered: