Skip to content

Commit

Permalink
Update label and variable names for consistancy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolan Warner authored and kzaher committed Jul 9, 2017
1 parent af450fc commit fa8a8bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions RxCocoa/iOS/UICollectionView+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ extension UICollectionView {
}

extension Reactive where Base: UICollectionView {
public typealias DisplayCollectionViewCellEvent = (cell: UICollectionViewCell, indexPath: IndexPath)
public typealias DisplayCollectionReusableViewEvent = (reuseableView: UICollectionReusableView, elementKind: String, indexPath: IndexPath)
public typealias DisplayCollectionViewCellEvent = (cell: UICollectionViewCell, at: IndexPath)
public typealias DisplayCollectionViewSupplementaryViewEvent = (supplementaryView: UICollectionReusableView, elementKind: String, at: IndexPath)

/// Reactive wrapper for `dataSource`.
///
Expand Down Expand Up @@ -252,8 +252,8 @@ extension Reactive where Base: UICollectionView {
}

/// Reactive wrapper for `delegate` message `collectionView(_:willDisplaySupplementaryView:forElementKind:at:)`.
public var willDisplaySupplementaryView: ControlEvent<DisplayCollectionReusableViewEvent> {
let source: Observable<DisplayCollectionReusableViewEvent> = self.delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:)))
public var willDisplaySupplementaryView: ControlEvent<DisplayCollectionViewSupplementaryViewEvent> {
let source: Observable<DisplayCollectionViewSupplementaryViewEvent> = self.delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:)))
.map { a in
return (try castOrThrow(UICollectionReusableView.self, a[1]),
try castOrThrow(String.self, a[2]),
Expand All @@ -274,8 +274,8 @@ extension Reactive where Base: UICollectionView {
}

/// Reactive wrapper for `delegate` message `collectionView(_:didEndDisplayingSupplementaryView:forElementOfKind:at:)`.
public var didEndDisplayingSupplementaryView: ControlEvent<DisplayCollectionReusableViewEvent> {
let source: Observable<DisplayCollectionReusableViewEvent> = self.delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementOfKind:at:)))
public var didEndDisplayingSupplementaryView: ControlEvent<DisplayCollectionViewSupplementaryViewEvent> {
let source: Observable<DisplayCollectionViewSupplementaryViewEvent> = self.delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementOfKind:at:)))
.map { a in
return (try castOrThrow(UICollectionReusableView.self, a[1]),
try castOrThrow(String.self, a[2]),
Expand Down
34 changes: 17 additions & 17 deletions Tests/RxCocoaTests/UICollectionView+RxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,37 +108,37 @@ final class UICollectionViewTests : RxTest {
})

let testCell = UICollectionViewCell(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
let testRow = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, willDisplay: testCell, forItemAt: testRow)
let testIndexPath = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, willDisplay: testCell, forItemAt: testIndexPath)

XCTAssertEqual(resultCell, testCell)
XCTAssertEqual(resultIndexPath, testRow)
XCTAssertEqual(resultIndexPath, testIndexPath)
subscription.dispose()
}

func testCollectionView_willDisplaySupplementaryView() {
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)

var resultReuseableView: UICollectionReusableView? = nil
var resultSupplementaryView: UICollectionReusableView? = nil
var resultElementKind: String? = nil
var resultIndexPath: IndexPath? = nil

let subscription = collectionView.rx.willDisplaySupplementaryView
.subscribe(onNext: { (reuseableView, elementKind, indexPath) in
resultReuseableView = reuseableView
resultSupplementaryView = reuseableView
resultElementKind = elementKind
resultIndexPath = indexPath
})

let testReuseableView = UICollectionReusableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
let testSupplementaryView = UICollectionReusableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
let testElementKind = UICollectionElementKindSectionHeader
let testRow = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, willDisplaySupplementaryView: testReuseableView, forElementKind: testElementKind, at: testRow)
let testIndexPath = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, willDisplaySupplementaryView: testSupplementaryView, forElementKind: testElementKind, at: testIndexPath)

XCTAssertEqual(resultReuseableView, testReuseableView)
XCTAssertEqual(resultSupplementaryView, testSupplementaryView)
XCTAssertEqual(resultElementKind, testElementKind)
XCTAssertEqual(resultIndexPath, testRow)
XCTAssertEqual(resultIndexPath, testIndexPath)
subscription.dispose()
}

Expand Down Expand Up @@ -168,25 +168,25 @@ final class UICollectionViewTests : RxTest {
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)

var resultReuseableView: UICollectionReusableView? = nil
var resultSupplementaryView: UICollectionReusableView? = nil
var resultElementKind: String? = nil
var resultIndexPath: IndexPath? = nil

let subscription = collectionView.rx.didEndDisplayingSupplementaryView
.subscribe(onNext: { (reuseableView, elementKind, indexPath) in
resultReuseableView = reuseableView
resultSupplementaryView = reuseableView
resultElementKind = elementKind
resultIndexPath = indexPath
})

let testReuseableView = UICollectionReusableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
let testSupplementaryView = UICollectionReusableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
let testElementKind = UICollectionElementKindSectionHeader
let testRow = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, didEndDisplayingSupplementaryView: testReuseableView, forElementOfKind: testElementKind, at: testRow)
let testIndexPath = IndexPath(row: 1, section: 0)
collectionView.delegate!.collectionView!(collectionView, didEndDisplayingSupplementaryView: testSupplementaryView, forElementOfKind: testElementKind, at: testIndexPath)

XCTAssertEqual(resultReuseableView, testReuseableView)
XCTAssertEqual(resultSupplementaryView, testSupplementaryView)
XCTAssertEqual(resultElementKind, testElementKind)
XCTAssertEqual(resultIndexPath, testRow)
XCTAssertEqual(resultIndexPath, testIndexPath)
subscription.dispose()
}

Expand Down

0 comments on commit fa8a8bb

Please sign in to comment.