@@ -82,6 +82,7 @@ class BasicTableViewController: KeyCommandTableViewController {
82
82
var playContextAtIndexPathCallback : PlayContextAtIndexPathCallback ?
83
83
var swipeCallback : SwipeActionCallback ?
84
84
var isEditLockedDueToActiveSwipe = false
85
+ var isSingleCellEditingModeActive = false
85
86
86
87
override func viewDidLoad( ) {
87
88
super. viewDidLoad ( )
@@ -97,12 +98,20 @@ class BasicTableViewController: KeyCommandTableViewController {
97
98
}
98
99
updateSearchResults ( for: searchController)
99
100
}
101
+
102
+ override func tableView( _ tableView: UITableView , willBeginEditingRowAt indexPath: IndexPath ) {
103
+ isSingleCellEditingModeActive = true
104
+ }
105
+
106
+ override func tableView( _ tableView: UITableView , didEndEditingRowAt indexPath: IndexPath ? ) {
107
+ isSingleCellEditingModeActive = false
108
+ }
100
109
101
110
override func tableView( _ tableView: UITableView , leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath ) -> UISwipeActionsConfiguration ? {
102
111
guard let swipeCB = swipeCallback,
103
112
let containableCB = containableAtIndexPathCallback,
104
113
let containable = containableCB ( indexPath)
105
- else { return nil }
114
+ else { return UISwipeActionsConfiguration ( ) }
106
115
107
116
var createdActionsIndex = 0
108
117
var actions = [ UIContextualAction] ( )
@@ -116,11 +125,14 @@ class BasicTableViewController: KeyCommandTableViewController {
116
125
}
117
126
118
127
override func tableView( _ tableView: UITableView , trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath ) -> UISwipeActionsConfiguration ? {
119
- guard !tableView. isEditing else { return nil }
128
+ // return nil here allows to display the "Delete" confirmation swipe action in edit mode (nil -> show default action -> delete is the default one)
129
+ guard !( tableView. isEditing && !isSingleCellEditingModeActive) else { return nil }
130
+ // this empty configuration enshures to only perform one "Delete" action at a time (no confirmation is displayed)
131
+ guard !( tableView. isEditing && isSingleCellEditingModeActive) else { return UISwipeActionsConfiguration ( ) }
120
132
guard let swipeCB = swipeCallback,
121
133
let containableCB = containableAtIndexPathCallback,
122
134
let containable = containableCB ( indexPath)
123
- else { return nil }
135
+ else { return UISwipeActionsConfiguration ( ) }
124
136
var createdActionsIndex = 0
125
137
var actions = [ UIContextualAction] ( )
126
138
for actionType in appDelegate. storage. settings. swipeActionSettings. trailing {
0 commit comments