Merge pull request #77 from mrojas/master

Added support for moving rows
This commit is contained in:
Max Sokolov 2018-03-13 14:00:07 +09:00 committed by GitHub
commit d8ae329118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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: [TableKitUserInfoKeys.CellMoveDestinationIndexPath: destinationIndexPath])
}
}
// MARK: - Sections manipulation

View File

@ -24,6 +24,10 @@ struct TableKitNotifications {
static let CellAction = "TableKitNotificationsCellAction"
}
public struct TableKitUserInfoKeys {
public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath"
}
public protocol RowConfigurable {
func configure(_ cell: UITableViewCell)
@ -65,6 +69,7 @@ public enum TableRowActionType {
case height
case canEdit
case configure
case move
case custom(String)
var key: String {