Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Sources/TableDirector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,34 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
{
invoke(action: .showContextMenu, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath, userInfo: [TableKitUserInfoKeys.ContextMenuInvokePoint: point]) as? UIContextMenuConfiguration
}

@available(iOS 13.0, *)
open func tableView(_ tableView: UITableView,
previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {

if let indexPath = configuration.identifier as? IndexPath {

return invoke(action: .previewForHighlightingContextMenu,
cell: tableView.cellForRow(at: indexPath),
indexPath: indexPath,
userInfo: [TableKitUserInfoKeys.ContextMenuConfiguration: configuration]) as? UITargetedPreview
}
return nil
}

@available(iOS 13.0, *)
open func tableView(_ tableView: UITableView,
previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {

if let indexPath = configuration.identifier as? IndexPath {

return invoke(action: .previewForDismissingContextMenu,
cell: tableView.cellForRow(at: indexPath),
indexPath: indexPath,
userInfo: [TableKitUserInfoKeys.ContextMenuConfiguration: configuration]) as? UITargetedPreview
}
return nil
}

// MARK: - Row editing
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
Expand Down
3 changes: 3 additions & 0 deletions Sources/TableKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public struct TableKitUserInfoKeys {
public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath"
public static let CellCanMoveProposedIndexPath = "CellCanMoveProposedIndexPath"
public static let ContextMenuInvokePoint = "ContextMenuInvokePoint"
public static let ContextMenuConfiguration = "ContextMenuConfiguration"
}

public protocol RowConfigurable {
Expand Down Expand Up @@ -84,6 +85,8 @@ public enum TableRowActionType {
case canMoveTo
case move
case showContextMenu
case previewForHighlightingContextMenu
case previewForDismissingContextMenu
case accessoryButtonTap
case custom(String)

Expand Down