Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CompositionLocalProvider #102

Open
ln-12 opened this issue Oct 25, 2022 · 0 comments
Open

Support for CompositionLocalProvider #102

ln-12 opened this issue Oct 25, 2022 · 0 comments

Comments

@ln-12
Copy link

ln-12 commented Oct 25, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant