Skip to content

Commit

Permalink
Merge pull request #14 from bigMOTOR/develop
Browse files Browse the repository at this point in the history
Provide performsFirstActionWithFullSwipe with TrailingSwipeableType protocol
  • Loading branch information
mashe committed Sep 7, 2021
2 parents 1c9a646 + 8660ff2 commit 91b91d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DataDrivenRxDatasources.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DataDrivenRxDatasources"
s.version = "3.2.1"
s.version = "3.2.2"
s.summary = "MVVM abstraction boilerplate code over RxDataSources."
s.description = <<-DESC
DataDrivenRxDatasources - MVVM abstraction boilerplate code over RxDataSources.
Expand Down
7 changes: 7 additions & 0 deletions Sources/DataDrivenRxDatasources/SectionModelExtensions.swift
Expand Up @@ -65,6 +65,13 @@ public protocol DeletableType {
// Protocol for viewModel that provide and handles trailing swipe actions
public protocol TrailingSwipeableType {
var trailingSwipeActions: [SwipeAction] { get }
var performsFirstActionWithFullSwipe: Bool { get }
}

extension TrailingSwipeableType {
public var performsFirstActionWithFullSwipe: Bool {
return true
}
}

// Protocol for UITableViewCell to update constraints and redraw cell
Expand Down
4 changes: 3 additions & 1 deletion Sources/DataDrivenRxDatasources/TableView/RxTableView.swift
Expand Up @@ -229,7 +229,9 @@ private final class TableViewControllerDelegateProxy<DataSource: ExtendedSection
let model = try? _dataSource.model(at: indexPath) as? CellViewModelWrapper,
let trailingModel = model.base as? TrailingSwipeableType
else { return nil }
return UISwipeActionsConfiguration(actions: trailingModel.trailingSwipeActions.map(\.contextualAction))
let configuration = UISwipeActionsConfiguration(actions: trailingModel.trailingSwipeActions.map(\.contextualAction))
configuration.performsFirstActionWithFullSwipe = trailingModel.performsFirstActionWithFullSwipe
return configuration
}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
Expand Down

0 comments on commit 91b91d0

Please sign in to comment.