compose-richtext
compose-richtext copied to clipboard
Support for `CompositionLocalProvider`
I want to display my text with an alpha value dependent on its state. Usually, I would do it like shown here to wrap all composables which should be affected:
CompositionLocalProvider(LocalContentAlpha provides if(isDisabled) { ContentAlpha.high } else { ContentAlpha.disabled }) {
RichText(
modifier = Modifier.padding(8.dp),
) {
Markdown(message.body)
}
}
However, this solution does not work with RichText
, so I found this alternative solution:
MaterialRichText(
modifier = Modifier.alpha(if(isDisabled) { ContentAlpha.high } else { ContentAlpha.disabled })
) {
RichText(
modifier = Modifier.padding(8.dp),
) {
Markdown(message.body)
}
}
Are you planning to support setting values using CompositionLocalProvider
?