Skip to content

Commit

Permalink
Update iOS + playground.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshaber committed Apr 17, 2015
1 parent 39dfdbc commit 4da9de5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 12 additions & 6 deletions FewDemo-iOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Few
func renderCounter(component: Component<Int>, count: Int) -> Element {
let updateCounter = { component.updateState { $0 + 1 } }

return View()
return Element()
// The view itself should be centered.
.justification(.Center)
// The children should be centered in the view.
Expand Down Expand Up @@ -48,7 +48,9 @@ private func renderRow(row: Int) -> Element {
}

func renderTableView(component: Component<()>, state: ()) -> Element {
return TableView((1...100).map(renderRow), selectionChanged: println)
return TableView((1...100).map(renderRow), selectionChanged: println)
.flex(1)
.selfAlignment(.Stretch)
}

let TableViewDemo = { Component(initialState: (), render: renderTableView) }
Expand Down Expand Up @@ -101,14 +103,18 @@ func renderApp(component: Few.Component<AppState>, state: AppState) -> Element {
return Element()
.direction(.Column)
.children([
contentComponent
.margin(Edges(top: 20))
.flex(1),
Element()
.children([
contentComponent
])
.childAlignment(.Center)
.justification(.Center)
.flex(1),
Button(title: "Show me more!", action: showMore)
.width(200)
.margin(Edges(uniform: 10))
.selfAlignment(.Center)
])
])
}

func toggleDisplay(var state: AppState) -> AppState {
Expand Down
15 changes: 13 additions & 2 deletions FewDemo/MyPlayground.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@ import Cocoa
import Few
import XCPlayground

let view = View(backgroundColor: NSColor.redColor()).size(100, 100)
view.ql
let view = View(backgroundColor: NSColor.redColor())
.direction(.Column)
.justification(.FlexEnd)
.children([
Label("Bleh").size(100, 23),
Label("World").size(100, 23),
Button(title: "Yoo").margin(Edges(uniform: 4))
])
let component = Component(initialState: ()) { _, _ in view }

let host = NSView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
component.addToView(host)
host

0 comments on commit 4da9de5

Please sign in to comment.