CalendarKit icon indicating copy to clipboard operation
CalendarKit copied to clipboard

API: moveTo(event:) or Select Event programmatically, similar to moveTo(date:)

Open boominadhapm opened this issue 5 years ago • 2 comments

Hi,

Thanks for the nice library. I just want to clarify my doubt which is required for my project implementation.

Currently I am using this library in my project to load the calendar events. But now I am having requirement like, I need to load the events on particular date and move/select to the particular event automatically while loading the events.

Let me know, Is it possible?

Thanks, Boominadha Prakash

boominadhapm avatar Nov 18 '20 06:11 boominadhapm

Hi, this is not available. Please take a look here: https://github.com/richardtop/CalendarKit/blob/7908671216d3bbe52a540172dc57f8edb890c972/Source/Timeline/TimelineContainer.swift#L42

I suggest you implement this feature and suggest a pull request. For example, you could start by defining an API on the DayViewController and all the way up to the Timeline:

func scrollToEvent(event: EventDescriptor, animated: Bool)

Or even

func scrollToEvent(event: EventDescriptor, at:ScrollPosition (top/middle/bottom/auto) animated: Bool)

Then, in the Timeline calculate the y(coordinate) of the event and scroll to it in the method I've shown.

You could add a method similar to this: https://github.com/richardtop/CalendarKit/blob/7908671216d3bbe52a540172dc57f8edb890c972/Source/Timeline/TimelineView.swift#L57

to the Timeline and return the y value of any event:

frameForEvent(event: EventDescriptor)

Another approach to finding just a y value without knowing the whole frame would be just using this function: https://github.com/richardtop/CalendarKit/blob/7908671216d3bbe52a540172dc57f8edb890c972/Source/Timeline/TimelineView.swift#L467

If you're interested, I'm looking forward to your pull request.

richardtop avatar Nov 18 '20 22:11 richardtop

Hi @richardtop

Thanks for the detailed explanation. I will check it and if possible, I will implement and create a pull request.

boominadhapm avatar Nov 19 '20 06:11 boominadhapm