forked from SwipeCellKit/SwipeCellKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwipeTableViewCellDelegate.swift
More file actions
76 lines (53 loc) · 3.17 KB
/
SwipeTableViewCellDelegate.swift
File metadata and controls
76 lines (53 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// SwipeTableViewCellDelegate.swift
//
// Created by Jeremy Koch
// Copyright © 2017 Jeremy Koch. All rights reserved.
//
import UIKit
/**
The `SwipeTableViewCellDelegate` protocol is adopted by an object that manages the display of action buttons when the cell is swiped.
*/
public protocol SwipeTableViewCellDelegate: class {
/**
Asks the delegate for the actions to display in response to a swipe in the specified row.
- parameter tableView: The table view object which owns the cell requesting this information.
- parameter indexPath: The index path of the row.
- parameter orientation: The side of the cell requesting this information.
- returns: An array of `SwipeAction` objects representing the actions for the row. Each action you provide is used to create a button that the user can tap. Returning `nil` will prevent swiping for the supplied orientation.
*/
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]?
/**
Asks the delegate for the display options to be used while presenting the action buttons.
- parameter tableView: The table view object which owns the cell requesting this information.
- parameter indexPath: The index path of the row.
- parameter orientation: The side of the cell requesting this information.
- returns: A `SwipeTableOptions` instance which configures the behavior of the action buttons.
- note: If not implemented, a default `SwipeTableOptions` instance is used.
*/
func tableView(_ tableView: UITableView, editActionsOptionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> SwipeTableOptions
/**
Tells the delegate that the table view is about to go into editing mode.
- parameter tableView: The table view object providing this information.
- parameter indexPath: The index path of the row.
- parameter orientation: The side of the cell.
*/
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation)
/**
Tells the delegate that the table view has left editing mode.
- parameter tableView: The table view object providing this information.
- parameter indexPath: The index path of the row.
- parameter orientation: The side of the cell.
*/
func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?, for orientation: SwipeActionsOrientation)
}
/**
Default implementation of `SwipeTableViewCellDelegate` methods
*/
public extension SwipeTableViewCellDelegate {
func tableView(_ tableView: UITableView, editActionsOptionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> SwipeTableOptions {
return SwipeTableOptions()
}
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) {}
func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?, for orientation: SwipeActionsOrientation) {}
}