Merge pull request #11 from maxsokolov/develop

0.4.0
This commit is contained in:
Max Sokolov 2016-04-13 02:15:42 +04:00
commit b71d141cab
7 changed files with 13 additions and 13 deletions

View File

@ -4,8 +4,8 @@ branches:
only:
- master
before_install:
- brew update
- brew reinstall --HEAD xctool
- cd Tablet
script:
- xctool clean build test -project Tablet.xcodeproj -scheme Tablet -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
- cd $TRAVIS_BUILD_DIR
- xctool clean build test -project Tablet.xcodeproj -scheme Tablet -sdk iphonesimulator

View File

@ -4,7 +4,7 @@
<a href="https://travis-ci.org/maxsokolov/tablet"><img src="https://travis-ci.org/maxsokolov/tablet.svg" alt="Build Status" /></a>
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/Swift2-compatible-4BC51D.svg?style=flat" alt="Swift 2 compatible" /></a>
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
<a href="https://cocoapods.org/pods/tablet"><img src="https://img.shields.io/badge/pod-0.3.0-blue.svg" alt="CocoaPods compatible" /></a>
<a href="https://cocoapods.org/pods/tablet"><img src="https://img.shields.io/badge/pod-0.4.0-blue.svg" alt="CocoaPods compatible" /></a>
<a href="https://raw.githubusercontent.com/maxsokolov/tablet/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
</p>
@ -85,7 +85,7 @@ import Tablet
class MyTableViewCell : UITableViewCell, ConfigurableCell {
typealias Item = User
typealias T = User
static func reusableIdentifier() -> String {
return "reusable_id"
@ -95,7 +95,7 @@ class MyTableViewCell : UITableViewCell, ConfigurableCell {
return 255
}
func configureWithItem(item: Item) { // item is user here
func configure(item: T) { // item is user here
textLabel?.text = item.username
detailTextLabel?.text = item.isActive ? "Active" : "Inactive"

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Tablet'
s.version = '0.3.0'
s.version = '0.4.0'
s.homepage = 'https://github.com/maxsokolov/tablet'
s.summary = 'Powerful type-safe tool for UITableView. Swift 2.0 is required.'

View File

@ -144,7 +144,7 @@ public class TableRowBuilder<I, C where C: UITableViewCell> : RowBuilder {
/**
Responsible for building configurable cells of given type and passing items to them.
*/
public class TableConfigurableRowBuilder<I, C: ConfigurableCell where C.Item == I, C: UITableViewCell> : TableRowBuilder<I, C> {
public class TableConfigurableRowBuilder<I, C: ConfigurableCell where C.T == I, C: UITableViewCell> : TableRowBuilder<I, C> {
public override var estimatedRowHeight: Float {
return C.estimatedHeight()
@ -162,7 +162,7 @@ public class TableConfigurableRowBuilder<I, C: ConfigurableCell where C.Item ==
switch actionType {
case .configure:
(cell as? C)?.configureWithItem(items[itemIndex])
(cell as? C)?.configure(items[itemIndex])
default: break
}
return super.invokeAction(actionType, cell: cell, indexPath: indexPath, itemIndex: itemIndex, userInfo: userInfo)

View File

@ -102,11 +102,11 @@ public class Action {
*/
public protocol ConfigurableCell {
associatedtype Item
associatedtype T
static func reusableIdentifier() -> String
static func estimatedHeight() -> Float
func configureWithItem(item: Item)
func configure(_: T)
}
public extension ConfigurableCell where Self: UITableViewCell {

View File

@ -47,7 +47,7 @@ struct TestTableViewCellOptions {
class TestTableViewCell: UITableViewCell, ConfigurableCell {
typealias Item = TestData
typealias T = TestData
static func reusableIdentifier() -> String {
return TestTableViewCellOptions.ReusableIdentifier
@ -57,7 +57,7 @@ class TestTableViewCell: UITableViewCell, ConfigurableCell {
return TestTableViewCellOptions.EstimatedHeight
}
func configureWithItem(item: Item) {
func configure(item: T) {
textLabel?.text = item.title
}