Since Samsung updated One UI 6, apps using Jetpack Compose with Material Design 3 no longer support dynamic colors on Samsung devices when update Compose-bom to version newer than 2024-01-00. This module is used to fix this issue until Samsung or Google officially resolves the issue.
// settings.gradle.kts
repositories {
...
maven { url = uri("https://jitpack.io") }
}
# libs.versions.toml
[versions]
...
oneui6Material3DynamicColorCompose = <version>
[libraries]
...
oneui6-material3-dynamic-color-compose = { module = "com.github.long5436:oneui6-material3-dynamic-color-compose", version.ref = "oneui6Material3DynamicColorCompose" }
// build.gradle.kts
dependencies {
...
implementation(libs.oneui6.material3.dynamic.color.compose)
}
// From
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context)
else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
// Change to
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorSchemeFix(context)
else dynamicLightColorSchemeFix(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}