CalendarKit
CalendarKit copied to clipboard
zPosition enhancement for eventViews
New Issue Checklist
- [x] Use the latest version of CalendarKit
- [x] I've read the Contribution Guidelines
- [x] I've searched for existing GitHub issues
Issue Description
I am trying to add zPosition to eventView.layer. Currently, there seems to be no right way to do it without editing the library code. (since I intend to use the library for long I would prefer not to edit library code). I will be willing to take up this issue and make a pull request. zPosition can be defaulted to 0. This issue occurs only when eventsWillOverlap is true. Essentially I have a hierarchy where for every day I have free time and working time and under them I have subEvents. However, if I call reloadData the events move on top of each other in an undesired manner. By adding zPosition this issue will be resolved. Is there an enhancement you would be open to?
Code I'm using with CalendarKit
[INSERT CODE HERE]
Result I am trying to achieve
[INSERT API OR UI MOCKUPS HERE]
Hi, yes please go ahead with the pull request! Also, could you please share some screenshots showing the issue and the desired behavior?

As you will see In the above two files, currently non-work time is drawing under work-time, same for holiday. I can't seem to control this flow without changing the library code. For the same, I will be editing a bit of calendarKit code and likely making a pull request this week
@aditya-rastogi23 thanks for the idea, but I suggest changing the layout algorithm, as it could put smaller events on top of the larger ones and the beginning of the event on top of the end of the event.
Could you please attach a project with the reproducible example of this issue?
I'm not sure how you're getting the results as shown on the screenshot, as the current CalendarKit layout algorithm should produce the results as shown:

Please, provide a reproducible example or sample code you're using to achieve the result shown on the screenshot, or I'll have to close this issue.
Hey! I will be attaching the project in a couple of days. Having some issues with my setup. The screenshot you've provided I believe does not use the eventsWillOverlap as true, correct me if I am wrong.
Thank you for getting back quickly! Yes, you're right. eventsWillOverlap feature is not commonly supported, so there might be issues.
Once you attach the project, I'll be able to help you troubleshoot the issue.
Hey! sorry for taking so long but you can find a sample project with this issue here: https://github.com/aditya-rastogi23/calendarKitExample The solution for this that I found optimal would be to allow users to define their own zPosition for each event. The zPosition for eventView.layer.zPosition can be updated using event.zPosition once the events are dequeued and added to their respective superview.
Hi, thanks for following up.
Few comments:
- event reuse is actually disabled right now and could be completely removed from the library.
- I'd also recommend taking a look at simpler solution: there is an option to set a z-position of the events happening later to a higher value than that of the events happening earlier.
E.g.
Event 1 - 10:00 - 13:00 - zPosition 0 Event 2 -12:00 - 14:00 - zPosition 1 .....
That would keep zPosition property out of the Event completely, so that the interface would be cleaner.
Later, I plan on introducing an option to plug in a custom layout algorithm, so that you'll be able to control and modify behaviors like that programmatically.
How am I supposed to access the zposition of events?(or access eventview in general) I don't want to alter the library code
@aditya-rastogi23 indeed, I encourage you to alter the library code and submit a pull request which will be incorporated in the next version of the library. How does that sound?
Sounds good I'll start working on it
HI aditya any update on that issue ?
My MacOS basically broke down, will not be able to work on it till august