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

commonMain.com.softartdev.theme.pref.ThemePrefs.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.pref

import androidx.compose.runtime.*

val LocalThemePrefs = staticCompositionLocalOf {
    error("CompositionLocal LocalThemePrefs not present")
}

abstract class ThemePrefs(
    val preferenceHelper: PreferenceHelper,
    val dialogHolder: DialogHolder = DialogHolder(),
) {
    val darkThemeState: MutableState = mutableStateOf(preferenceHelper.themeEnum)

    @Composable
    fun showDialogIfNeed() = dialogHolder.showDialogIfNeed()
}

object PreferableMaterialTheme {

    val themePrefs: ThemePrefs
        @Composable
        @ReadOnlyComposable
        get() = LocalThemePrefs.current
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy