From 74af45f3cd5bb91e7fe910f24a5d228669a32901 Mon Sep 17 00:00:00 2001 From: Alexander Desyatov Date: Fri, 6 Apr 2018 20:22:29 +0300 Subject: [PATCH] Implement tableView:canMoveRowAt:indexPath method --- Sources/TableDirector.swift | 4 ++++ Sources/TableKit.swift | 1 + 2 files changed, 5 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index b380865..548eafb 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -307,6 +307,10 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { } } + open func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + return invoke(action: .canMove, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? true + } + open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { 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 780f680..c2b10c9 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -74,6 +74,7 @@ public enum TableRowActionType { case height case canEdit case configure + case canMove case move case custom(String)