From 0188dccd4fa8548e8af973757c0c091dc55ca536 Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Sat, 7 May 2016 12:23:50 -0700 Subject: [PATCH 1/3] create UIAlertAction+Rx.swift --- Rx.xcodeproj/project.pbxproj | 8 ++++++++ RxCocoa/iOS/UIAlertAction+Rx.swift | 32 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 RxCocoa/iOS/UIAlertAction+Rx.swift diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index a0536ce7..7204b265 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 46307D4E1CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46307D4D1CDE77D800E47A1C /* UIAlertAction+Rx.swift */; }; + 46307D4F1CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46307D4D1CDE77D800E47A1C /* UIAlertAction+Rx.swift */; }; + 46307D501CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46307D4D1CDE77D800E47A1C /* UIAlertAction+Rx.swift */; }; 79E9DE891C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; 79E9DE8A1C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; 79E9DE8B1C3417FD009970AF /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */; }; @@ -1338,6 +1341,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 46307D4D1CDE77D800E47A1C /* UIAlertAction+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIAlertAction+Rx.swift"; sourceTree = ""; }; 79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchQueueSchedulerQOS.swift; sourceTree = ""; }; 7EDBAEAB1C89B1A5006CBE67 /* UITabBarItem+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITabBarItem+RxTests.swift"; sourceTree = ""; }; 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITabBarItem+Rx.swift"; sourceTree = ""; }; @@ -2380,6 +2384,7 @@ C8BCD3EC1C14B5FB005F1280 /* UIView+Rx.swift */, 7EDBAEB71C89B9B7006CBE67 /* UITabBarItem+Rx.swift */, 84E4D3901C9AFCD500ADFDC9 /* UISearchController+Rx.swift */, + 46307D4D1CDE77D800E47A1C /* UIAlertAction+Rx.swift */, ); path = iOS; sourceTree = ""; @@ -3287,6 +3292,7 @@ C8C4B4A91C17722400828BD5 /* _RXObjCRuntime.m in Sources */, C8093EEF1B8A732E0088E94D /* KVOObserver.swift in Sources */, C882541F1B8A752B00B02D69 /* RxCollectionViewDelegateProxy.swift in Sources */, + 46307D4E1CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */, C88254201B8A752B00B02D69 /* RxScrollViewDelegateProxy.swift in Sources */, C882542E1B8A752B00B02D69 /* UILabel+Rx.swift in Sources */, C88254211B8A752B00B02D69 /* RxSearchBarDelegateProxy.swift in Sources */, @@ -4200,6 +4206,7 @@ C80DDEA21BCE69BA006A1832 /* Driver+Subscription.swift in Sources */, C811C8A01C24D80100A2DDD4 /* DeallocObservable.swift in Sources */, C8BCD3F01C14B5FB005F1280 /* UIView+Rx.swift in Sources */, + 46307D501CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */, C8F0C01F1BBBFBB9001B112F /* Observable+Bind.swift in Sources */, C8F0C0201BBBFBB9001B112F /* UISegmentedControl+Rx.swift in Sources */, C8F0C0211BBBFBB9001B112F /* KVOObservable.swift in Sources */, @@ -4299,6 +4306,7 @@ C8BCD3EF1C14B5FB005F1280 /* UIView+Rx.swift in Sources */, D2138C921BB9BED600339B5C /* KVOObserver.swift in Sources */, D2138C831BB9BEBE00339B5C /* _RXKVOObserver.m in Sources */, + 46307D4F1CDE77D800E47A1C /* UIAlertAction+Rx.swift in Sources */, C80DDEB31BCE8CA3006A1832 /* Driver+Operators+arity.swift in Sources */, C8DB968F1BF7595D0084BD53 /* KVORepresentable+Swift.swift in Sources */, D203C5061BB9C53E00D02D00 /* UIControl+Rx.swift in Sources */, diff --git a/RxCocoa/iOS/UIAlertAction+Rx.swift b/RxCocoa/iOS/UIAlertAction+Rx.swift new file mode 100644 index 00000000..1f9b02c2 --- /dev/null +++ b/RxCocoa/iOS/UIAlertAction+Rx.swift @@ -0,0 +1,32 @@ +// +// UIAlertAction+Rx.swift +// Rx +// +// Created by Andrew Breckenridge on 5/7/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(iOS) +import Foundation +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +extension UIAlertAction { + + /** + Bindable sink for `enabled` property. + */ + public var rx_enabled: AnyObserver { + return UIBindingObserver(UIElement: self) { alertAction, value in + alertAction.enabled = value + }.asObserver() + } + +} + +#endif \ No newline at end of file From c4e83f3f341adbbf2430b5bb7cad08821aa8b907 Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Sat, 7 May 2016 12:31:31 -0700 Subject: [PATCH 2/3] add UIAlertAction tests to Control+RxTests+UIKit --- Tests/RxCocoaTests/Control+RxTests+UIKit.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift index 2fa27c26..d33c53a4 100644 --- a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift +++ b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift @@ -159,6 +159,22 @@ extension ControlTests { } } +// UIAlertAction +extension ControlTests { + func testAlertAction_Enable { + let subject = UIAlertAction() + Observable.just(false).subscribe(subject.rx_enabled).dispose() + + XCTAssertTrue(subject.enabled == true) + } + + func testAlertAction_Disable { + let subject = UIAlertAction() + Observable.just(false).subscribe(subject.rx_enabled).dispose() + + XCTAssertTrue(subject.enabled == true) + } +} #if os(iOS) From af7c011a533d617cab1d7e714d5cfd1d7918e3f2 Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Sun, 8 May 2016 15:08:43 -0700 Subject: [PATCH 3/3] add forgotten parentheses to test function declarations --- Tests/RxCocoaTests/Control+RxTests+UIKit.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift index d33c53a4..f3ec9757 100644 --- a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift +++ b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift @@ -161,14 +161,14 @@ extension ControlTests { // UIAlertAction extension ControlTests { - func testAlertAction_Enable { + func testAlertAction_Enable() { let subject = UIAlertAction() Observable.just(false).subscribe(subject.rx_enabled).dispose() XCTAssertTrue(subject.enabled == true) } - func testAlertAction_Disable { + func testAlertAction_Disable() { let subject = UIAlertAction() Observable.just(false).subscribe(subject.rx_enabled).dispose()