richardtop / CalendarKit

📅 Calendar for Apple platforms in Swift
https://www.youtube.com/watch?v=cJ63-_z1qg8
MIT License
2.48k stars 333 forks source link

How can I set a blank space for user to press to add new event on timeline? #322

Closed qubyedev closed 2 years ago

qubyedev commented 2 years ago

Hi Richard,

For example, now no matter I creat 1 or seeral events on the same time (15:00), it's always occupy the full width. But what I want to do is have a blank space at the right side so user can press that area to do some functions. [0,1,2,X]

Which file and which function should I edit if I fork it? Thanks

richardtop commented 2 years ago

Hi, please modify this method to add some "protected" space where the events won't be placed: https://github.com/richardtop/CalendarKit/blob/master/Sources/Timeline/TimelineView.swift#L433

qubyedev commented 2 years ago

Thanks Richard. Btw, may I know how to implement press event or long press event on timeline each time block?

richardtop commented 2 years ago

Hi, to implement those events, use the DayViewDelegate:

  1. Press event: func dayView(dayView: DayView, didTapTimelineAt date: Date)
  2. Long Press event: func dayView(dayView: DayView, didLongPressTimelineAt date: Date)

Examples in the CalendarApp: How to handle Long Press Timeline Event How to handle Long Tap Timeline Event

Video: Watch implementation of those two methods in the CalendarApp live

qubyedev commented 2 years ago

Thanks, Richard :D

richardtop commented 2 years ago

Feel free to close this issue if your problem is resolved.