Regarding Swipe-to-Reveal, I am using it as a way ...
# compose-wear
n
Regarding Swipe-to-Reveal, I am using it as a way of saving an item. I would then like the item to bounce back into its original position. How could I do that? I'll put my code in the thread.
Copy code
SwipeToReveal(
                        onFullSwipe = {
                            Toast.makeText(
                                context,
                                "Saved to Phone!",
                                Toast.LENGTH_SHORT
                            ).show()
                        },
                        primaryAction = {
                            Box(
                                modifier = Modifier
                                    .fillMaxSize()
                                    .clickable { /* Add the primary action */ },
                            ) {
                                Icon(
                                    imageVector = Icons.Outlined.Star,
                                    contentDescription = "Star"
                                )
                            }
                        }
                    ) {
                        ResultsChip(
                            item.id,
                            item.feedItem.title,
                            navController
                        )
                    }
y
Add something like the following to onFullSwipe?
Copy code
scope.launch {
                state.snapTo(RevealValue.Covered)
            }
Pass in rememberRevealState() to your SwipeToReveal.
n
Lovely, many thanks Yuri!
1
y
One general tip. There are a bunch of demos and samples in cs.android.com. show a lot of these types of cases. Just search for the component name.
👍 1
s
Note that whilst the gesture-handling for swipe-to-reveal is in the Foundation library, we've added SwipeToRevealChip and SwipeToRevealCard in the Material library that make it easier to follow UX guidance (these work with the respective Wear Compose Material Chip/Card components). See 1.3.0-alpha03 release notes.
🙏 1