I am using compose version 1.1.1
in my project. I am using LocalRippleTheme
like this
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Surface
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ClickableItemContainer(
rippleColor: Color = TealLight,
content: @Composable (MutableInteractionSource) -> Unit,
clickAction: () -> Unit
) {
val interactionSource = remember { MutableInteractionSource() }
CompositionLocalProvider(
LocalRippleTheme provides LgcRippleTheme(rippleColor),
content = {
Surface(
onClick = { clickAction() },
interactionSource = interactionSource,
indication = rememberRipple(true),
color = White
) {
content(interactionSource)
}
}
)
}
when I update to compose version to 1.2.1
I am getting weried error message on Surface
Using 'Surface(() -> Unit, Modifier = ..., Shape = ..., Color = ..., Color = ..., BorderStroke? = ..., Dp = ..., MutableInteractionSource = ..., Indication? = ..., Boolean = ..., String? = ..., Role? = ..., () -> Unit): Unit' is an error. This API is deprecated with the introduction a newer Surface function overload that accepts an onClick().
You have to remove the indication
attribute:
Surface(
onClick = { clickAction() },
interactionSource = interactionSource,
color = White
) {
content(interactionSource)
}
The M2 1.2.0
deprecated the clickable Surface
function with the introduction a newer Surface
function that accepts an onClick()
.
With this API you can't define the indication
that is defined internally by the clickable
modifier.