diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 2ffc99d..c308c8c 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -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 { diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 526b378..bba24ee 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -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 { @@ -84,6 +85,8 @@ public enum TableRowActionType { case canMoveTo case move case showContextMenu + case previewForHighlightingContextMenu + case previewForDismissingContextMenu case accessoryButtonTap case custom(String)