Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where one is ignored when using UIScrollViewDelegateProxy and UICollectionViewDelegateProxy #67

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Example/ExampleTests/UICollectionViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,25 @@ class UICollectionViewTests: XCTestCase {
XCTAssertEqual(firstResultIndexPaths, [givenIndexPath])
XCTAssertEqual(firstResultIndexPaths, secondResultIndexPaths)
}

func test_didScrollAndDidSelectItemAt() {
let collectionView = UICollectionView(frame: .zero,
collectionViewLayout: UICollectionViewFlowLayout())

var didScroll = false
collectionView.didScrollPublisher
.sink(receiveValue: { didScroll = true })
.store(in: &subscriptions)

var didSelect = false
collectionView.didSelectItemPublisher
.sink(receiveValue: { _ in didSelect = true })
.store(in: &subscriptions)

collectionView.delegate!.scrollViewDidScroll!(collectionView)
collectionView.delegate!.collectionView?(collectionView, didSelectItemAt: .init(row: 0, section: 1))

XCTAssertEqual(didScroll, true)
XCTAssertEqual(didSelect, true)
}
}
4 changes: 2 additions & 2 deletions Sources/CombineCocoa/Controls/UICollectionView+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public extension UICollectionView {
.eraseToAnyPublisher()
}

private var delegateProxy: CollectionViewDelegateProxy {
.createDelegateProxy(for: self)
override var delegateProxy: DelegateProxy {
CollectionViewDelegateProxy.createDelegateProxy(for: self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/CombineCocoa/Controls/UIScrollView+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public extension UIScrollView {
.eraseToAnyPublisher()
}

private var delegateProxy: ScrollViewDelegateProxy {
.createDelegateProxy(for: self)
@objc var delegateProxy: DelegateProxy {
ScrollViewDelegateProxy.createDelegateProxy(for: self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/CombineCocoa/Controls/UITableView+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public extension UITableView {
.eraseToAnyPublisher()
}

private var delegateProxy: TableViewDelegateProxy {
.createDelegateProxy(for: self)
override var delegateProxy: DelegateProxy {
TableViewDelegateProxy.createDelegateProxy(for: self)
}
}

Expand Down