mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-06 06:57:43 +03:00
Merge pull request #734 from devxoul/uiscrollview-rxscrollenabled
Add UIScrollView.rx_scrollEnabled
This commit is contained in:
commit
49e9057d28
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
|
||||
#### Features
|
||||
|
||||
* Adds `rx_title` to `UIViewController`.
|
||||
* Adds `rx_scrollEnabled` to `UIScrollView`.
|
||||
|
||||
|
||||
## [2.5.0](https://github.com/ReactiveX/RxSwift/releases/tag/2.5.0)
|
||||
|
@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
033C2EF61D081C460050C015 /* UIScrollView+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033C2EF41D081B2A0050C015 /* UIScrollView+RxTests.swift */; };
|
||||
1AF67DA21CED420A00C310FA /* PublishSubjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF67DA11CED420A00C310FA /* PublishSubjectTest.swift */; };
|
||||
1AF67DA31CED427D00C310FA /* PublishSubjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF67DA11CED420A00C310FA /* PublishSubjectTest.swift */; };
|
||||
1AF67DA41CED427D00C310FA /* PublishSubjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF67DA11CED420A00C310FA /* PublishSubjectTest.swift */; };
|
||||
@ -1373,6 +1374,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
033C2EF41D081B2A0050C015 /* UIScrollView+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScrollView+RxTests.swift"; sourceTree = "<group>"; };
|
||||
1AF67DA11CED420A00C310FA /* PublishSubjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishSubjectTest.swift; sourceTree = "<group>"; };
|
||||
1AF67DA51CED430100C310FA /* ReplaySubjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplaySubjectTest.swift; sourceTree = "<group>"; };
|
||||
271A97401CFC996B00D64125 /* UIViewController+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Rx.swift"; sourceTree = "<group>"; };
|
||||
@ -2298,6 +2300,7 @@
|
||||
C8F27DB11CE6711600D5FB4F /* UITextView+RxTests.swift */,
|
||||
844BC8B71CE5023200F5C7CB /* UIPickerView+RxTests.swift */,
|
||||
914FCD661CCDB82E0058B304 /* UIPageControl+RxTest.swift */,
|
||||
033C2EF41D081B2A0050C015 /* UIScrollView+RxTests.swift */,
|
||||
);
|
||||
path = RxCocoaTests;
|
||||
sourceTree = "<group>";
|
||||
@ -3489,6 +3492,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
033C2EF61D081C460050C015 /* UIScrollView+RxTests.swift in Sources */,
|
||||
C835092A1C38706E0027C24C /* CLLocationManager+RxTests.swift in Sources */,
|
||||
C83509661C38706E0027C24C /* RxTest.swift in Sources */,
|
||||
C83509611C38706E0027C24C /* ObserverTests.swift in Sources */,
|
||||
|
@ -46,7 +46,16 @@ extension UIScrollView {
|
||||
|
||||
return ControlProperty(values: proxy.contentOffsetSubject, valueSink: bindingObserver)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Bindable sink for `scrollEnabled` property.
|
||||
*/
|
||||
public var rx_scrollEnabled: AnyObserver<Bool> {
|
||||
return UIBindingObserver(UIElement: self) { scrollView, scrollEnabled in
|
||||
scrollView.scrollEnabled = scrollEnabled
|
||||
}.asObserver()
|
||||
}
|
||||
|
||||
/**
|
||||
Installs delegate as forwarding delegate on `rx_delegate`.
|
||||
|
||||
|
39
Tests/RxCocoaTests/UIScrollView+RxTests.swift
Normal file
39
Tests/RxCocoaTests/UIScrollView+RxTests.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// UIScrollView+RxTests.swift
|
||||
// Rx
|
||||
//
|
||||
// Created by Suyeol Jeon on 6/8/16.
|
||||
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
import Foundation
|
||||
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
import UIKit
|
||||
import XCTest
|
||||
|
||||
class UIScrollViewTests : RxTest {
|
||||
}
|
||||
|
||||
extension UIScrollViewTests {
|
||||
|
||||
func testScrollEnabled_False() {
|
||||
let scrollView = UIScrollView(frame: CGRect.zero)
|
||||
scrollView.scrollEnabled = true
|
||||
Observable.just(false).bindTo(scrollView.rx_scrollEnabled).dispose()
|
||||
XCTAssertTrue(scrollView.scrollEnabled == false)
|
||||
}
|
||||
|
||||
func testScrollEnabled_True() {
|
||||
let scrollView = UIScrollView(frame: CGRect.zero)
|
||||
scrollView.scrollEnabled = false
|
||||
Observable.just(true).bindTo(scrollView.rx_scrollEnabled).dispose()
|
||||
XCTAssertTrue(scrollView.scrollEnabled == true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user