https://kotlinlang.org logo
#compose
Title
# compose
d

David Corrado

03/05/2022, 12:10 AM
I want to know if it's possible to correctly implement something like MaterialTheme.colors.isOnPrimary. 🧵
I came up with a small example of implementing many of the compose components. Which you can see here https://github.com/DavidCorrado/ComposeCustomDesignSystem I really did not do anything really custom here just putting all the components and sometimes on a Primary, Background, or Surface. I am hoping I can just get them to dynamically look good on top of all of these surfaces. It does not appear to do that for free. So how I wanted to fix that is wrap these views in composable functions. Problem there was in those you only have access to MaterialTheme.colors.isLight. Which is great but also would like to have power over detecting what surface color I am on. So something like MaterialTheme.colors.isOnPrimary. I posted about that before and I was suggested to do something like this:
Copy code
val Colors.isOnPrimary: Boolean
    @Composable
    get() = MaterialTheme.colors.onPrimary == LocalContentColor.current
Problem with the above is current is the current text color which I have the onPrimary to always be Color.White. But in dark mode basically all of the colors are White by default. So I could slightly change the color so its not technically white for onPrimary to get this to work but that seems hacky.
Also secondary question is it seems like the Controls do not appear to work well onPrimary. Anyone know more about that. See screenshot from the above project
Created a ticket to Compose team https://issuetracker.google.com/issues/223248892