Skip to content

saurabhkanswal/MiniUiEngine

Repository files navigation

MiniUiEngine

Describe your Android UI as plain text, get a rendered screen.

column bg=#FFFFFF height=match
  column padding=24 bg=#FFFFFF
    text "miniUiEngine" size=28 color=#1E293B
    spacer height=6
    text "Plain text to pixels" size=16 color=#64748B
    text "No Compose. No XML. No views." size=13 color=#94A3B8
    spacer height=20
    button "Get Started" bg=#4F46E5 color=#FFFFFF width=match
  spacer height=1 bg=#E2E8F0 width=match
  row bg=#F8FAFC padding=20
    column weight=1
      text "Fast" size=22 color=#0F172A align=center width=match
      text "Parsing" size=11 color=#4F46E5 align=center width=match
    column weight=1
      text "Pure" size=22 color=#0F172A align=center width=match
      text "Canvas" size=11 color=#4F46E5 align=center width=match
    column weight=1
      text "Zero" size=22 color=#0F172A align=center width=match
      text "Deps" size=11 color=#4F46E5 align=center width=match
  spacer height=1 bg=#E2E8F0 width=match
  column padding=24 bg=#FFFFFF
    text "Lexer" size=15 color=#0F172A
    text "Plain text into typed tokens" size=12 color=#64748B
    spacer height=14
    text "Parser" size=15 color=#0F172A
    text "Tokens into an AST node tree" size=12 color=#64748B
    spacer height=14
    text "Layout" size=15 color=#0F172A
    text "Measure and position every node" size=12 color=#64748B
    spacer height=14
    text "Renderer" size=15 color=#0F172A
    text "Draw each node directly to Canvas" size=12 color=#64748B

No XML. No Compose. The string goes through a lexer → parser → layout → renderer pipeline and draws straight to Canvas.


Add to your project

Add JitPack to your root build.gradle.kts:

repositories {
    maven("https://jitpack.io")
}

Then add the dependency:

dependencies {
    implementation("com.github.saurabhkanswal:MiniUiEngine:0.1.0")
}

Min SDK 24.


Usage

val view = MiniUiView(this)

view.setUiText("""
    column padding=24
      text "Hello world" size=20 color=#1E293B
      spacer height=12
      button "Click" bg=#4F46E5 color=#FFFFFF width=match
""")

view.onButtonTap = { label ->
    Toast.makeText(this, label, Toast.LENGTH_SHORT).show()
}

setContentView(view)

setUiText can be called anytime → it recompiles and redraws.


DSL

Widgets: column, row, box, text, button, spacer

Nesting is indentation-based → 2 spaces per level. Lines starting with # are comments.

Props:

prop values notes
bg #rrggbb background fill
color #rrggbb text color, defaults to black
size number text size in sp
padding number inner spacing in dp
margin number outer spacing in dp
width / height wrap, match, or a number number is treated as dp
align start, center, end text alignment inside a text widget
weight number flex weight, only applies inside row

About

Describe your Android UI as plain text, get a rendered screen

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages