Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Daio-io/dresscode
👔 Tiny lightweight Kotlin Android library to change theme at runtime.
https://github.com/Daio-io/dresscode
android android-library kotlin-android theme
Last synced: 3 months ago
JSON representation
👔 Tiny lightweight Kotlin Android library to change theme at runtime.
- Host: GitHub
- URL: https://github.com/Daio-io/dresscode
- Owner: Daio-io
- License: apache-2.0
- Created: 2018-08-28T13:36:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-28T16:32:39.000Z (over 4 years ago)
- Last Synced: 2024-08-02T19:37:31.051Z (6 months ago)
- Topics: android, android-library, kotlin-android, theme
- Language: Kotlin
- Homepage:
- Size: 170 KB
- Stars: 340
- Watchers: 7
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - Daio-io/dresscode - 👔 Tiny lightweight Kotlin Android library to change theme at runtime. (Kotlin)
README
# dresscode 👔
[![](https://jitpack.io/v/Daio-io/dresscode.svg)](https://jitpack.io/#Daio-io/dresscode) [![codebeat badge](https://codebeat.co/badges/c4f32440-60e4-4878-820b-b258c1cb8fc8)](https://codebeat.co/projects/github-com-daio-io-dresscode-master) [![build status](https://travis-ci.org/Daio-io/dresscode.svg?branch=master)](https://travis-ci.org/Daio-io/dresscode)Tiny lightweight Kotlin Android library to change theme at runtime.
- Tiny 🔍
- Very simple to use.
- DressCode uses only extension functions to enable runtime theme changes avoiding the need to create some kind of `BaseThemeActivity` class.
- Declare your Themes as normal in `styles.xml`
- Automatically updates activity themes.
- Remembers the current theme between app launches.Make a pull request if you want your app in this section
## Add DressCode
```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
````implementation 'com.github.Daio-io:dresscode:{latest-release}'`
## Setting your App DressCode
In your Android Application class `onCreate` call the library function to set your dress codes
```kotlin
declareDressCode(DressCode("themeone", R.style.ThemeOne),
DressCode("themetwo", R.style.ThemeTwo),
DressCode("themethree", R.style.ThemeThree))
```Then from your Activities simply call `matchDressCode` before `setContentView`.
```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
matchDressCode() // Call me first or someone may come dressed as a 🤡
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
```
DressCode will automatically manage applying the new theme when it has been changed. So a simple call from within an Activity to:`dressCodeStyleId = R.style.ThemeTwo`
Will just apply the new theme to all Activities that call `matchDressCode()`.
Check out the sample app in the project for a simple implementation.
## Contributing Info
Coming soon