macroid icon indicating copy to clipboard operation
macroid copied to clipboard

enhancement: Make implicit layout available to child views

Open bennythomps opened this issue 10 years ago • 9 comments

Might get a bit crazy/unmanageable with multiple layers of nesting, but it would be great for type-checking on things like LayoutParams, to have an implicit layout available.

bennythomps avatar Dec 06 '14 20:12 bennythomps

What would be the syntax? Something like this?

l[LinearLayout](
  implicit l ⇒ w[Button] <~ lp(...),
  implicit l ⇒ w[TextView] <~ lp(...)
)

stanch avatar Dec 06 '14 20:12 stanch

Also see this comment for an alternative idea.

stanch avatar Dec 06 '14 20:12 stanch

l[LinearLayout]( implicit layout =>
  w[Button] <~ margin(all = 10 dp)
)

bennythomps avatar Dec 06 '14 20:12 bennythomps

So this is the same as in my first comment, right?

stanch avatar Dec 06 '14 20:12 stanch

Simliar, but maybe even just a signature like

def l[L <: ViewGroup](op: L => Seq[Ui[View]])

bennythomps avatar Dec 06 '14 20:12 bennythomps

Then you’ll have to wrap your views into a Seq — I don’t think it will look very nice :(

stanch avatar Dec 06 '14 20:12 stanch

Agreed, but for things like margin, there isn't a much cleaner way is there? Overloading it at least make it an option.

bennythomps avatar Dec 06 '14 21:12 bennythomps

I see your point — will have to think about this. Feel free to make a PR with a solution of your own :)

stanch avatar Dec 06 '14 21:12 stanch

Sounds good. Will do!

bennythomps avatar Dec 06 '14 21:12 bennythomps