Kira
ποΈ Automatically generates UI which allows users to call any function (including composable ones) with any parameter values. Useful for building demo screens in playground apps of design systems
Install / Use
/learn @popovanton0/KiraREADME
Kira
Kira is an Android library that defines a Kotlin DSL (similar to
androidx.preference) for creating UI that allows users to call
any function (including @Composable ones) with any parameter values.
Kira also includes annotation-processor kira-processor that β¨automagicallyβ¨ generates UI for functions using the
DSL.
Library is particularly useful for building demo screens for UI components in playground apps of various design systems.
Example
@Kira
@Composable
fun TextCard(
text: String,
isRed: Boolean,
skill: Skill?,
food: Food,
) = TODO()
Generated code (only a portion):
kira(TextCardScope()) {
text = string(paramName = "text", defaultValue = "Lorem")
isRed = boolean(paramName = "isRed", defaultValue = false)
skill = nullableEnum(paramName = "skill", defaultValue = null)
food = enum(paramName = "food")
injector {
TextCard(
text = text.currentValue(),
isRed = isRed.currentValue(),
skill = skill.currentValue(),
food = food.currentValue(),
)
}
}
Screenshot of the UI demo screen:
<img width="400" src="images/light/example-ui.gif#gh-light-mode-only" alt="Horizontal ListItems present for each function argument that allow user to provide any value of the argument's type to the function's arguments"> <img width="400" src="images/dark/example-ui.gif#gh-dark-mode-only" alt="Horizontal ListItems present for each function argument that allow user to provide any value of the argument's type to the function's arguments">Demo Video
<a href="https://www.youtube.com/watch?v=FOiUPHJNiYI" target="_blank"> <img width="300" src="images/youtube-thumbnail.jpg" alt="Kira β Early Demo on YouTube"> </a>Getting Started
Add the following code to your project's root build.gradle file:
repositories {
maven { url "https://jitpack.io" }
}
Next, add the dependency below to your module's build.gradle file:
dependencies {
implementation "com.github.popovanton0:kira:LATEST_VERSION"
ksp "com.github.popovanton0.kira:kira-processor:LATEST_VERSION"
}
Usage
Examples are in the source code .
Basic
TODO()
<!-- No try-catch https://kotlinlang.slack.com/archives/CJLTWPH7S/p1603748877143100?thread_ts=1603737209.131700&cid=CJLTWPH7S -->