|
|
|
|
@ -16,18 +16,14 @@
|
|
|
|
|
|
|
|
|
|
package com.google.samples.apps.nowinandroid.core.designsystem.theme
|
|
|
|
|
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
|
import androidx.compose.material3.darkColorScheme
|
|
|
|
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
|
|
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
|
|
|
import androidx.compose.material3.lightColorScheme
|
|
|
|
|
import androidx.compose.material3.surfaceColorAtElevation
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -64,7 +60,6 @@ val LightDefaultColorScheme = lightColorScheme(
|
|
|
|
|
/**
|
|
|
|
|
* Dark default theme color scheme
|
|
|
|
|
*/
|
|
|
|
|
@VisibleForTesting
|
|
|
|
|
val DarkDefaultColorScheme = darkColorScheme(
|
|
|
|
|
primary = Purple80,
|
|
|
|
|
onPrimary = Purple20,
|
|
|
|
|
@ -96,7 +91,6 @@ val DarkDefaultColorScheme = darkColorScheme(
|
|
|
|
|
/**
|
|
|
|
|
* Light Android theme color scheme
|
|
|
|
|
*/
|
|
|
|
|
@VisibleForTesting
|
|
|
|
|
val LightAndroidColorScheme = lightColorScheme(
|
|
|
|
|
primary = Green40,
|
|
|
|
|
onPrimary = Color.White,
|
|
|
|
|
@ -128,7 +122,6 @@ val LightAndroidColorScheme = lightColorScheme(
|
|
|
|
|
/**
|
|
|
|
|
* Dark Android theme color scheme
|
|
|
|
|
*/
|
|
|
|
|
@VisibleForTesting
|
|
|
|
|
val DarkAndroidColorScheme = darkColorScheme(
|
|
|
|
|
primary = Green80,
|
|
|
|
|
onPrimary = Green20,
|
|
|
|
|
@ -196,10 +189,10 @@ fun NiaTheme(
|
|
|
|
|
// Color scheme
|
|
|
|
|
val colorScheme = when {
|
|
|
|
|
androidTheme -> if (darkTheme) DarkAndroidColorScheme else LightAndroidColorScheme
|
|
|
|
|
!disableDynamicTheming && supportsDynamicTheming() -> {
|
|
|
|
|
val context = LocalContext.current
|
|
|
|
|
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
|
|
|
|
}
|
|
|
|
|
// Workaround for dynamic theming support in Compose Multiplatform
|
|
|
|
|
// !disableDynamicTheming && supportsDynamicTheming() -> {
|
|
|
|
|
// if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
else -> if (darkTheme) DarkDefaultColorScheme else LightDefaultColorScheme
|
|
|
|
|
}
|
|
|
|
|
@ -243,5 +236,7 @@ fun NiaTheme(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S)
|
|
|
|
|
fun supportsDynamicTheming() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
|
|
|
|
//@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S)
|
|
|
|
|
//fun supportsDynamicTheming() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
|
|
|
|
// A workaround for the dynamic theming support in Compose Multiplatform
|
|
|
|
|
fun supportsDynamicTheming() = false
|
|
|
|
|
|