richardtop / CalendarKit

📅 Calendar for Apple platforms in Swift

Home Page:https://www.youtube.com/watch?v=cJ63-_z1qg8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to set default start time 8 AM for each day of calender

lokeshguptakiwi opened this issue · comments

Is it a duplicate of #34?

No..I want to set 8AM the default start time of calendar for each day. If user want to see above and below time, he can scroll up and down.

Would scrollTo method of the dayView solve your issue?
https://github.com/richardtop/CalendarKit/blob/master/Sources/DayView.swift#L140

Just try using it like this:

dayView.scrollTo(hour24: 8, animated: true/false)

Let me know if this is an appropriate solution to your problem

yes its work..but when we click on another date ..its automatically shift to 12:00 AM.

  1. but when we click on another date - this is a limitation of the CalendarKit, as it doesn't preserve the scroll position when you click on the date in the header. Already reported as #211
  2. One workaround would be to invoke the dayView.scrollTo(hour24: 8, animated: true/false) method just after dayView.didMoveToDate delegate callback: https://github.com/richardtop/CalendarKit/blob/master/Sources/DayViewController.swift#L106 - let me know if this solution works for you.

yes, when i try to write scroll code in this method its working.. but their some jerk ...means its first show 12:00 for some millisecond then directly move to 8:00 AM

Could you please attach a video? Thanks

Screen.Recording.2023-02-27.at.3.56.14.PM.mov

Plz check in this video

And the exact code you're using for this? Maybe try using 'willMoveTo' instead of 'didMoveTo'? Let me know if there is any difference.
If this doesn't help, I'll convert this ticket to an enhancement.

No , when i move that line to willMoveTo..then nothing are happing.

And do you use animated:false with didMoveTo?

yes on didMoveTo and same on willMoveTo.

Ok, I've changed this to enhancement. Would you be willing to make relevant changes to the CalendarKit to implement this feature?

I can briefly explain how to achieve this functionality.

yes if you will help me..i will make changes.

Looks like this will need quite a big refactoring to make it posible. Unfortunately, CK doesn't keep the scroll position in the case of selecting a date via the header.

Please take a look at this code, as you see, the scrollToFirstEventIfNeeded() is executed on completion, so there will be some animation going on:
https://github.com/richardtop/CalendarKit/blob/master/Sources/Timeline/TimelinePagerView.swift#L446

I suggest for your case just use the method I've suggested, but with the animated:true parameter. It won't make it unnoticeable, although it will make the interface feel a bit more pleasing.

oky..let me check this one..Thanks

Please keep me updated on whether you resolve this issue either by my suggestion or by any other means...