Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lokeshguptakiwi opened this issue Feb 22, 2023 · 17 comments
Closed

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

lokeshguptakiwi opened this issue Feb 22, 2023 · 17 comments

Comments

@lokeshguptakiwi
Copy link

lokeshguptakiwi commented Feb 22, 2023

No description provided.

@richardtop
Copy link
Owner

Is it a duplicate of #34?

@lokeshguptakiwi
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@richardtop
Copy link
Owner

  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 move(to: ) forcing timeline view to 12:00 am  #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
Copy link
Author

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
Copy link
Owner

Could you please attach a video? Thanks

@lokeshguptakiwi
Copy link
Author

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

Plz check in this video

@richardtop
Copy link
Owner

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
Copy link
Author

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

@richardtop
Copy link
Owner

richardtop commented Feb 27, 2023

And do you use animated:false with didMoveTo?

@lokeshguptakiwi
Copy link
Author

yes on didMoveTo and same on willMoveTo.

@richardtop
Copy link
Owner

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
Copy link
Author

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

@richardtop
Copy link
Owner

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
Copy link
Author

oky..let me check this one..Thanks

@richardtop
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants