diff --git a/README.md b/README.md index 65c4c15..809dfd2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/maxsokolov/tablet/assets/logo.png) -#Tablet +#Tablet.swift

Build Status -Swift 2 compatible +Swift 2.2 compatible Platform iOS -CocoaPods compatible +CocoaPods compatible License: MIT

@@ -17,16 +17,16 @@ Tablet is a super lightweight yet powerful generic library that handles a comple - [x] Type-safe cells based on generics - [x] The easiest way to map your models or view models to cells - [x] Correctly handles autolayout cells with multiline labels -- [x] Chainable cell actions +- [x] Chainable cell actions (select/deselect etc.) - [x] Support cells created from code, xib, or storyboard - [x] Automatic xib/classes registration - [x] No need to subclass - [x] Extensibility - [x] Tests -That's almost all you need in your controller to build a bunch of cells in a section 😘: +That's almost all you need in your controller to build a bunch of cells in a section: ```swift -TableConfigurableRowBuilder(items: ["1", "2", "3", "4", "5"]) +let builder = TableRowBuilder(items: ["1", "2", "3", "4", "5"]) ``` Tablet respects cells reusability feature and built with performace in mind. See the Usage section to learn more. @@ -59,28 +59,28 @@ $ pod install ### Very basic -You may want to setup a very basic table view, without any custom cells. In that case simply use the `TableRowBuilder`. +You may want to setup a very basic table view, without any custom cells. In that case simply use the `TableBaseRowBuilder`. ```swift import Tablet -let rowBuilder = TableRowBuilder(items: [user1, user2, user3], id: "reusable_id") - .action(.configure) { data -> Void in +let rowBuilder = TableBaseRowBuilder(items: [user1, user2, user3], id: "reusable_id") + .action(.configure) { (data) in data.cell?.textLabel?.text = data.item.username data.cell?.detailTextLabel?.text = data.item.isActive ? "Active" : "Inactive" } -let sectionBuilder = TableSectionBuilder(headerTitle: "Users", rows: [rowBuilder]) +let sectionBuilder = TableSectionBuilder(headerTitle: "Users", footerTitle: nil, rows: [rowBuilder]) director = TableDirector(tableView: tableView) -director.appendSections(sectionBuilder) +director += sectionBuilder ``` ### Type-safe configurable cells Let's say you want to put your cell configuration logic into cell itself. Say you want to pass your view model (or even model) to your cell. -You could easily do this using the `TableConfigurableRowBuilder`. Your cell should respect the `ConfigurableCell` protocol as you may see in example below: +You could easily do this using the `TableRowBuilder`. Your cell should conforms to `ConfigurableCell` protocol as you may see in example below: ```swift import Tablet @@ -104,16 +104,16 @@ class MyTableViewCell : UITableViewCell, ConfigurableCell { } } ``` -Once you've implemented the protocol, simply use the `TableConfigurableRowBuilder` to build cells: +Once you've implemented the protocol, simply use the `TableRowBuilder` to build cells: ```swift import Tablet -let rowBuilder = TableConfigurableRowBuilder() -rowBuilder.appendItems(users) +let rowBuilder = TableRowBuilder() +rowBuilder += users director = TableDirector(tableView: tableView) -tableDirector.appendSection(TableSectionBuilder(rows: [rowBuilder])) +tableDirector += TableSectionBuilder(rows: [rowBuilder]) ``` ### Cell actions @@ -124,13 +124,13 @@ Tablet provides a chaining approach to handle actions from your cells: import Tablet let rowBuilder = TableRowBuilder(items: [user1, user2, user3], id: "reusable_id") - .action(.configure) { data -> Void in + .action(.configure) { (data) in } - .action(.click) { data -> Void in + .action(.click) { (data) in } - .action(.shouldHighlight) { data -> ReturnValue in + .valueAction(.shouldHighlight) { (data) in return false } @@ -154,14 +154,14 @@ And receive this actions with your row builder: ```swift import Tablet -let rowBuilder = TableConfigurableRowBuilder(items: users, id: "reusable_id") - .action(.click) { data -> Void in +let rowBuilder = TableRowBuilder(items: users, id: "reusable_id") + .action(.click) { (data) in } - .action(.willDisplay) { data -> Void in + .action(.willDisplay) { (data) in } - .action(kMyAction) { data -> Void in + .action(kMyAction) { (data) in } ``` @@ -186,7 +186,7 @@ extension TableDirector { Catch your action with row builder: ```swift let rowBuilder = TableConfigurableRowBuilder(items: users) - .action(kTableDirectorDidEndDisplayingCell) { data -> Void in + .action(kTableDirectorDidEndDisplayingCell) { (data) -> Void in } ```