diff --git a/README.md b/README.md index 5ab6266..5851397 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,13 @@ Tablet is a super lightweight yet powerful generic library that handles a comple ## Features -- [x] Powerfull type-safe system based on generics +- [x] Type-safe cells based on generics +- [x] The easiest way to map your models or view models to cells - [x] Chainable cell actions - [x] Support cells created from code, xib, or storyboard - [x] Automatic xib/classes registration - [x] No need to subclass +- [x] Correctly handles autolayout cells with multiline labels - [x] Extensibility - [x] Tests @@ -66,7 +68,7 @@ let rowBuilder = TableRowBuilder(items: [user1, user2, us data.cell?.detailTextLabel?.text = data.item.isActive ? "Active" : "Inactive" } -let sectionBuilder = TableSectionBuilder(headerTitle: "Users", rowBuilders: [rowBuilder]) +let sectionBuilder = TableSectionBuilder(headerTitle: "Users", rows: [rowBuilder]) director = TableDirector(tableView: tableView) director.appendSections(sectionBuilder) @@ -108,7 +110,7 @@ let rowBuilder = TableConfigurableRowBuilder() rowBuilder.appendItems(users) director = TableDirector(tableView: tableView) -tableDirector.appendSection(TableSectionBuilder(rowBuilders: [rowBuilder])) +tableDirector.appendSection(TableSectionBuilder(rows: [rowBuilder])) ``` ### Cell actions diff --git a/Tablet/Tablet.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate b/Tablet/Tablet.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate index b0f72cb..1d9a3e2 100644 Binary files a/Tablet/Tablet.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate and b/Tablet/Tablet.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Tests/TabletTests.swift b/Tests/TabletTests.swift index e62c2b1..2833a44 100644 --- a/Tests/TabletTests.swift +++ b/Tests/TabletTests.swift @@ -21,7 +21,7 @@ import XCTest import Tablet -class TestController : UITableViewController { +class TestController: UITableViewController { var tableDirector: TableDirector! @@ -31,6 +31,34 @@ class TestController : UITableViewController { } } +struct TestData { + + let title: String +} + +struct TestTableViewCellOptions { + + static let ReusableIdentifier: String = "ReusableIdentifier" + static let EstimatedHeight: Float = 255 +} + +class TestTableViewCell: UITableViewCell, ConfigurableCell { + + typealias Item = TestData + + static func reusableIdentifier() -> String { + return TestTableViewCellOptions.ReusableIdentifier + } + + static func estimatedHeight() -> Float { + return TestTableViewCellOptions.EstimatedHeight + } + + func configureWithItem(item: Item) { + textLabel?.text = item.title + } +} + class TabletTests: XCTestCase { var testController: TestController! @@ -80,4 +108,18 @@ class TabletTests: XCTestCase { XCTAssertTrue(cell?.textLabel?.text == element) } } + + func testConfigurableRowBuilder() { + + let testData = TestData(title: "title") + + testController.view.hidden = false + testController.tableDirector += TableConfigurableRowBuilder(item: testData) + testController.tableView.reloadData() + + let cell = testController.tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) as? TestTableViewCell + + XCTAssertNotNil(cell, "Cell should exists and should be TestTableViewCell") + XCTAssertTrue(cell?.textLabel?.text == testData.title, "Cell's textLabel.text should equal to testData's title") + } } \ No newline at end of file