Skip to content

Commit eb93fe2

Browse files
committed
Add multiple selection actions & context menu action
1 parent 44c55d2 commit eb93fe2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Diff for: Sources/TableDirector.swift

+25
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,31 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
317317
return indexPath
318318
}
319319

320+
@available(iOS 13.0, *)
321+
open func tableView(
322+
_ tableView: UITableView,
323+
shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool
324+
{
325+
invoke(action: .shouldBeginMultipleSelection, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false
326+
}
327+
328+
@available(iOS 13.0, *)
329+
open func tableView(
330+
_ tableView: UITableView,
331+
didBeginMultipleSelectionInteractionAt indexPath: IndexPath)
332+
{
333+
invoke(action: .didBeginMultipleSelection, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath)
334+
}
335+
336+
@available(iOS 13.0, *)
337+
open func tableView(
338+
_ tableView: UITableView,
339+
contextMenuConfigurationForRowAt indexPath: IndexPath,
340+
point: CGPoint) -> UIContextMenuConfiguration?
341+
{
342+
invoke(action: .showContextMenu, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath, userInfo: [TableKitUserInfoKeys.ContextMenuInvokePoint: point]) as? UIContextMenuConfiguration
343+
}
344+
320345
// MARK: - Row editing
321346
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
322347
return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath)

Diff for: Sources/TableKit.swift

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct TableKitNotifications {
2727
public struct TableKitUserInfoKeys {
2828
public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath"
2929
public static let CellCanMoveProposedIndexPath = "CellCanMoveProposedIndexPath"
30+
public static let ContextMenuInvokePoint = "ContextMenuInvokePoint"
3031
}
3132

3233
public protocol RowConfigurable {
@@ -73,13 +74,16 @@ public enum TableRowActionType {
7374
case willDisplay
7475
case didEndDisplaying
7576
case shouldHighlight
77+
case shouldBeginMultipleSelection
78+
case didBeginMultipleSelection
7679
case height
7780
case canEdit
7881
case configure
7982
case canDelete
8083
case canMove
8184
case canMoveTo
8285
case move
86+
case showContextMenu
8387
case accessoryButtonTap
8488
case custom(String)
8589

0 commit comments

Comments
 (0)