From a7530eb3c779e144444cc5cea189971a952003a6 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Mon, 22 Aug 2016 17:31:54 +0300
Subject: [PATCH 1/5] rename items to rows in TableSection
---
Sources/TableDirector.swift | 10 +++++-----
Sources/TableSection.swift | 16 ++++++++--------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index ff6fd3f..bfdb60e 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -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)
diff --git a/Sources/TableSection.swift b/Sources/TableSection.swift
index e42b306..3e4df1d 100644
--- a/Sources/TableSection.swift
+++ b/Sources/TableSection.swift
@@ -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)
}
}
\ No newline at end of file
From 5e5643c342992475e7c70df17e88c49014ac71df Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Mon, 22 Aug 2016 17:33:28 +0300
Subject: [PATCH 2/5] support editing actions in TableRow
---
Sources/TableRow.swift | 15 ++++++++++++++-
Sources/TableRowAction.swift | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index b3cd9d1..0655c10 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -27,6 +27,9 @@ public protocol RowConfigurable {
public protocol RowActionable {
+ var editingActions: [UITableViewRowAction]? { get }
+ func isEditingAllowed(forIndexPath indexPath: NSIndexPath) -> Bool
+
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: NSIndexPath) -> Any?
func hasAction(action: TableRowActionType) -> Bool
}
@@ -49,6 +52,7 @@ public class TableRow
-
+