Skip to content

Commit d3b6fc7

Browse files
committed
Fix ignore action side bar items.
1 parent b80976d commit d3b6fc7

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Example iOS/Controllers/SideBarController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ class SidebarController: SPDiffableSideBarController {
4646
SPDiffableSideBarItem(title: "Listen Now", image: UIImage(systemName: "play.circle"), action: { _ in }),
4747
SPDiffableSideBarItem(title: "Browse", image: UIImage(systemName: "square.grid.2x2"), action: { _ in }),
4848
SPDiffableSideBarItem(title: "Radio", image: UIImage(systemName: "dot.radiowaves.left.and.right"), action: { _ in }),
49-
SPDiffableSideBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), action: { _ in }),
49+
SPDiffableSideBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), action: { _ in
50+
print("action call 2")
51+
}),
5052
SPDiffableSideBarButton(title: "Button", image: UIImage(systemName: "plus.square.fill"), action: { [weak self] _ in
53+
print("action call")
5154
guard let self = self else { return }
5255
let controller = UIViewController()
5356
controller.view.backgroundColor = .systemBackground

Sources/SPDiffable/Collection/Models/SPDiffableSideBarButton.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,17 @@ import UIKit
2727
Colorful title usually.
2828
*/
2929
@available(iOS 14, *)
30-
open class SPDiffableSideBarButton: SPDiffableItem {
30+
open class SPDiffableSideBarButton: SPDiffableCollectionActionableItem {
3131

3232
open var title: String
3333
open var image: UIImage?
3434
open var accessories: [UICellAccessory]
35-
open var action: Action
3635

3736
public init(identifier: SPDiffableItem.Identifier? = nil, title: String, image: UIImage?, accessories: [UICellAccessory] = [], action: @escaping Action) {
3837
self.title = title
3938
self.image = image
4039
self.accessories = accessories
41-
self.action = action
42-
super.init(identifier: identifier ?? title)
40+
super.init(identifier: identifier ?? title, action: action)
4341
}
4442

4543
public typealias Action = (_ indexPath: IndexPath) -> Void

Sources/SPDiffable/Collection/Models/SPDiffableSideBarItem.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,17 @@ import UIKit
2727
For header use `SPDiffableSideBarHeader` class.
2828
*/
2929
@available(iOS 14, *)
30-
open class SPDiffableSideBarItem: SPDiffableItem {
30+
open class SPDiffableSideBarItem: SPDiffableCollectionActionableItem {
3131

3232
open var title: String
3333
open var image: UIImage?
3434
open var accessories: [UICellAccessory]
35-
open var action: Action
3635

3736
public init(identifier: SPDiffableItem.Identifier? = nil, title: String, image: UIImage?, accessories: [UICellAccessory] = [], action: @escaping Action) {
3837
self.title = title
3938
self.image = image
4039
self.accessories = accessories
41-
self.action = action
42-
super.init(identifier: identifier ?? title)
40+
super.init(identifier: identifier ?? title, action: action)
4341
}
4442

4543
public typealias Action = (_ indexPath: IndexPath) -> Void

0 commit comments

Comments
 (0)