Instantly share code, notes, and snippets.

View ScreenSizes.swift
enum ScreenSizes {
static let threePointFiveInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 480)
static let fourInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 568)
static let fourPointSevenInchesPhoneFrame = CGRect(x: 0, y: 0, width: 375, height: 667)
static let iPadPortrait = CGRect(x: 0, y: 0, width: 768, height: 1024)
static let iPadLandscape = CGRect(x: 0, y: 0, width: 1024, height: 768)
}
View TwoWayBinding.swift
import Foundation
import RxSwift
import RxSwiftExt
import RxCocoa
extension Variable {
func bidirectionalBind(with controlProperty: ControlProperty<Element>) -> Disposable {
let bindingToControl = self
.asDriver()
.drive(controlProperty)
View ab_rxactionsheet_tests_16.swift
func test_asksManagerForLastPhotoTaken_version2() {
let expectedImage = UIImage()
photosManagerMock.expectedImage = expectedImage
expect(subject.lastPhotoTaken) == expectedImage
}
View ab_rxactionsheet_tests_15.swift
func test_asksManagerForLastPhotoTaken_version2() {
let expectedImage = UIImage()
photosManagerMock.expectedImage = expectedImage
let image = try! subject.lastPhotoTaken.toBlocking().first()!
XCTAssertEqual(image, expectedImage)
}
View ab_rxactionsheet_tests_14.swift
override func setUp() {
//...
driveOnScheduler(testScheduler) {
subject = AvatarViewModel(imageReceiver: imageHavingMock)
}
}
View ab_rxactionsheet_tests_13.swift
func test_receiveImage_onButtonClick2() {
simulateTaps(at: 100, 200)
let observer = testScheduler.createObserver(UIImage.self)
subject.image.drive(observer)
.disposed(by: rx_disposeBag)
testScheduler.start()
XCTAssertEqual(observer.events, [next(100, imageHavingMock.expectedImage), next(200, imageHavingMock.expectedImage)])
}
View ab_rxactionsheet_tests_12.swift
func test_receiveImage_onButtonClick_version2() {
let buttonTaps = testScheduler.createHotObservable([next(100, ()), next(200, ())])
buttonTaps.bindTo(subject.chooseImageButtonPressed)
.disposed(by: rx_disposeBag)
let observer = testScheduler.createObserver(UIImage.self)
self.subject.image.drive(observer)
.disposed(by: self.rx_disposeBag)
testScheduler.start()
View ab_rxactionsheet_tests_11.swift
testScheduler.start()
XCTAssertEqual(observer.events, [next(100, imageHavingMock.expectedImage), next(200, imageHavingMock.expectedImage)])
View ab_rxactionsheet_tests_10.swift
let observer = testScheduler.createObserver(UIImage.self)
subject.image.drive(observer)
.disposed(by: rx_disposeBag)
View ab_rxactionsheet_tests_9.swift
let buttonTaps = testScheduler.createHotObservable([next(100, ()), next(200, ())])
buttonTaps.bindTo(subject.chooseImageButtonPressed)
.disposed(by: rx_disposeBag)