From 709f739ab6106010203c9eeaaa1c1829cc25075f Mon Sep 17 00:00:00 2001 From: Matias Rojas Date: Tue, 13 Mar 2018 00:16:17 +0300 Subject: [PATCH 1/2] Added support to move rows --- Sources/TableDirector.swift | 4 ++++ Sources/TableKit.swift | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 41798dd..1da8ae8 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -273,6 +273,10 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { invoke(action: .clickDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) } } + + open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { + invoke(action: .move, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitNotifications.CellMoveDestinationIndexPath: destinationIndexPath]) + } } // MARK: - Sections manipulation diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 6b8b11c..6bab9c8 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -22,6 +22,7 @@ import UIKit struct TableKitNotifications { static let CellAction = "TableKitNotificationsCellAction" + static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath" } public protocol RowConfigurable { @@ -65,6 +66,7 @@ public enum TableRowActionType { case height case canEdit case configure + case move case custom(String) var key: String { From fd50b732c9c971e2c4b76f51a44cf5939a1c2d49 Mon Sep 17 00:00:00 2001 From: Matias Rojas Date: Tue, 13 Mar 2018 00:43:00 +0300 Subject: [PATCH 2/2] Added support for moving rows --- Sources/TableDirector.swift | 2 +- Sources/TableKit.swift | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 1da8ae8..ea20fd1 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -275,7 +275,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { } open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { - invoke(action: .move, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitNotifications.CellMoveDestinationIndexPath: destinationIndexPath]) + invoke(action: .move, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitUserInfoKeys.CellMoveDestinationIndexPath: destinationIndexPath]) } } diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 6bab9c8..96a2e48 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -22,7 +22,10 @@ import UIKit struct TableKitNotifications { static let CellAction = "TableKitNotificationsCellAction" - static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath" +} + +public struct TableKitUserInfoKeys { + public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath" } public protocol RowConfigurable {