mrmans0n / compose-rules

Lint rules for ktlint/detekt aimed to contribute to a healthier usage of Compose. Actively maintained and evolved fork of the Twitter Compose rules.
https://mrmans0n.github.io/compose-rules
Other
543 stars 20 forks source link

Material2 rule / rememberRipple violation #224

Closed egorikftp closed 4 months ago

egorikftp commented 4 months ago

io.nlopez.compose.rules:detekt:0.3.15

Fail if we use Material 3 in the project and try to make custom ripple effect

androidx.compose.material.ripple.rememberRipple

@Composable
fun TestRipple(
    selected: Boolean,
    onClick: () -> Unit,
    enabled: Boolean = true
) {
    Box(
        modifier = Modifier
            .selectable(
                selected = selected,
                onClick = onClick,
                enabled = enabled,
                interactionSource = remember { MutableInteractionSource() },
                indication = rememberRipple(bounded = false),
                role = Role.Tab,
            )
            .fillMaxHeight()
    ) {
        Text(text = "Select")
    }
}

looks like will be change in Compose 1.7.0 https://developer.android.com/develop/ui/compose/touch-input/user-interactions/migrate-indication-ripple

mrmans0n commented 4 months ago

You can add it to your detekt configuration as an exception while you migrate to the new ripple:

  Material2:
    active: true
    allowedFromM2: ripple
egorikftp commented 4 months ago

Thanks, can be with your example due to it will be removed in next Compose version 🙂