Skip to content

Functional UI toolkit for Jetpack Compose, inspired by purescript-halogen.

License

Notifications You must be signed in to change notification settings

Sintrastes/Iodine

Repository files navigation

Iodine

Functional UI toolkit for Jetpack Compose, inspired by Halogen.

Introduction

Iodine is a functional UI toolkit for Kotlin built on top of Flow, Jetpack Compose, and Arrow. Where Arrow intends to be a "Functional companion to Kotlin's Standard Library", Iodine aims to be a functional companion to Jetpack Compose (including for desktop and multi-platform).

⚠️ WARNING: This project is currently alpha quality software. Things may break. Interfaces are likely to change without notice or deprecation cycles between versions. Documentation may not be entirely accurate or complete. While Iodine could very well be used today to build applications, at this time we do not recommend it for production use.

Why use Iodine?

A question that might come to mind when first learning about Iodine is: What advantages does it provide over pure compose? Isn't compose already a perfectly good declarative UI framework, why do we need another layer on top of that?

The answer to that is multi-fold:

  1. Iodine, together with some other projects, provides the capability to easily create and use forms for the validation and entry of Kotlin data classes.
  2. Iodine provides various utility functions for common UI and databinding patterns, such as a drop-down list selection widget which displays some visual representation (say a name) of a more complex strucuted object that is being selected under-the-hood.
  3. Iodine builds on top of composable functions to allow architecting user interfaces in terms of components, which allows explicitly specifying how the state of the component updates based on the input events to the component, as well as what kind of events the component itself can output, and provides a useful re-usable/plugable bundle of UI and buisness logic (similar to Decompose) which still internally maintains a clear seperation of presentation (view) and buisness logic.
  4. The explicit specification of the API of components that Iodine allows allows for highly flexible ways of abstracting out various UI design patterns to reduce coupling between different aspects of the UI design, as well as allowing for particularly nice APIs to be designed for plugin systems where the UI of a base application is extensible by said plugins.
  5. Iodine's architecture allows for particularly easy testing of UI logic.

✏️Getting Started

To get started with Iodine, clone this project and run gradlew :core:jar :desktop:jar to build the iodine-core and iodine-desktop jars needed for a Compose for Desktop project, then, place these in the libs folder of your project, and add the following to your build.gradle.kts:

dependencies {
    ...
    implementation(files("$projectDir/libs/iodine-core.jar"))
    implementation(files("$projectDir/libs/iodine-desktop.jar"))
    ...
}

An example of this can be found in the compose for desktop project example.

Similarly, to get started with an Android project, you can run gradlew :core:jar :android:build, place the built jar and aar in the libs folder of your project, and add the following to your build.gradle.kts:

dependencies {
    ...
    implementation(files("$projectDir/libs/iodine-core.jar"))
    implementation(files("$projectDir/libs/iodine-android.aar"))
    ...
}

An example of this can be found in the android project example.

Like this project?

If you use Iodine, or find it useful, consider supporting it's development efforts by buying me a coffee ☕, or a beer 🍺!

Donate Donate with Ethereum

📚 Learn More

For a more comprehensive tutorial, visit the project page for Iodine, or, if you would prefer to dig straight into the KDocs, you can find those here. For a quick introduction, continue reading!

💡 Related Projects

  • Bow Arch: UI-framework for Swift with a similar approach to Iodine.
  • Halogen: Inspiration for Iodine's approach of using strongly typed UI composable components.
  • Yesod: Inspiration for Iodine's Applicative form interface.