All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.softartdev.theme.material.PreferableMaterialTheme.kt Maven / Gradle / Ivy

Go to download

Kotlin Multiplatform library for easy switching Dark/Light Material themes on Compose.

There is a newer version: 0.9.1
Show newest version
package com.softartdev.theme.material

import androidx.compose.material.Colors
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import com.softartdev.theme.pref.*

@Composable
fun PreferableMaterialTheme(
    preferHelper: PreferenceHelper = rememberPreferenceHelper(),
    dialogHolder: DialogHolder = DialogHolder(),
    darkColorPalette: Colors = darkColors(),
    lightColorPalette: Colors = lightColors(),
    content: @Composable PreferableMaterialTheme.() -> Unit
) {
    val themePrefs = rememberThemePrefs(preferHelper, dialogHolder, darkColorPalette, lightColorPalette)
    CompositionLocalProvider(
        LocalThemePrefs provides themePrefs,
    ) {
        MaterialTheme(
            colors = themePrefs.colors,
            content = { PreferableMaterialTheme.content() }
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy