Reputation: 277
On the Material and Material2 Compose there was a SwipeableState and a swipeable option on the Modifier. But in Material3 this doesn't exist, at all. So how do you create a Swipeable in Material3? If anyone knows please share.
Upvotes: 9
Views: 4312
Reputation: 5453
The successor of Swipeable is AnchoredDraggable with AnchoredDraggableState
and Modifier.anchoredDraggable
. They were introduced in Compose-Foundation 1.6.0-alpha01 and are still experimental. Here is the migration guide (that unfortunately misses a complete example): https://developer.android.com/jetpack/compose/touch-input/pointer-input/migrate-swipeable
Upvotes: 4
Reputation: 199805
This kotlinlang
slack includes a link to issue 229839039, which is about making SwipeableState
public in the Material3 Compose library and a discussion about what you should be doing:
We are currently evaluating the API surface we want to offer for Swipeable, including a possible Foundation API. As there are quite a few issues with Swipeable, we haven't made it public in M3 yet.
Comment #2 on the issue linked above gives you the full explanation and recommendations if you need something to give to your leads 😃
For the time being, we recommend forking Swipeable if you need it in M3!
So you can either also include the Material2 Compose library and use its Swipeable
or fork it entirely (i.e., copy/paste the code into your project) and use it directly.
Upvotes: 9