Litho Kotlin

Additional

Language
Kotlin
Version
v0.1 (Dec 24, 2017)
Created
Dec 24, 2017
Updated
Dec 25, 2017
Owner
Vince Mi (vinc3m1)
Contributor
Vince Mi (vinc3m1)
1
Activity
Badge
Generate
Download
Source code

Advertising

Litho Kotlin

Kotlin DSL for Litho ComponentLayout Builders.

Usage

Import

Just copy litho.kt into your project under com/makeramen/litho. I may look into a proper Maven Central release in the future.

Example

@LayoutSpec
object ExampleComponentSpec {

  @OnCreateLayout
  fun onCreateLayout(c: ComponentContext): ComponentLayout = layout { // Root element must be a layout, returns a ComponentLayout
    column(c) { // Init builders by passing in the context
      paddingDip(YogaEdge.ALL, 8f) // Attributes can be defined inline within the lambda
      children { // Children can be added through a children element
        text(c) {
          text("ONE")
          textSizeDip(16f)
        }
        text(c) {
          text("TWO")
          textSizeDip(16f)
        }
        text(c) {
          text("THREE")
          textSizeDip(16f)
        }
      }
    }
  }
}