Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lcdsmao/jettheme
A flexible theme provider for Jetpack Compose. Supports dynamic theme changes and saving theme preference.
https://github.com/lcdsmao/jettheme
android jetpack-compose kotlin kotlin-android material-design theme theme-values
Last synced: 13 days ago
JSON representation
A flexible theme provider for Jetpack Compose. Supports dynamic theme changes and saving theme preference.
- Host: GitHub
- URL: https://github.com/lcdsmao/jettheme
- Owner: lcdsmao
- License: mit
- Created: 2020-11-07T08:51:50.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T00:36:42.000Z (17 days ago)
- Last Synced: 2024-10-22T22:25:01.374Z (17 days ago)
- Topics: android, jetpack-compose, kotlin, kotlin-android, material-design, theme, theme-values
- Language: Kotlin
- Homepage: https://lcdsmao.github.io/JetTheme/
- Size: 823 KB
- Stars: 53
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# JetTheme
JetTheme is a flexible theme provider for Jetpack Compose.
- Change the theme and recompose the UI dynamically.
- Save theme preference to local storage.
- Build your own design system.## Download
```gradle
dependencies {
// Use this if you want material design support (recommended)
implementation "dev.lcdsmao.jettheme:jettheme-material:$latestVersion"
// Use this if you want to build custom design system
implementation "dev.lcdsmao.jettheme:jettheme:$latestVersion"
}
```## Quick Start
### Provide Themes
Define your material themes themes using `buildMaterialThemePack`.
```kotlin
val AppTheme = buildMaterialThemePack {
defaultMaterialTheme(
colors = lightColors(...),
typography = Typography(...),
shapes = Shapes(...),
)
materialTheme(
id = darkId,
colors = darkColors(...),
)
materialTheme(
id = "other_theme",
colors = otherColors(...),
)
}
```For child components can correctly access defined `AppTheme` via `MaterialTheme`,
wrap your child components in a `ProvideAppMaterialTheme`.```kotlin
@Composable
fun App() {
ProvideAppMaterialTheme(AppTheme) {
// children
}
}
```### Change Themes
You can retrieve current component tree's `ThemeController` from `ThemeControllerAmbient`.
```kotlin
val themeController = ThemeControllerAmbient.current
```To change current theme you can use the theme id strings.
```kotlin
themeController.setThemeId(ThemeIds.Default)
themeController.setThemeId("other_theme_id")
```### Access Current Theme Values
You can access current theme values via `MaterialTheme` object (from `androidx.compose.material`):
```kotlin
Surface(color = MaterialTheme.colors.primary) {
// children
}
```Check out JetTheme's [full documentation here.](https://lcdsmao.github.io/jettheme/)
## Contributing
Feel free to open a issue or submit a pull request for any bugs/improvements.