rename items to rows in TableSection

This commit is contained in:
Max Sokolov 2016-08-22 17:31:54 +03:00
parent f132560f39
commit a7530eb3c7
2 changed files with 13 additions and 13 deletions

View File

@ -70,7 +70,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
// MARK: Public
public func invoke(action action: TableRowActionType, cell: UITableViewCell?, indexPath: NSIndexPath) -> Any? {
return sections[indexPath.section].items[indexPath.row].invoke(action, cell: cell, path: indexPath)
return sections[indexPath.section].rows[indexPath.row].invoke(action, cell: cell, path: indexPath)
}
public override func respondsToSelector(selector: Selector) -> Bool {
@ -84,7 +84,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
// MARK: - Internal -
func hasAction(action: TableRowActionType, atIndexPath indexPath: NSIndexPath) -> Bool {
return sections[indexPath.section].items[indexPath.row].hasAction(action)
return sections[indexPath.section].rows[indexPath.row].hasAction(action)
}
func didReceiveAction(notification: NSNotification) {
@ -97,13 +97,13 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
public func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let row = sections[indexPath.section].items[indexPath.row]
let row = sections[indexPath.section].rows[indexPath.row]
return row.estimatedHeight ?? heightStrategy?.estimatedHeight(row, path: indexPath) ?? UITableViewAutomaticDimension
}
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let row = sections[indexPath.section].items[indexPath.row]
let row = sections[indexPath.section].rows[indexPath.row]
let rowHeight = invoke(action: .height, cell: nil, indexPath: indexPath) as? CGFloat
return rowHeight ?? row.defaultHeight ?? heightStrategy?.height(row, path: indexPath) ?? UITableViewAutomaticDimension
@ -121,7 +121,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let row = sections[indexPath.section].items[indexPath.row]
let row = sections[indexPath.section].rows[indexPath.row]
cellManager?.register(cellType: row.cellType, forCellReuseIdentifier: row.reuseIdentifier)

View File

@ -24,7 +24,7 @@ public class TableSection {
weak var tableDirector: TableDirector?
public private(set) var items = [Row]()
public private(set) var rows = [Row]()
public var headerTitle: String?
public var footerTitle: String?
@ -36,17 +36,17 @@ public class TableSection {
public var footerHeight: CGFloat? = nil
public var numberOfRows: Int {
return items.count
return rows.count
}
public var isEmpty: Bool {
return items.isEmpty
return rows.isEmpty
}
public init(rows: [Row]? = nil) {
if let initialRows = rows {
items.appendContentsOf(initialRows)
self.rows.appendContentsOf(initialRows)
}
}
@ -67,7 +67,7 @@ public class TableSection {
// MARK: - Public -
public func clear() {
items.removeAll()
rows.removeAll()
}
public func append(row row: Row) {
@ -75,14 +75,14 @@ public class TableSection {
}
public func append(rows rows: [Row]) {
items.appendContentsOf(rows)
self.rows.appendContentsOf(rows)
}
public func insert(row row: Row, atIndex index: Int) {
items.insert(row, atIndex: index)
rows.insert(row, atIndex: index)
}
public func delete(index index: Int) {
items.removeAtIndex(index)
rows.removeAtIndex(index)
}
}