On Github stanch / funlx-meetup-2
(html [:span {:class "foo"} "bar"])
(node [:div#id.class1 (for [r (range 2)] [:span.text (str "word" r)])])
output = render -> ul -> li 'Bergamot' li 'Chamomile'
Experimental modular functional UI language for Android, written in Scala.
w[Button]
l[LinearLayout]( w[Button], w[TextView] )
val brick1 = w[Button] val brick2 = w[TextView] l[LinearLayout]( brick1, brick2 )
w[TextView] <~ text("Hello")
def largeText(str: String) = text(str) + TextSize.large + padding(left = 8 dp) myTextView <~ largeText("Hello")
var greeting = slot[TextView] l[LinearLayout]( w[Button] <~ text("Greet me!") <~ On.click { greeting <~ show }, w[TextView] <~ text("Hello there") <~ wire(greeting) <~ hide )
myTextView <~~ fadeIn(400)
myTextView <~~ fadeIn(400) <~ text("Faded!")
val blink = fadeIn(400) ++ delay(2000) ++ fadeOut(400) myTextView <~~ blink
val action = myTextView <~ text("Foo") <~ show
val action1 = myTextView <~ text("Foo") <~ show val action2 = myProgressBar <~ hide runUi(action1 ~ action2)
runUi { (myProgressBar <~~ fadeOut(400)) ~~ (myTextView <~~ blink) ~~ (myOtherTextView <~ text("’SUP?")) }
// create a reactive variable val caption = rx.Var("Olá") // set text to “Olá” myTextView <~ caption.map(text) // text automatically updates to “Adeus” caption.update("Adeus")
Reactor.loop { self ⇒ // step 1 val path = new Path((self await mouseDown).position) // step 2 self.loopUntil(mouseUp) { val m = self awaitNext mouseMove path.lineTo(m.position) draw(path) } // step 3 path.close() draw(path) }
This presentation: http://stanch.github.io/funlx-meetup-2