google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.43k stars 598 forks source link

[Pager] Migrate from Snapper to SnapFlingBehavior; Support Snap on Mouse Scroll #1470

Closed cotysaxman closed 1 year ago

cotysaxman commented 1 year ago

Tested the Pager code in isolation in my Compose Multiplatform project (MacOS + Android), and tested the Android sample.

Background: I needed to use Pager in a Compose Multiplatform project, and made these two changes in order to accommodate that. I'm not sure what else is needed for Accompanist to support compose-jb, but this fixes Pager.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

cotysaxman commented 1 year ago

@Levi-Moreira Thank you for reviewing!

The full context leading up to my pull request is that I needed a Date Picker for a Compose Desktop application. This led me to adopting an open-source Material UI Calendar View meant for Android, which depended on Accompanist. SnapFlingBehavior being incompatible with mouse-based click-and-drag seems to be a known blocker for Compose Multiplatform compatibility (I believe it was mentioned on a Snapper issue before deprecation).

For my own uses, I cloned only Pager and PagerState, and developed these changes in isolation. SnapFlingBehavior is available on multiplatform with Compose 1.3.0+ (currently available in RC), so a local copy of Pager/PagerState along with compose-jb 1.3.0-RC was my best solution.

Adding this mouse solution to Foundation's Pager seems like a great idea, but it will only help multiplatform users when Compose 1.4.x is made available for compose-jb.

I believe Compose on Android should want mouse support, so if you think Foundation Pager is a better target for these changes I can test them against that target when I have the chance.

bentrengrove commented 1 year ago

Thank you for this. I'm going to close it as we are currently in the process of deprecating Pager in accompanist and are not accepting any new PRs for it.