https://kotlinlang.org logo
f

flosch

04/18/2020, 10:05 AM
Hey guys, I am trying to provide a
ColorPalette
appwide like that:
Copy code
object AppColors {
    private val primaryColor: Color = Color(0x464763)

    val lightPalette: ColorPalette = lightColorPalette(
        primary = primaryColor
    )

    val darkPalette: ColorPalette = darkColorPalette(
        primary = primaryColor
    )

    @Composable
    val currentPalette: ColorPalette
        get() = if (isSystemInDarkTheme()) darkPalette else lightPalette
}
When I use it for my
MaterialTheme(colors = AppColors.currentPalette) { … }
, the primary color is just invisible or set to transparent, what am I doing wrong? If I dont overwrite the primary, then everything works as expected (images in thread).
with custom
primary
without custom
primary
a

Andrey Kulikov

04/18/2020, 11:25 AM
can you try to write
Color(0xFF464763)
f

flosch

04/18/2020, 11:26 AM
oof 🤦 thanks
a

Andrey Kulikov

04/18/2020, 3:43 PM
it is too easy to make this mistake, we should do it automatically in some way. can you please file a bug so we we will not forget to make it easier? thanks!
g

Gabriel Feo

04/21/2020, 12:40 AM
Are you still having this issue? I noticed we can't pass a @Composable ColorPalette or a @Composable Typography to
MaterialTheme
@flosch
f

flosch

04/21/2020, 7:42 AM
No it worked after I corrected the hex
👌🏻 1
c

Chris Sinco [G]

04/21/2020, 4:17 PM
FWIW the new color picker in Studio can also help in the future on the line
Color
is used via the gutter icon. Also very useful for converting alpha % to hex.
g

Gabriel Feo

04/21/2020, 6:57 PM
Just an update, what I said before is not actually an issue. The problem is having a backing field for the @Composable ColorPalette, not the fact that it's @Composable https://issuetracker.google.com/issues/154531805
2 Views