Thread
#compose
    flosch

    flosch

    2 years ago
    Hey guys, I am trying to provide a
    ColorPalette
    appwide like that:
    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
    Andrey Kulikov

    Andrey Kulikov

    2 years ago
    can you try to write
    Color(0xFF464763)
    flosch

    flosch

    2 years ago
    oof 🤦 thanks
    Andrey Kulikov

    Andrey Kulikov

    2 years ago
    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!
    Gabriel Feo

    Gabriel Feo

    2 years ago
    Are you still having this issue? I noticed we can't pass a @Composable ColorPalette or a @Composable Typography to
    MaterialTheme
    @flosch
    flosch

    flosch

    2 years ago
    No it worked after I corrected the hex
    Chris Sinco [G]

    Chris Sinco [G]

    2 years ago
    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.
    Gabriel Feo

    Gabriel Feo

    2 years ago
    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 @Composablehttps://issuetracker.google.com/issues/154531805