a plugin for android compose theme changing
plugins {
id("io.github.kapaseker.cafe")
}app's build.gradle.kts
cafe {
cup = setOf("dusk", "night") // this means you will use two themes, dusk and night.
} <color name="purple">#FF3700B3</color> <!--common color-->
<color name="purple_dusk">#FFFF0088</color> <!--dust color-->
<color name="purple_night">#FF37FFB3</color> <!--night color--> this is important, because this plugin will auto generate code by building project, you can use gralde task preBuild to avoid a whole build.
setContent {
CafeTheme { // use this theme, alse can include other themes(like MaterialTheme).
Box() {}
}
}use Cafe.color anywhere to enalbe theme change.
Box(modifier = Modifier.background(colorResource(id = Cafe.color.purple)))Cafe.setCup(DUSK) // change all color to dusk color
Cafe.setCup(MAIN) // change all color to default main color
Cafe.setCup(NIGHT) // change all color to night color
- Adapt to the new Gradle version 9.2.0 (9.0 has not been tested, but should ideally also be compatible).
- Fix an issue with empty resources. A compilation error may occur for the MAIN resource when certain resources are missing.