Skip to content

Module to fix dynamic color bug on oneui 6 devices when using compose material 3

Notifications You must be signed in to change notification settings

long5436/oneui6-material3-dynamic-color-compose

Repository files navigation

OneUI 6 Material-3 Dynamic Color Compose

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.

Understand the issue better

Getting Started

Add repository

// settings.gradle.kts 

repositories {
    ...
    maven { url = uri("https://jitpack.io") }
}

Add Dependency

# 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)
}

Using

// 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
}

Useful Links

About

Module to fix dynamic color bug on oneui 6 devices when using compose material 3

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages