Skip to content

kapaseker/Cafe

Repository files navigation

Cafe

a plugin for android compose theme changing

1. import Cafe plugin

plugins {
    id("io.github.kapaseker.cafe")
}

2. config you project theme name

app's build.gradle.kts

cafe {
    cup = setOf("dusk", "night") // this means you will use two themes, dusk and night.
}

3. define your theme colors (also support drawables/mipmaps, clone this project to learn more)

    <color name="purple">#FF3700B3</color> <!--common color--> 
    <color name="purple_dusk">#FFFF0088</color> <!--dust color--> 
    <color name="purple_night">#FF37FFB3</color> <!--night color--> 

4. build your project

this is important, because this plugin will auto generate code by building project, you can use gralde task preBuild to avoid a whole build.

5. use CafeTheme

setContent {
    CafeTheme { // use this theme, alse can include other themes(like MaterialTheme).
        Box() {}
    }
}

6. use Cafe's color

use Cafe.color anywhere to enalbe theme change.

Box(modifier = Modifier.background(colorResource(id = Cafe.color.purple)))

7. change theme and enjoy

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

Version

2.0.0-9.2.0

  1. Adapt to the new Gradle version 9.2.0 (9.0 has not been tested, but should ideally also be compatible).
  2. Fix an issue with empty resources. A compilation error may occur for the MAIN resource when certain resources are missing.

About

Android Compose Them Plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages