YokanThemeFromSettings.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/theme/YokanThemeFromSettings.kt
1package eu.friedcutlet.yokan.ui.theme23import androidx.compose.runtime.Composable4import androidx.compose.runtime.LaunchedEffect5import eu.friedcutlet.yokan.database.DbSettings6import eu.friedcutlet.yokan.services.system.isTvDevice7import eu.friedcutlet.yokan.ui.tv.resolveTvUiScale89/** [YokanTheme] as configured in [db]; [themeIsDark] is the user's dark-mode choice when not following the system. */10@Composable11fun YokanThemeFromSettings(db: DbSettings, themeIsDark: Boolean, content: @Composable () -> Unit) {12 val systemDark = rememberSystemDark()13 // E-ink display mode is always black on white.14 val appDark = !db.einkMode && resolveDarkMode(15 followSystem = db.followSystemTheme,16 themeIsDark = themeIsDark,17 systemDark = systemDark,18 )19 // Android: system bar icon contrast must follow the in-app theme, which20 // can diverge from the system dark mode (followSystemTheme = false).21 LaunchedEffect(appDark) { applySystemBarTheme(appDark) }22 YokanTheme(23 darkTheme = appDark,24 schemeIndex = db.flexSchemeColorIndex,25 pureBlackDark = db.pureBlackDarkMode,26 blendLevel = (db.flexColorSchemeBlendLevel / 100.0).toFloat().coerceIn(0f, 1f),27 uiScale = resolveTvUiScale(isTvDevice(), db),28 seedColorArgb = db.themeSeedColor,29 seedImagePath = db.themeSeedImagePath,30 materialYou = db.materialYou,31 materialExpressive = db.materialExpressive,32 paletteStyleName = db.themePaletteStyle,33 fontFamily = resolveAppFontFamily(db.appFontFamily),34 eink = db.einkMode,35 content = content,36 )37}38