xebia-functional / macroid

A modular functional UI language for Android
527 stars 37 forks source link

Layout tree manipulation #5

Closed stanch closed 11 years ago

stanch commented 11 years ago

In the spirit of

And of course with mq #3 integration.

Requires delaying addView calls on layouts.

stanch commented 11 years ago

There is a first draft here: https://github.com/stanch/macroid/commit/5dd2ada38cbb91dcfbd71638ba87a54ee94efe85#L1R58

Apparently, zipper is not that useful for mutable structures, and layout manipulation without mutation is hardly doable, since widgets carry too much state to copy them around.

Current implementation is based on depth-first tree traversal and side-effecting (mutating) partial functions, e.g.

layout ~~> {
  case t: TextView ⇒ t ~> text("Hijacked!")
  case _ ⇒ ()
}

There is a Layout extractor, that lets one write code like this:

layout ~~> {
  case Layout(b: Button, t: TextView, otherChildren @ _*) ⇒ ...
}
stanch commented 11 years ago

So far no doubts, thus closing the issue.