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

Correctly support Arrangement.spacedBy in ScrollbarAdapters for lazy lists/grids #380

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

m-sasha
Copy link
Member

@m-sasha m-sasha commented Jan 21, 2023

Proposed Changes

  • Add mainAxisItemSpacing property to LazyListLayoutInfo, LazyGridLayoutInfo and LazyStaggeredGridLayoutInfo, per discussion with Andrey Kulikov from Google.
  • Use the new mainAxisItemSpacing property to fix the line size approximation in LazyListScrollbarAdapter and LazyGridScrollbarAdapter

Testing

Test: manually and with a new unit test

Issues Fixed

Fixes: JetBrains/compose-multiplatform#2644

@m-sasha m-sasha requested a review from igordmn January 21, 2023 11:48
@@ -147,4 +153,5 @@ internal object EmptyLazyStaggeredGridLayoutInfo : LazyStaggeredGridLayoutInfo {
override val viewportEndOffset: Int = 0
override val beforeContentPadding: Int = 0
override val afterContentPadding: Int = 0
override val mainAxisItemSpacing: Int = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to wait for https://android-review.googlesource.com/c/platform/frameworks/support/+/2397134 to merge, and then cherry-pick it straight into jb-main

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The cherry-pick is part of this PR, so you can review it too.
Once approved, I will merge --ff-only this branch into jb-main, to avoid squashing the two commits.

Copy link
Collaborator

@igordmn igordmn Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's push the cherry-pick straight into jb-main.

The alternative process is as you described. It is better because we review everything that adds to the main branch, but worse because:

  1. we have to enable merging of PR's. If we do that, someone can use it, and don't bother about commits in the PR. It will spoil the git history.
  2. the review of a cherry-pick and a fix together is harder than just fixes.
  3. the 2. can be fixed by squashing the fix into a single commit, but it requires force-push, that is also not good for review.

Copy link
Collaborator

@igordmn igordmn Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, we also lose ability to run CI (we'll configure it in the future) on the cherry-pick.

And one more issue. When it will be merged, the code is become common. And when users tried to use it, they encounter noSuchMethod on Android. I don't know good way to solve it. We have 2 options:

  1. wait for the Jetpack release, and point to it in our sources. But if it will be 1.5, we can't merge it right now
  2. make public API internal, fix conflicts later (we should add comments near internal to describe how to solve conflicts)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll adjust the cherry-picked commit to make the new properties internal for now.

Base automatically changed from feature/scrollbar-adapter-for-lazygrid to jb-main January 24, 2023 15:15
@m-sasha m-sasha force-pushed the bugfix/scrollbar-with-arrangement-spacedby branch 3 times, most recently from 36db25f to f7efc4e Compare January 28, 2023 19:31
@m-sasha m-sasha requested a review from igordmn January 28, 2023 19:33
@m-sasha m-sasha force-pushed the bugfix/scrollbar-with-arrangement-spacedby branch from f7efc4e to 14075d9 Compare February 2, 2023 19:06
@m-sasha m-sasha merged commit 41c1b8f into jb-main Feb 2, 2023
@m-sasha m-sasha deleted the bugfix/scrollbar-with-arrangement-spacedby branch February 2, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrollbar works incorrectly with lazy list that uses Arrangement.spacedBy
2 participants