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 to set default start time 8 AM for each day of calender #352

Closed lokeshguptakiwi closed 1 year ago

richardtop commented 1 year ago

Is it a duplicate of #34?

lokeshguptakiwi commented 1 year ago

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.

richardtop commented 1 year ago

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

lokeshguptakiwi commented 1 year ago

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

richardtop commented 1 year ago
  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.
lokeshguptakiwi commented 1 year ago

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

richardtop commented 1 year ago

Could you please attach a video? Thanks

lokeshguptakiwi commented 1 year ago

https://user-images.githubusercontent.com/95008910/221539069-bdb69ce4-c14f-434d-a8f6-146a68cdc2b3.mov

Plz check in this video

richardtop commented 1 year ago

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.

lokeshguptakiwi commented 1 year ago

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

richardtop commented 1 year ago

And do you use animated:false with didMoveTo?

lokeshguptakiwi commented 1 year ago

yes on didMoveTo and same on willMoveTo.

richardtop commented 1 year ago

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.

lokeshguptakiwi commented 1 year ago

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

richardtop commented 1 year ago

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.

lokeshguptakiwi commented 1 year ago

oky..let me check this one..Thanks

richardtop commented 1 year ago

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