Kotlin DSL for Litho ComponentLayout Builders.

Overview

Litho Kotlin

Kotlin DSL for Litho Component.Builders.

Usage

Import

  1. Copy Litho.kt into your project under com/makeramen/litho.
  2. Add any definitions for your own custom components, e.g.
    @LithoMarker
    fun myComponent(c: ComponentContext, init: MyComponent.Builder.() -> Unit) =
        componentBuilder(c, MyComponent::create, init)
    
    @LithoMarker
    fun ChildHolder.myComponent(c: ComponentContext, init: MyComponent.Builder.() -> Unit) =
        componentBuilder(c, MyComponent::create, init)
  3. Remove any definitions you don't want to use, like recyclerCollectionComponent if you're not using Sections.

I may look into a proper Maven Central release in the future, but it's just one file, and extensibility for custom components is the best part.

Example

@LayoutSpec
object ExampleComponentSpec {

  @OnCreateLayout
  fun onCreateLayout(c: ComponentContext): Component {
    return column(c) {               // Init root Components by passing in the context
      paddingDip(YogaEdge.ALL, 8f)   // Attributes can be defined inline within the lambda
      children {                     // Add children using a children element
        text {                       // ComponentBuilders within a children element don't need a context
          text("TWO")
          textSizeDip(16f)
        }
        text {
          text("THREE")
          textSizeDip(16f)
        }
      }
    }
  }
}
You might also like...
Kotlin parser library with an easy-to-use DSL
Kotlin parser library with an easy-to-use DSL

Pratt Library for parsing expressions and a beautiful Kotlin DSL Just define your operators and operands with the Kotlin DSL and the parser is ready!

Kotlin DSL for Junit5

Kupiter is Kotlin DSL for Junit5. Current API is only for dynamic tests. Get it repositories { maven { url 'https://jitpack.io' } } dependencies

Kotlin-dsl-sample - Preferences project on android

kotlin-dsl-example Sample preferences project on android. How to use val

GitHub Actions Kotlin DSL

GitHub Actions Kotlin DSL Work in progress! The goal is to be able to describe GH Actions in Kotlin with all its perks, like: workflow( name = "Te

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

Kotlin DSL inspired by bhailang.js

Kotlin DSL inspired by bhailang.js

A light weight Compose Animation library to choreograph low level Animation API through Kotlin DSL.

Koreography Choreograph your Compose Animation 💃 🕺 A lightweight Compose Animation utility library to choreograph low-level Animation API (https://d

A small DSL to make building a conversation in Bukkit easy.

Konversation Konversation provides a simple builder to construct chains of prompts to be used in the conversation API present in Bukkit. Bukkit only p

Koin Annotations - help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you

The goal of Koin Annotations project is to help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you. The goal is to help developer experience to scale and go fast 🚀 , thanks to Kotlin Compilers.

Comments
  • Usage example for recycler

    Usage example for recycler

    Currently using component instead

            component(c, RecyclerCollectionComponent::create) {
              section(
                  ResultsListSection.create(SectionContext(c)).results(results).build())
                  .disablePTR(true).flexGrow(1f)
            }
    

    But ideal would be closer to

            recycler(RecyclerCollectionComponent::create) {
              section {
                results(results).build()).disablePTR(true).flexGrow(1f)
              }
            }
    
    opened by yschimke 1
  • new form of component

    new form of component

    Add new form of component

    fun <C : Component<out Component<*>>, B : Component.Builder<C, B>> ChildHolder.component(
        component: B,
        init: B.() -> Unit) {
      val builder = component
      builder.init()
      this.children.add(builder)
    }
    

    Before

            component(c, { QueryComponent.create(c) }) {
              initialUrl(initialUrl).executeListener(executeListener).flexGrow(0f)
            }
    

    After

    
            component(QueryComponent.create(c)) {
              initialUrl(initialUrl).executeListener(executeListener).flexGrow(0f)
            }
    
    opened by yschimke 1
Releases(v0.1)
Owner
Vince Mi
Vince Mi
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.

MaterialDrawerKt Create navigation drawers in your Activities and Fragments without having to write any XML, in pure Kotlin code, with access to all t

Márton Braun 517 Nov 19, 2022
{ } Declarative Kotlin DSL for choreographing Android transitions

Transition X Kotlin DSL for choreographing Android Transitions TransitionManager makes it easy to animate simple changes to layout without needing to

Arunkumar 520 Dec 16, 2022
Kotlin Dsl for Android RecyclerView

KRecyclerDsl Kotlin Dsl for Android RecyclerView Exemple Sample project recyclerView.adapter = dataClassAdapter<MyView, MyDataClass>(R.layout.my_view,

Thomas Girard 14 Mar 31, 2019
The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.

Lychee (ex. reactive-properties) Lychee is a library to rule all the data. ToC Approach to declaring data Properties Other data-binding libraries Prop

Mike 112 Dec 9, 2022
Nice and simple DSL for Espresso in Kotlin

Kakao Nice and simple DSL for Espresso in Kotlin Introduction At Agoda, we have more than 1000 automated tests to ensure our application's quality and

Agoda Company Pte Ltd. 1.1k Nov 22, 2022
DSL for constructing the drawables in Kotlin instead of in XML

Android Drawable Kotlin DSL DSL for constructing the drawables in Kotlin instead of in XML Examples Shape drawables <?xml version="1.0" encoding="utf-

Infotech Group 178 Dec 4, 2022
Lightweight Kotlin DSL dependency injection library

Warehouse DSL Warehouse is a lightweight Kotlin DSL dependency injection library this library has an extremely faster learning curve and more human fr

Osama Raddad 18 Jul 17, 2022
Code generation of Kotlin DSL for AWS CDK

Code generation of Kotlin DSL for AWS CDK

Semantic Configuration 5 Dec 24, 2022
Regular expression DSL on Kotlin

Examples Characters Construct Equivalent Matches x character(Char) The character x \\ character('\\') The backslash character \0n octal(OctalValue(7))

null 1 Oct 7, 2021
Kotlin Object Notation - Lightweight DSL to build fluid JSON trees

Kotlin Object Notation Lightweight kotlin MPP DSL for building JSON trees Setup Just drop the dependency in your commonMain sourceSet kotlin { sourc

Martynas Petuška 43 Dec 10, 2022