JetpackCompose 1.0.0-alpha11 中 rememberRippleIndication 的替代品是什么?

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

在 JetpackCompose 1.0.0-alpha08 中,下面的代码是合法的,其中 indication = rememberRippleIndication(...) 是可以的。

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

但是在 1.0.0-alpha11 中,clickableindication 参数不再存在,rememberRippleIndication 也不存在。什么是替代品?

您需要使用另一个 Modifier.clickable(),它还需要 InteractionState

另外 rememberRippleIndication 已被弃用并替换为 rememberRipple

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