-
Notifications
You must be signed in to change notification settings - Fork 605
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
[Pager] Migrate to Modifier.scrollable #236
Conversation
d28be2c
to
c2b73fd
Compare
c2b73fd
to
282181a
Compare
282181a
to
eeb7513
Compare
a5e8bf6
to
836f30e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few things that might be clarified/commented.
Our test is still disabled because we need to make sure we snap to the correct page after an a11y scroll. Most a11y services will just scroll enough so that the item is in view port, which isn't how Pager works.
This allows us to remove our workaround for https://issuetracker.google.com/182893298
We also speed up the snapping animation via a stiffer spring
c55df48
to
d42994e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Chris, just two smallish comments!
@IntRange(from = 1) offscreenLimit: Int = 1, | ||
content: @Composable PagerScope.(page: Int) -> Unit | ||
decayAnimationSpec: DecayAnimationSpec<Float> = defaultDecayAnimationSpec(), | ||
snapAnimationSpec: AnimationSpec<Float> = spring(stiffness = SnapSpringStiffness), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's is an idea: since your internal PagerState.fling uses only public API available (if not, it's still a good idea :) ) what you can do here is to replace two animation specs with one FlingBehaviour, e.g.
object PagerDefaults {
@Composable
fun defaultPagerFlingConfig(state: PagerState, decayAnimationSpec: DecayAnimationSpec<Float>, snapAnimationSpec: AnimationSpec<Float>): FlingConfig { ... }
}
Or similar, then you can just open the whole flingbehaviour for overriding (make FlingBehaviour a param in HorizontalPager), so people can:
- Use default behavior by providing nothing
- Use default with tweaked params
- Use their own sophisticated or slightly different fling behaviour by providing their own instance.
- The API for customization will be consistent with LazyColumn and friends.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I like it, I'll follow up after #254
val density = LocalDensity.current | ||
val decay = remember(density) { splineBasedDecay<Float>(density) } | ||
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl | ||
val reverseDirection = if (isRtl) !reverseLayout else reverseLayout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do if (isRtl) reverseLayout else !reverseLayout
to "reverse the reverse", do you still need the shenanigans with minuses in the rest of the logic?
Fixes #247