Skip to content

Commit

Permalink
Merge pull request #39 from yukiasai/fix/example
Browse files Browse the repository at this point in the history
Fix name of member
  • Loading branch information
xai3 authored Jan 13, 2017
2 parents c0029a9 + 45a21aa commit 559cdd5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ Use `createSection` and `createRow`.

``` swift
tableView.source = Source() { source in

// Create section
source.createSection { section in

// Create row
section.createRow { row in

// Setting reuse identifier
row.reuseIdentifier = "Cell"

// Setting fixed height.
row.height = 52

// Configuring handler for cell.
row.configureCell = { cell, _ in
cell.textLabel?.text = "row 1"
Expand All @@ -48,11 +48,12 @@ Use `createRows`.

``` swift
let members = [
Member(firstName: "John", lastName: "Paterson"),
Member(firstName: "Matt", lastName: "Gray"),
Member(firstName: "Jennifer", lastName: "Hart"),
Member(firstName: "Katherine", lastName: "Nash"),
Member(firstName: "Diane", lastName: "Nash"),
Member(firstName: "Hamada", lastName: "Hiro"),
Member(firstName: "Hamada", lastName: "Tadashi"),
Member(firstName: "Tamago", lastName: "GoGo"),
Member(firstName: "", lastName: "Wasabi"),
Member(firstName: "Lemon", lastName: "Honey"),
Member(firstName: "", lastName: "Fred"),
]

tableView.source = Source() { source in
Expand All @@ -74,18 +75,18 @@ Use `createHeader` and `createFooter`.
``` swift
tableView.source = Source() { source in
source.createSection { section in

// Create header.
section.createHeader { header in
// Setting title.
header.title = "Header"
header.title = "Big Hero 6"

header.height = 22
header.configureView = { view, _ in
view.backgroundColor = UIColor.lightGrayColor()
}
}

// Create footer.
section.createFooter { footer in
...
Expand Down Expand Up @@ -133,17 +134,17 @@ section.createRows(members) { (member, row: Row<MemberTableViewCell>) in

```
section.createRow { row in
// Configuring handler for height.
row.heightFor = { _ -> CGFloat? in
return 52
}
// Configuring handler for cell.
row.configureCell = { cell, _ in
cell.textLabel?.text = "row"
}
// Event handler for when cell is selected.
row.didSelect = { _ in
print("row is selected.")
Expand Down
22 changes: 12 additions & 10 deletions ShoyuExample/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ class TableViewController: UIViewController {
@IBOutlet weak var tableView: TableView!

let members = [
Member(firstName: "N", lastName: "Takahiro"),
Member(firstName: "H", lastName: "Naoki"),
Member(firstName: "K", lastName: "Kotaro"),
Member(firstName: "A", lastName: "Yuki"),
Member(firstName: "Hamada", lastName: "Hiro"),
Member(firstName: "Hamada", lastName: "Tadashi"),
Member(firstName: "Tamago", lastName: "GoGo"),
Member(firstName: "", lastName: "Wasabi"),
Member(firstName: "Lemon", lastName: "Honey"),
Member(firstName: "", lastName: "Fred"),
]

override func viewDidLoad() {
super.viewDidLoad()
tableView.source = Source().createSection { (section: Section<HeaderTableViewCell, FooterTableViewCell>) in
section.createHeader { header in
header.reuseIdentifier = "Header"
header.title = "Big Hero 6"
header.height = 32
header.configureView = { headerCell, _ in
headerCell.contentView.backgroundColor = UIColor.blue
Expand All @@ -47,7 +50,11 @@ class TableViewController: UIViewController {
row.height = 52
row.configureCell = configureMemberCell(member: member)
row.didSelect = didSelectMember(member: member)

}
section.createRows(for: 5) { (index: UInt, row: Row<DefaultTableViewCell>) -> Void in
row.heightFor = { _ -> CGFloat? in
return 44
}
row.canRemove = { _ -> Bool in
return true
}
Expand All @@ -63,11 +70,6 @@ class TableViewController: UIViewController {
row.didRemove = { event in
print(event.row)
}
}
section.createRows(for: 5) { (index: UInt, row: Row<DefaultTableViewCell>) -> Void in
row.heightFor = { _ -> CGFloat? in
return 44
}
row.configureCell = configureCountCell(index: index)
}
}
Expand Down

0 comments on commit 559cdd5

Please sign in to comment.