kotlinandroid-jetpack-compose

What's the replacement for rememberRippleIndication in JetpackCompose 1.0.0-alpha11?


In JetpackCompose 1.0.0-alpha08, the below code is legitimate, where by indication = rememberRippleIndication(...) is okay.

    Surface(
        modifier = modifier.padding(4.dp).clickable(
            onClick = { },
            indication = rememberRippleIndication(
                color = color.value.rippleColor()
            )
        )
    ) {
    }

However in 1.0.0-alpha11, the indication parameter doesn't exist anymore for clickable, and the rememberRippleIndication also doesn't exist. What's the replacement?


Solution

  • You need to use another Modifier.clickable() which also requires InteractionState.

    Also rememberRippleIndication has been deprecated and replaced with rememberRipple.

    Surface(
        modifier = modifier.padding(4.dp).clickable(
            onClick = { },
            indication = rememberRipple(
                color = color.value.rippleColor()
            ),
            interactionState = remember { InteractionState() }
        )
    ) { }