aipok
06/16/2021, 5:11 AM.clickable
ripple effect color on the theme level to avoid
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(color = MaterialTheme.colors.secondary),
onClick = onClicked
)
every time I want to apply theme color?Zach Klippenstein (he/him) [MOD]
06/16/2021, 5:31 AMMaterialTheme
is what sets LocalIndication
, so you should just be able to set that to a different value underneath the theme composable to override it.aipok
06/16/2021, 6:01 AMMyTheme {
val rippleIndication = rememberRipple(color = colors.secondary200)
CompositionLocalProvider(LocalIndication provides rippleIndication) {
// other compose elements will have proper color for indication
}
}
But I’m not sure if I have to declare everything what was applied on the MaterialTheme as well. Also the place of this does not look right.aipok
06/16/2021, 6:05 AMZach Klippenstein (he/him) [MOD]
06/16/2021, 6:23 AMthe place of this does not look rightLooks like what I’d expect. I don’t know about whether MaterialTheme should make this easier to configure, it seems like material is pretty opinionated about what an official “Material ripple” should look like. I’m guessing this is veering close to building a custom design system for it to make sense for material to support it so directly, but idk.
aipok
06/16/2021, 6:47 AMopinionated
part 😄len
06/16/2021, 8:28 AMMyTheme
composable so that it's not 'outside of the theme'aipok
06/16/2021, 8:31 AMlen
06/16/2021, 8:33 AM@Composable
fun MyTheme(content: @Composable () -> Unit) {
MaterialTheme(...) {
val rippleIndication = rememberRipple(color = colors.secondary200)
CompositionLocalProvider(LocalIndication provides rippleIndication) {
content()
}
}
}
Something like this. I wrote it on the fly but it should look like thisaipok
06/16/2021, 8:34 AMLouis Pullen-Freilich [G]
06/16/2021, 11:05 AMLocalRippleTheme
for this