https://kotlinlang.org logo
Title
b

Brad Harris

09/07/2021, 10:45 PM
@cb I saw you made a custom swipe to refresh in the accompanist library. But I like how YouTube on iOS works. How hard would this be to implement. While looking at your source code as a reference. There are some differences though like the list slides down as the indicator slides down.
l

Luis

09/07/2021, 11:57 PM
I know that on iOS, scrolling has a spring animation attached to it, so you can overscroll. Detecting that overscroll is as easy has checking the scroll offset.
On Android, you will probably need to fake the overscroll by adding some space, and then adjusting the scroll to always stick to after the Space. Then you would also need a spring animation that would scroll with the same resistance has it does on iOS, so it doesn’t feel like a normal scroll it feels like you are pulling something
Thats why you don’t usually see the same pull to refresh on Android, out of the box we don’t have those sweet spring animations that iOS has
b

Brad Harris

09/08/2021, 12:00 AM
Yeah :/ it’s complicated to get working perfectly
c

Chris Sinco [G]

09/08/2021, 3:02 AM
out of the box we don’t have those sweet spring animations that iOS has
Out of the box in iOS == baked into a List control and/or container that has scrolling?
l

Luis

09/08/2021, 4:54 AM
Yep, a UIScrollView uses a spring animation to deal with the overscroll
c

Chris Sinco [G]

09/08/2021, 5:52 AM
Gotcha. The Android 12 overscroll effect and the current glow effect are coming soon. But the springy effects are not in there since that’s not the design. But perhaps it’s worth exploring with Compose to animate things more in the platform
That is to say the baseline motion design will always be the look and feel of the platform first for overscroll in Compose Android. To have it behave more like iOS is not something we’d do out of the box. And even if we could make it possible to override I don’t think that’s desirable from the ecosystem POV where scrolling looks different across apps.
c

cb

09/08/2021, 6:34 AM
It should be fairly easy to overscroll the list. You could apply
Modifier.offset(swipeRefreshState.indicatorOffset)
to the list, which should work
:jetpack-compose: 4
🤯 2
+1 to Chris’ points though. Don’t look to YouTube for platform design guidance.