wangshengjia / LeeGo

Declarative, configurable & highly reusable UI development as making Lego bricks.
MIT License
966 stars 45 forks source link

Are the explicit types in the README there deliberately? #60

Closed BasThomas closed 8 years ago

BasThomas commented 8 years ago

eg.

import LeeGo

let titleBrick: Brick = "title".build(UILabel).style([.text("Showcase"), .backgroundColor(UIColor.lightGrayColor())])

could become

import LeeGo

let titleBrick: Brick = "title".build(UILabel).style([.text("Showcase"), .backgroundColor(.lightGrayColor())])

and

let bricks = ["red".build().style(Style.redBlockStyle).height(50),
 "green".build().style(Style.greenBlockStyle).height(80),
 "blue".build().style(Style.blueBlockStyle).height(30)]

let layout = Layout(bricks: bricks, axis: .Horizontal, align: .Top, distribution: .FillEqually, metrics: LayoutMetrics(10, 10, 10, 10, 10, 10))
let viewBrick = "view".build().style(Style.blocksStyle).bricks(bricks, layout: layout).height(100)

could become

let bricks = ["red".build().style(.redBlockStyle).height(50),
 "green".build().style(.greenBlockStyle).height(80),
 "blue".build().style(.blueBlockStyle).height(30)]

let layout = Layout(bricks: bricks, axis: .Horizontal, align: .Top, distribution: .FillEqually, metrics: LayoutMetrics(10, 10, 10, 10, 10, 10))
let viewBrick = "view".build().style(.blocksStyle).bricks(bricks, layout: layout).height(100)

But I understand if this was done intentionally; it is clearer and more easily readable (?) in the examples.

If this wasn't done deliberately, I'd gladly help using implicit type inference. :)

wangshengjia commented 8 years ago

Thank you for letting me know.

No, it's not intentionally. You are right, we may get rid of UIColor and take advantage from implicit type inference. Unfortunately it won't work for Style 😔.