Add performsFirstActionWithFullSwipe

This commit is contained in:
Vlad 2020-12-26 11:24:59 +03:00
parent 94c40faa63
commit efc03d7c22
3 changed files with 20 additions and 2 deletions

View File

@ -355,13 +355,23 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
@available(iOS 11, *)
open func tableView(_ tableView: UITableView,
leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return .init(actions: sections[indexPath.section].rows[indexPath.row].leadingContextualActions)
let currentRow = sections[indexPath.section].rows[indexPath.row]
let configuration = UISwipeActionsConfiguration(actions: currentRow.leadingContextualActions)
configuration.performsFirstActionWithFullSwipe = currentRow.performsFirstActionWithFullSwipe
return configuration
}
@available(iOS 11, *)
open func tableView(_ tableView: UITableView,
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return .init(actions: sections[indexPath.section].rows[indexPath.row].trailingContextualActions)
let currentRow = sections[indexPath.section].rows[indexPath.row]
let configuration = UISwipeActionsConfiguration(actions: currentRow.trailingContextualActions)
configuration.performsFirstActionWithFullSwipe = currentRow.performsFirstActionWithFullSwipe
return configuration
}
open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {

View File

@ -44,6 +44,9 @@ public protocol RowActionable {
@available(iOS 11, *)
var trailingContextualActions: [UIContextualAction] { get }
@available(iOS 11, *)
var performsFirstActionWithFullSwipe: Bool { get }
@available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead")
var editingActions: [UITableViewRowAction]? { get }

View File

@ -38,6 +38,11 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
[]
}
@available(iOS 11, *)
open var performsFirstActionWithFullSwipe: Bool {
false
}
open var hashValue: Int {
return ObjectIdentifier(self).hashValue
}