Thread
#compose
    a

    alorma

    1 year ago
    Hi! One question... What's the best way to have a list of themes? SO we can create a theme switcher
    Javier

    Javier

    1 year ago
    For preview or in general?
    For first one check this

    https://youtu.be/exjL2kGPngI

    a

    alorma

    1 year ago
    for "prod"
    Javier

    Javier

    1 year ago
    I would go for a some Enum which I can save in some way in DataStore, so when the user select one theme, you can observe it an apply automatically
    a

    alorma

    1 year ago
    data class MaterialThemeHolder(
        val name: String,
        val lightColors: Colors,
        val darkColors: Colors,
        val shapes: Shapes,
        val typography: Typography
    ) {
    
        @Composable
        fun compile(
            isDark: Boolean = isSystemInDarkTheme(),
            content: @Composable () -> Unit,
        ) {
            MaterialTheme(
                colors = if (isDark) darkColors else lightColors,
                shapes = shapes,
                typography = typography,
                content = content,
            )
        }
    }
    I went to something like this, as I'm doing a catalog
    Afzal Najam

    Afzal Najam

    1 year ago
    Essentially the same thing but with an abstraction layer, this is what the new project wizard creates: https://github.com/AfzalivE/Fun-Compose/blob/main/app/src/main/java/com/afzaln/funcompose/ui/Theme.kt