So I'm trying to create a custom implement of Page...
# compose
o
So I'm trying to create a custom implement of Pager that reacts to the direction the user swipes and turns to an horizontal or vertical pager based on the swipe direction. I'm currently at a road block that has to do with the .scrollableArea modifier and the ScrollableState which Pager implements. I have a mutable state orientation in the pager state that I passed to .scrollableArea modifier, but because of the way modifiers are applied in compose, the orientation doesn't actually change on the user first drag but rather the second. So I'm at a cross road for my next step. More in thread🧵
I'm considering the drastic rewrite. Which is changing Pager to implement Scrollable2DState instead to be able to more natively get the x or y deltas and work my way from there. Or. more like but. Before that, I'd like to know if it's possible to create like a custom wrapper for . scrollableArea that adds a key parameter that I can pass my orientation to and if it changes, reconstruct the modifier with the new orientation. And if this would solve my issue and make the orientation change happen on the first user drag. I'm still a noob, so just wanted to confirm if this more simpler approach is possible before going down that Scrollable2DState rewrite rabbit hole
k
Instead of changing the orientation based on the first drag, can't you just implement the scrollableArea twice? I don't have any experience using this, but using horizontalScroll and verticalScroll also works. Without testing, it probably will apply the horizontal or the vertical based on your drag. scrollable2D is so you can also scroll diagonally, at least that's why I used it (had its own problems). So it depends. Scrollable2D will probably need more custom code (it isn't really a scrollable container, but just passes the values, which you can apply an offset to a view for example). So I would try getting the scrollableArea to work and if that really doesn't work, then look into scrollable2D.
o
Ok, I'll try that out