bugfix for configureWithItem

This commit is contained in:
Max Sokolov 2015-11-14 01:43:43 +03:00
parent 2cb9078375
commit 20c19fda50
3 changed files with 13 additions and 10 deletions

View File

@ -165,12 +165,12 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
}
public func tableView(tableView: UITableView, shouldHighlightRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return triggerAction(.shouldHighlight, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? Bool ?? true
}
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return triggerAction(.height, cell: nil, indexPath: indexPath) as? CGFloat ?? tableView.rowHeight
}
}

View File

@ -82,21 +82,21 @@ public class TableRowBuilder<I, C where C: UITableViewCell> : RowBuilder {
// MARK: Chaining actions
public func action(key: String, action: (data: ActionData<I, C>) -> Void) -> Self {
public func action(key: String, closure: (data: ActionData<I, C>) -> Void) -> Self {
actions[key] = .actionBlock(action)
actions[key] = .actionBlock(closure)
return self
}
public func action(actionType: ActionType, action: (data: ActionData<I, C>) -> Void) -> Self {
public func action(actionType: ActionType, closure: (data: ActionData<I, C>) -> Void) -> Self {
actions[actionType.key] = .actionBlock(action)
actions[actionType.key] = .actionBlock(closure)
return self
}
public func action(actionType: ActionType, action: (data: ActionData<I, C>) -> AnyObject) -> Self {
public func action(actionType: ActionType, closure: (data: ActionData<I, C>) -> AnyObject) -> Self {
actions[actionType.key] = .actionReturnBlock(action)
actions[actionType.key] = .actionReturnBlock(closure)
return self
}
@ -126,8 +126,11 @@ public class TableConfigurableRowBuilder<I, C: ConfigurableCell where C.Item ==
public override func triggerAction(actionType: ActionType, cell: UITableViewCell?, indexPath: NSIndexPath, itemIndex: Int) -> AnyObject? {
(cell as? C)?.configureWithItem(items[itemIndex])
switch actionType {
case .configure:
(cell as? C)?.configureWithItem(items[itemIndex])
default: break
}
return super.triggerAction(actionType, cell: cell, indexPath: indexPath, itemIndex: itemIndex)
}
}