-
Notifications
You must be signed in to change notification settings - Fork 517
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
Week Calendar scroll to past skips not scrolls #567
Comments
Hi, sorry I do not fully understand. In the video, I see both forward and backward scrolls. Can you explain further? Some pointers:
It is difficult to tell what is incorrect since the code is incomplete. You can check if this issue is happening in the sample project or try to reproduce it there, then I can easily have a look. |
At second 6 the backwards scroll appears, and if you look at a date, it changes from July 10th to July 3rd (at second 7), but the calendar doesn't scroll, it just skips and the icons change. Then more scrolling was supposed to happen but i just skips to June 26th, June 19th, June 12th... Thank you |
I am able to scroll fine in the sample project, so it is hard to tell what is intercepting the scroll behaviour in your app. Could it be the drawer? scroll.mp4 |
How would I figure that out? I am still using the old Android Views for the app, and this is just a ComposeView that is part of the today screen's fragment. |
It's hard to tell since I do not have access to the project. I'd suggest isolating the calendar composable, then create and run a preview of the composable to see the issue happens there. |
I get an error when trying to run it on device (composable not found -- probably because I have modules, and maybe because my app is still mostly set up for views). However, the interactive mode, seems to work fine. If this is a symptom of the Composable being inflated inside of a good ol' fragment, and the navigation drawer messing things up, what are my options for workarounds? It's going to be a while before everything is rewritten in compose. |
I did find this in the main activity, but removing it didn't help the symptom: |
Not sure how else I can help here, unfortunately. |
Could you maybe try removing all calls to val currentDate = remember { LocalDate.now() }
val currentMonth = remember { YearMonth.now() }
val startDate = remember { currentMonth.minusMonths(100).atStartOfMonth() }
val endDate = remember { currentMonth.plusMonths(100).atEndOfMonth() }
val firstDayOfWeek = remember { firstDayOfWeekFromLocale() }
val state = rememberWeekCalendarState(
startDate = startDate,
endDate = endDate,
firstVisibleWeekDate = currentDate,
firstDayOfWeek = firstDayOfWeek
) |
I think we have hit the nail on the head. Do you have a recommended flow for the following:
Thank you |
I have realized that I'm missing the part where we only take into account the ! scrolling actions like here: That mostly solves the problem of the odd 'snap behavior' when scrolling into the past. There is still times when I try to scroll more like a fling behavior, and then it still behaves rather oddly. |
After digging in a little more, this is what I came up with. I admit, the previous solution was mostly just a direct translation from view's based view.
|
I had the same problem with monthly calendar. It was because I passed a dynamically changing |
I have another interesting problem now. It looks like scrolling works great (possibly because I was doing something similar that @DanielRendox mentioned), however, the date that I'm observing in view model can be changed on a different screen. For example, I open a full screen calendar fragment, select a date, and then navigate up from that screen to end up in a week view (the app is still half written in fragments/views). So when the app returns to the screen with a week view, this code takes over:
So essentially the scrolling always takes over regardless of what was selected somewhere else. Is there a good way to manage this state to know whether it has been scrolled or not? |
I do not understand this, please explain further. |
Library information:
Describe the bug**
I recently migrated from Views to Compose, so I just went with the newest library (but I also tried 2.5.2 which is the last stable version). When I try to scroll, it only scrolls forwards, but not backwards. Is that a setting that I accidentally set somewhere, or is that a bug? Thank you
Expected behavior (if applicable)
Ability to scroll forwards and backwards.
Screenshots? (if applicable)
Attached screen recording.
Screen_Recording_20240724_182411_trainwell.mp4
Additional information
The text was updated successfully, but these errors were encountered: