alexstyl / compose-tinder-card

A Jetpack Compose Modifier that enables Tinder-like card gestures.
Apache License 2.0
165 stars 13 forks source link

Not able to swipe more than one card #5

Closed Mcrich23 closed 1 year ago

Mcrich23 commented 1 year ago

Hi there! I am very new to Jetpack Compose and am trying to use your library. However, when I use this code, I can't swipe more than the first one. How do I fix it?

@Composable
fun SwipableCard(name: String) {
    val state = rememberSwipeableCardState()
    Box(
        modifier = Modifier
            .fillMaxSize()
            .swipableCard(
                state = state,
                onSwiped = { direction ->
                    println("The card was swiped to $direction") },
                onSwipeCancel = {
                    println("The swiping was cancelled")
                }
            )
            .background(Color.Magenta)
    ) {
        // contents ...
        Greeting(name = name)
    }
}

Called with:

    for (name:String in names.reversed()) {
        SwipableCard(name)
    }
}
alexstyl commented 1 year ago

Does the sample app work for you?

alexstyl commented 1 year ago

Closing due to inactivity

gianlucadest commented 7 months ago

if (swipeState.swipedDirection == null) {}

If the Swipe is completed, the corresponding Card shouldnt compose again. Add the upper if-Condition and you should be fine.