├── .gitignore ├── Example ├── Podfile ├── Podfile.lock ├── Pods │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ ├── RxCocoa │ │ ├── LICENSE.md │ │ ├── Platform │ │ │ ├── DataStructures │ │ │ │ ├── Bag.swift │ │ │ │ ├── InfiniteSequence.swift │ │ │ │ ├── PriorityQueue.swift │ │ │ │ └── Queue.swift │ │ │ ├── DeprecationWarner.swift │ │ │ ├── DispatchQueue+Extensions.swift │ │ │ ├── Platform.Darwin.swift │ │ │ ├── Platform.Linux.swift │ │ │ └── RecursiveLock.swift │ │ ├── README.md │ │ └── RxCocoa │ │ │ ├── Common │ │ │ ├── Binder.swift │ │ │ ├── ControlTarget.swift │ │ │ ├── DelegateProxy.swift │ │ │ ├── DelegateProxyType.swift │ │ │ ├── NSLayoutConstraint+Rx.swift │ │ │ ├── Observable+Bind.swift │ │ │ ├── RxCocoaObjCRuntimeError+Extensions.swift │ │ │ ├── RxTarget.swift │ │ │ ├── SectionedViewDataSourceType.swift │ │ │ └── TextInput.swift │ │ │ ├── Deprecated.swift │ │ │ ├── Foundation │ │ │ ├── KVORepresentable+CoreGraphics.swift │ │ │ ├── KVORepresentable+Swift.swift │ │ │ ├── KVORepresentable.swift │ │ │ ├── Logging.swift │ │ │ ├── NSObject+Rx+KVORepresentable.swift │ │ │ ├── NSObject+Rx+RawRepresentable.swift │ │ │ ├── NSObject+Rx.swift │ │ │ ├── NotificationCenter+Rx.swift │ │ │ └── URLSession+Rx.swift │ │ │ ├── Runtime │ │ │ ├── _RX.m │ │ │ ├── _RXDelegateProxy.m │ │ │ ├── _RXKVOObserver.m │ │ │ ├── _RXObjCRuntime.m │ │ │ └── include │ │ │ │ ├── RxCocoaRuntime.h │ │ │ │ ├── _RX.h │ │ │ │ ├── _RXDelegateProxy.h │ │ │ │ ├── _RXKVOObserver.h │ │ │ │ └── _RXObjCRuntime.h │ │ │ ├── RxCocoa.h │ │ │ ├── RxCocoa.swift │ │ │ ├── Traits │ │ │ ├── BehaviorRelay.swift │ │ │ ├── ControlEvent.swift │ │ │ ├── ControlProperty.swift │ │ │ ├── Driver │ │ │ │ ├── BehaviorRelay+Driver.swift │ │ │ │ ├── ControlEvent+Driver.swift │ │ │ │ ├── ControlProperty+Driver.swift │ │ │ │ ├── Driver+Subscription.swift │ │ │ │ ├── Driver.swift │ │ │ │ └── ObservableConvertibleType+Driver.swift │ │ │ ├── PublishRelay.swift │ │ │ ├── SharedSequence │ │ │ │ ├── ObservableConvertibleType+SharedSequence.swift │ │ │ │ ├── SchedulerType+SharedSequence.swift │ │ │ │ ├── SharedSequence+Operators+arity.swift │ │ │ │ ├── SharedSequence+Operators.swift │ │ │ │ └── SharedSequence.swift │ │ │ └── Signal │ │ │ │ ├── ControlEvent+Signal.swift │ │ │ │ ├── ObservableConvertibleType+Signal.swift │ │ │ │ ├── PublishRelay+Signal.swift │ │ │ │ ├── Signal+Subscription.swift │ │ │ │ └── Signal.swift │ │ │ └── iOS │ │ │ ├── DataSources │ │ │ ├── RxCollectionViewReactiveArrayDataSource.swift │ │ │ ├── RxPickerViewAdapter.swift │ │ │ └── RxTableViewReactiveArrayDataSource.swift │ │ │ ├── Events │ │ │ └── ItemEvents.swift │ │ │ ├── NSTextStorage+Rx.swift │ │ │ ├── Protocols │ │ │ ├── RxCollectionViewDataSourceType.swift │ │ │ ├── RxPickerViewDataSourceType.swift │ │ │ └── RxTableViewDataSourceType.swift │ │ │ ├── Proxies │ │ │ ├── RxCollectionViewDataSourceProxy.swift │ │ │ ├── RxCollectionViewDelegateProxy.swift │ │ │ ├── RxNavigationControllerDelegateProxy.swift │ │ │ ├── RxPickerViewDataSourceProxy.swift │ │ │ ├── RxPickerViewDelegateProxy.swift │ │ │ ├── RxScrollViewDelegateProxy.swift │ │ │ ├── RxSearchBarDelegateProxy.swift │ │ │ ├── RxSearchControllerDelegateProxy.swift │ │ │ ├── RxTabBarControllerDelegateProxy.swift │ │ │ ├── RxTabBarDelegateProxy.swift │ │ │ ├── RxTableViewDataSourceProxy.swift │ │ │ ├── RxTableViewDelegateProxy.swift │ │ │ ├── RxTextStorageDelegateProxy.swift │ │ │ ├── RxTextViewDelegateProxy.swift │ │ │ └── RxWebViewDelegateProxy.swift │ │ │ ├── UIActivityIndicatorView+Rx.swift │ │ │ ├── UIAlertAction+Rx.swift │ │ │ ├── UIApplication+Rx.swift │ │ │ ├── UIBarButtonItem+Rx.swift │ │ │ ├── UIButton+Rx.swift │ │ │ ├── UICollectionView+Rx.swift │ │ │ ├── UIControl+Rx.swift │ │ │ ├── UIDatePicker+Rx.swift │ │ │ ├── UIGestureRecognizer+Rx.swift │ │ │ ├── UIImageView+Rx.swift │ │ │ ├── UILabel+Rx.swift │ │ │ ├── UINavigationController+Rx.swift │ │ │ ├── UINavigationItem+Rx.swift │ │ │ ├── UIPageControl+Rx.swift │ │ │ ├── UIPickerView+Rx.swift │ │ │ ├── UIProgressView+Rx.swift │ │ │ ├── UIRefreshControl+Rx.swift │ │ │ ├── UIScrollView+Rx.swift │ │ │ ├── UISearchBar+Rx.swift │ │ │ ├── UISearchController+Rx.swift │ │ │ ├── UISegmentedControl+Rx.swift │ │ │ ├── UISlider+Rx.swift │ │ │ ├── UIStepper+Rx.swift │ │ │ ├── UISwitch+Rx.swift │ │ │ ├── UITabBar+Rx.swift │ │ │ ├── UITabBarController+Rx.swift │ │ │ ├── UITabBarItem+Rx.swift │ │ │ ├── UITableView+Rx.swift │ │ │ ├── UITextField+Rx.swift │ │ │ ├── UITextView+Rx.swift │ │ │ ├── UIView+Rx.swift │ │ │ ├── UIViewController+Rx.swift │ │ │ └── UIWebView+Rx.swift │ ├── RxSwift │ │ ├── LICENSE.md │ │ ├── Platform │ │ │ ├── DataStructures │ │ │ │ ├── Bag.swift │ │ │ │ ├── InfiniteSequence.swift │ │ │ │ ├── PriorityQueue.swift │ │ │ │ └── Queue.swift │ │ │ ├── DeprecationWarner.swift │ │ │ ├── DispatchQueue+Extensions.swift │ │ │ ├── Platform.Darwin.swift │ │ │ ├── Platform.Linux.swift │ │ │ └── RecursiveLock.swift │ │ ├── README.md │ │ └── RxSwift │ │ │ ├── AnyObserver.swift │ │ │ ├── Cancelable.swift │ │ │ ├── Concurrency │ │ │ ├── AsyncLock.swift │ │ │ ├── Lock.swift │ │ │ ├── LockOwnerType.swift │ │ │ ├── SynchronizedDisposeType.swift │ │ │ ├── SynchronizedOnType.swift │ │ │ └── SynchronizedUnsubscribeType.swift │ │ │ ├── ConnectableObservableType.swift │ │ │ ├── Deprecated.swift │ │ │ ├── Disposable.swift │ │ │ ├── Disposables │ │ │ ├── AnonymousDisposable.swift │ │ │ ├── BinaryDisposable.swift │ │ │ ├── BooleanDisposable.swift │ │ │ ├── CompositeDisposable.swift │ │ │ ├── Disposables.swift │ │ │ ├── DisposeBag.swift │ │ │ ├── DisposeBase.swift │ │ │ ├── NopDisposable.swift │ │ │ ├── RefCountDisposable.swift │ │ │ ├── ScheduledDisposable.swift │ │ │ ├── SerialDisposable.swift │ │ │ ├── SingleAssignmentDisposable.swift │ │ │ └── SubscriptionDisposable.swift │ │ │ ├── Errors.swift │ │ │ ├── Event.swift │ │ │ ├── Extensions │ │ │ ├── Bag+Rx.swift │ │ │ └── String+Rx.swift │ │ │ ├── GroupedObservable.swift │ │ │ ├── ImmediateSchedulerType.swift │ │ │ ├── Observable.swift │ │ │ ├── ObservableConvertibleType.swift │ │ │ ├── ObservableType+Extensions.swift │ │ │ ├── ObservableType.swift │ │ │ ├── Observables │ │ │ ├── AddRef.swift │ │ │ ├── Amb.swift │ │ │ ├── AsMaybe.swift │ │ │ ├── AsSingle.swift │ │ │ ├── Buffer.swift │ │ │ ├── Catch.swift │ │ │ ├── CombineLatest+Collection.swift │ │ │ ├── CombineLatest+arity.swift │ │ │ ├── CombineLatest.swift │ │ │ ├── Concat.swift │ │ │ ├── Create.swift │ │ │ ├── Debounce.swift │ │ │ ├── Debug.swift │ │ │ ├── DefaultIfEmpty.swift │ │ │ ├── Deferred.swift │ │ │ ├── Delay.swift │ │ │ ├── DelaySubscription.swift │ │ │ ├── Dematerialize.swift │ │ │ ├── DistinctUntilChanged.swift │ │ │ ├── Do.swift │ │ │ ├── ElementAt.swift │ │ │ ├── Empty.swift │ │ │ ├── Enumerated.swift │ │ │ ├── Error.swift │ │ │ ├── Filter.swift │ │ │ ├── First.swift │ │ │ ├── Generate.swift │ │ │ ├── GroupBy.swift │ │ │ ├── Just.swift │ │ │ ├── Map.swift │ │ │ ├── Materialize.swift │ │ │ ├── Merge.swift │ │ │ ├── Multicast.swift │ │ │ ├── Never.swift │ │ │ ├── ObserveOn.swift │ │ │ ├── Optional.swift │ │ │ ├── Producer.swift │ │ │ ├── Range.swift │ │ │ ├── Reduce.swift │ │ │ ├── Repeat.swift │ │ │ ├── RetryWhen.swift │ │ │ ├── Sample.swift │ │ │ ├── Scan.swift │ │ │ ├── Sequence.swift │ │ │ ├── ShareReplayScope.swift │ │ │ ├── SingleAsync.swift │ │ │ ├── Sink.swift │ │ │ ├── Skip.swift │ │ │ ├── SkipUntil.swift │ │ │ ├── SkipWhile.swift │ │ │ ├── StartWith.swift │ │ │ ├── SubscribeOn.swift │ │ │ ├── Switch.swift │ │ │ ├── SwitchIfEmpty.swift │ │ │ ├── Take.swift │ │ │ ├── TakeLast.swift │ │ │ ├── TakeUntil.swift │ │ │ ├── TakeWhile.swift │ │ │ ├── Throttle.swift │ │ │ ├── Timeout.swift │ │ │ ├── Timer.swift │ │ │ ├── ToArray.swift │ │ │ ├── Using.swift │ │ │ ├── Window.swift │ │ │ ├── WithLatestFrom.swift │ │ │ ├── Zip+Collection.swift │ │ │ ├── Zip+arity.swift │ │ │ └── Zip.swift │ │ │ ├── ObserverType.swift │ │ │ ├── Observers │ │ │ ├── AnonymousObserver.swift │ │ │ ├── ObserverBase.swift │ │ │ └── TailRecursiveSink.swift │ │ │ ├── Reactive.swift │ │ │ ├── Rx.swift │ │ │ ├── RxMutableBox.swift │ │ │ ├── SchedulerType.swift │ │ │ ├── Schedulers │ │ │ ├── ConcurrentDispatchQueueScheduler.swift │ │ │ ├── ConcurrentMainScheduler.swift │ │ │ ├── CurrentThreadScheduler.swift │ │ │ ├── HistoricalScheduler.swift │ │ │ ├── HistoricalSchedulerTimeConverter.swift │ │ │ ├── Internal │ │ │ │ ├── DispatchQueueConfiguration.swift │ │ │ │ ├── InvocableScheduledItem.swift │ │ │ │ ├── InvocableType.swift │ │ │ │ ├── ScheduledItem.swift │ │ │ │ └── ScheduledItemType.swift │ │ │ ├── MainScheduler.swift │ │ │ ├── OperationQueueScheduler.swift │ │ │ ├── RecursiveScheduler.swift │ │ │ ├── SchedulerServices+Emulation.swift │ │ │ ├── SerialDispatchQueueScheduler.swift │ │ │ ├── VirtualTimeConverterType.swift │ │ │ └── VirtualTimeScheduler.swift │ │ │ ├── Subjects │ │ │ ├── AsyncSubject.swift │ │ │ ├── BehaviorSubject.swift │ │ │ ├── PublishSubject.swift │ │ │ ├── ReplaySubject.swift │ │ │ └── SubjectType.swift │ │ │ ├── SwiftSupport │ │ │ └── SwiftSupport.swift │ │ │ └── Traits │ │ │ ├── Completable+AndThen.swift │ │ │ ├── Completable.swift │ │ │ ├── Maybe.swift │ │ │ ├── ObservableType+PrimitiveSequence.swift │ │ │ ├── PrimitiveSequence+Zip+arity.swift │ │ │ ├── PrimitiveSequence.swift │ │ │ └── Single.swift │ ├── Target Support Files │ │ ├── RxCocoa │ │ │ ├── Info.plist │ │ │ ├── RxCocoa-dummy.m │ │ │ ├── RxCocoa-prefix.pch │ │ │ ├── RxCocoa-umbrella.h │ │ │ ├── RxCocoa.modulemap │ │ │ └── RxCocoa.xcconfig │ │ ├── RxSwift │ │ │ ├── Info.plist │ │ │ ├── RxSwift-dummy.m │ │ │ ├── RxSwift-prefix.pch │ │ │ ├── RxSwift-umbrella.h │ │ │ ├── RxSwift.modulemap │ │ │ └── RxSwift.xcconfig │ │ └── TinyConstraints │ │ │ ├── Info.plist │ │ │ ├── TinyConstraints-dummy.m │ │ │ ├── TinyConstraints-prefix.pch │ │ │ ├── TinyConstraints-umbrella.h │ │ │ ├── TinyConstraints.modulemap │ │ │ └── TinyConstraints.xcconfig │ └── TinyConstraints │ │ ├── LICENSE │ │ ├── README.md │ │ └── TinyConstraints │ │ └── Classes │ │ ├── Abstraction.swift │ │ ├── Constrainable.swift │ │ ├── Constraints.swift │ │ ├── Stack.swift │ │ ├── TinyConstraints+superview.swift │ │ └── TinyConstraints.swift ├── Tests │ ├── Info.plist │ └── Tests.swift ├── XPlayer.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── XPlayer-Example.xcscheme ├── XPlayer.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── XPlayer │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── LICENSE ├── Pipfile ├── Pipfile.lock ├── README.md ├── XPlayer.podspec ├── XPlayer ├── Assets │ ├── .gitkeep │ ├── maximize_24.png │ ├── minimize_24.png │ ├── pause_24.png │ ├── play_24.png │ └── x_24.png └── Classes │ ├── .gitkeep │ ├── Utils.swift │ ├── WOMaintainer.swift │ ├── WOViewController.swift │ ├── XPlayer.swift │ ├── XPlayerViewController+Action.swift │ ├── XPlayerViewController+State.swift │ ├── XPlayerViewController+UI.swift │ └── XPlayerViewController.swift ├── _Pods.xcodeproj └── scripts └── gen_icon.py /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | platform :ios, '10.0' 3 | 4 | target 'XPlayer_Example' do 5 | pod 'XPlayer', :path => '../' 6 | pod 'TinyConstraints' 7 | pod 'RxSwift', '~> 4.0' 8 | pod 'RxCocoa', '~> 4.0' 9 | end 10 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RxCocoa (4.1.2): 3 | - RxSwift (~> 4.0) 4 | - RxSwift (4.1.2) 5 | - TinyConstraints (3.1.0) 6 | - XPlayer (0.2.0): 7 | - TinyConstraints (~> 3.0) 8 | 9 | DEPENDENCIES: 10 | - RxCocoa (~> 4.0) 11 | - RxSwift (~> 4.0) 12 | - TinyConstraints 13 | - XPlayer (from `../`) 14 | 15 | SPEC REPOS: 16 | https://github.com/CocoaPods/Specs.git: 17 | - RxCocoa 18 | - RxSwift 19 | - TinyConstraints 20 | 21 | EXTERNAL SOURCES: 22 | XPlayer: 23 | :path: "../" 24 | 25 | SPEC CHECKSUMS: 26 | RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a 27 | RxSwift: e49536837d9901277638493ea537394d4b55f570 28 | TinyConstraints: 4721a4b303c799328867078ade6560e152df54d1 29 | XPlayer: 54cb8faa38595e3cfa8563c72eb80bc678ea8f06 30 | 31 | PODFILE CHECKSUM: 676eb42c117cdefc536f02214a0d538555e1ade4 32 | 33 | COCOAPODS: 1.5.0 34 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RxCocoa (4.1.2): 3 | - RxSwift (~> 4.0) 4 | - RxSwift (4.1.2) 5 | - TinyConstraints (3.1.0) 6 | - XPlayer (0.2.0): 7 | - TinyConstraints (~> 3.0) 8 | 9 | DEPENDENCIES: 10 | - RxCocoa (~> 4.0) 11 | - RxSwift (~> 4.0) 12 | - TinyConstraints 13 | - XPlayer (from `../`) 14 | 15 | SPEC REPOS: 16 | https://github.com/CocoaPods/Specs.git: 17 | - RxCocoa 18 | - RxSwift 19 | - TinyConstraints 20 | 21 | EXTERNAL SOURCES: 22 | XPlayer: 23 | :path: "../" 24 | 25 | SPEC CHECKSUMS: 26 | RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a 27 | RxSwift: e49536837d9901277638493ea537394d4b55f570 28 | TinyConstraints: 4721a4b303c799328867078ade6560e152df54d1 29 | XPlayer: 54cb8faa38595e3cfa8563c72eb80bc678ea8f06 30 | 31 | PODFILE CHECKSUM: 676eb42c117cdefc536f02214a0d538555e1ade4 32 | 33 | COCOAPODS: 1.5.0 34 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/LICENSE.md: -------------------------------------------------------------------------------- 1 | **The MIT License** 2 | **Copyright © 2015 Krunoslav Zaher** 3 | **All rights reserved.** 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/Platform/DataStructures/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteSequence.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Sequence that repeats `repeatedValue` infinite number of times. 10 | struct InfiniteSequence : Sequence { 11 | typealias Element = E 12 | typealias Iterator = AnyIterator 13 | 14 | private let _repeatedValue: E 15 | 16 | init(repeatedValue: E) { 17 | _repeatedValue = repeatedValue 18 | } 19 | 20 | func makeIterator() -> Iterator { 21 | let repeatedValue = _repeatedValue 22 | return AnyIterator { 23 | return repeatedValue 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/Platform/DeprecationWarner.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DeprecationWarner.swift 3 | // Platform 4 | // 5 | // Created by Shai Mishali on 1/9/18. 6 | // Copyright © 2018 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if DEBUG 12 | class DeprecationWarner { 13 | private static var warned = Set() 14 | private static var _lock = NSRecursiveLock() 15 | 16 | static func warnIfNeeded(_ kind: Kind) { 17 | _lock.lock(); defer { _lock.unlock() } 18 | guard !warned.contains(kind) else { return } 19 | 20 | warned.insert(kind) 21 | print("ℹ️ [DEPRECATED] \(kind.message)") 22 | } 23 | } 24 | 25 | extension DeprecationWarner { 26 | enum Kind { 27 | case variable 28 | case globalTestFunctionNext 29 | case globalTestFunctionError 30 | case globalTestFunctionCompleted 31 | 32 | var message: String { 33 | switch self { 34 | case .variable: return "`Variable` is planned for future deprecation. Please consider `BehaviorRelay` as a replacement. Read more at: https://git.io/vNqvx" 35 | case .globalTestFunctionNext: return "The `next()` global function is planned for future deprecation. Please use `Recorded.next()` instead." 36 | case .globalTestFunctionError: return "The `error()` global function is planned for future deprecation. Please use `Recorded.error()` instead." 37 | case .globalTestFunctionCompleted: return "The `completed()` global function is planned for future deprecation. Please use `Recorded.completed()` instead." 38 | } 39 | } 40 | } 41 | } 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/Platform/DispatchQueue+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DispatchQueue+Extensions.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 10/22/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Dispatch 10 | 11 | extension DispatchQueue { 12 | private static var token: DispatchSpecificKey<()> = { 13 | let key = DispatchSpecificKey<()>() 14 | DispatchQueue.main.setSpecific(key: key, value: ()) 15 | return key 16 | }() 17 | 18 | static var isMain: Bool { 19 | return DispatchQueue.getSpecific(key: token) != nil 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/Platform/Platform.Darwin.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Platform.Darwin.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) 10 | 11 | import Darwin 12 | import class Foundation.Thread 13 | import func Foundation.OSAtomicCompareAndSwap32Barrier 14 | import func Foundation.OSAtomicIncrement32Barrier 15 | import func Foundation.OSAtomicDecrement32Barrier 16 | import protocol Foundation.NSCopying 17 | 18 | typealias AtomicInt = Int32 19 | 20 | fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer) -> UnsafeMutablePointer { 21 | let raw = UnsafeMutableRawPointer(pointer) 22 | return raw.assumingMemoryBound(to: UInt32.self) 23 | } 24 | 25 | let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier 26 | let AtomicIncrement = OSAtomicIncrement32Barrier 27 | let AtomicDecrement = OSAtomicDecrement32Barrier 28 | func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Int32 { 29 | return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue)) 30 | } 31 | func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Bool { 32 | // just used to create a barrier 33 | OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue)) 34 | return (theValue.pointee & Int32(mask)) != 0 35 | } 36 | 37 | extension Thread { 38 | 39 | static func setThreadLocalStorageValue(_ value: T?, forKey key: NSCopying 40 | ) { 41 | let currentThread = Thread.current 42 | let threadDictionary = currentThread.threadDictionary 43 | 44 | if let newValue = value { 45 | threadDictionary[key] = newValue 46 | } 47 | else { 48 | threadDictionary[key] = nil 49 | } 50 | 51 | } 52 | static func getThreadLocalStorageValueForKey(_ key: NSCopying) -> T? { 53 | let currentThread = Thread.current 54 | let threadDictionary = currentThread.threadDictionary 55 | 56 | return threadDictionary[key] as? T 57 | } 58 | } 59 | 60 | extension AtomicInt { 61 | func valueSnapshot() -> Int32 { 62 | return self 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/Platform/RecursiveLock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RecursiveLock.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/18/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NSRecursiveLock 10 | 11 | #if TRACE_RESOURCES 12 | class RecursiveLock: NSRecursiveLock { 13 | override init() { 14 | _ = Resources.incrementTotal() 15 | super.init() 16 | } 17 | 18 | override func lock() { 19 | super.lock() 20 | _ = Resources.incrementTotal() 21 | } 22 | 23 | override func unlock() { 24 | super.unlock() 25 | _ = Resources.decrementTotal() 26 | } 27 | 28 | deinit { 29 | _ = Resources.decrementTotal() 30 | } 31 | } 32 | #else 33 | typealias RecursiveLock = NSRecursiveLock 34 | #endif 35 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Common/Binder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Binder.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/17/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | /** 12 | Observer that enforces interface binding rules: 13 | * can't bind errors (in debug builds binding of errors causes `fatalError` in release builds errors are being logged) 14 | * ensures binding is performed on a specific scheduler 15 | 16 | `Binder` doesn't retain target and in case target is released, element isn't bound. 17 | 18 | By default it binds elements on main scheduler. 19 | */ 20 | public struct Binder: ObserverType { 21 | public typealias E = Value 22 | 23 | private let _binding: (Event) -> () 24 | 25 | /// Initializes `Binder` 26 | /// 27 | /// - parameter target: Target object. 28 | /// - parameter scheduler: Scheduler used to bind the events. 29 | /// - parameter binding: Binding logic. 30 | public init(_ target: Target, scheduler: ImmediateSchedulerType = MainScheduler(), binding: @escaping (Target, Value) -> ()) { 31 | weak var weakTarget = target 32 | 33 | _binding = { event in 34 | switch event { 35 | case .next(let element): 36 | _ = scheduler.schedule(element) { element in 37 | if let target = weakTarget { 38 | binding(target, element) 39 | } 40 | return Disposables.create() 41 | } 42 | case .error(let error): 43 | bindingError(error) 44 | case .completed: 45 | break 46 | } 47 | } 48 | } 49 | 50 | /// Binds next element to owner view as described in `binding`. 51 | public func on(_ event: Event) { 52 | _binding(event) 53 | } 54 | 55 | /// Erases type of observer. 56 | /// 57 | /// - returns: type erased observer. 58 | public func asObserver() -> AnyObserver { 59 | return AnyObserver(eventHandler: on) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if !os(Linux) 10 | 11 | #if os(macOS) 12 | import Cocoa 13 | #else 14 | import UIKit 15 | #endif 16 | 17 | import RxSwift 18 | 19 | #if os(iOS) || os(macOS) || os(tvOS) 20 | extension Reactive where Base: NSLayoutConstraint { 21 | /// Bindable sink for `constant` property. 22 | public var constant: Binder { 23 | return Binder(self.base) { constraint, constant in 24 | constraint.constant = constant 25 | } 26 | } 27 | 28 | /// Bindable sink for `active` property. 29 | @available(iOS 8, OSX 10.10, *) 30 | public var active: Binder { 31 | return Binder(self.base) { constraint, value in 32 | constraint.isActive = value 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Common/RxTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTarget.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NSObject 10 | 11 | import RxSwift 12 | 13 | class RxTarget : NSObject 14 | , Disposable { 15 | 16 | private var retainSelf: RxTarget? 17 | 18 | override init() { 19 | super.init() 20 | self.retainSelf = self 21 | 22 | #if TRACE_RESOURCES 23 | _ = Resources.incrementTotal() 24 | #endif 25 | 26 | #if DEBUG 27 | MainScheduler.ensureExecutingOnScheduler() 28 | #endif 29 | } 30 | 31 | func dispose() { 32 | #if DEBUG 33 | MainScheduler.ensureExecutingOnScheduler() 34 | #endif 35 | self.retainSelf = nil 36 | } 37 | 38 | #if TRACE_RESOURCES 39 | deinit { 40 | _ = Resources.decrementTotal() 41 | } 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Common/SectionedViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SectionedViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 1/10/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.IndexPath 10 | 11 | /// Data source with access to underlying sectioned model. 12 | public protocol SectionedViewDataSourceType { 13 | /// Returns model at index path. 14 | /// 15 | /// In case data source doesn't contain any sections when this method is being called, `RxCocoaError.ItemsNotYetBound(object: self)` is thrown. 16 | 17 | /// - parameter indexPath: Model index path 18 | /// - returns: Model at index path. 19 | func model(at indexPath: IndexPath) throws -> Any 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Common/TextInput.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextInput.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 5/12/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | #if os(iOS) || os(tvOS) 12 | import UIKit 13 | 14 | /// Represents text input with reactive extensions. 15 | public struct TextInput { 16 | /// Base text input to extend. 17 | public let base: Base 18 | 19 | /// Reactive wrapper for `text` property. 20 | public let text: ControlProperty 21 | 22 | /// Initializes new text input. 23 | /// 24 | /// - parameter base: Base object. 25 | /// - parameter text: Textual control property. 26 | public init(base: Base, text: ControlProperty) { 27 | self.base = base 28 | self.text = text 29 | } 30 | } 31 | 32 | extension Reactive where Base: UITextField { 33 | /// Reactive text input. 34 | public var textInput: TextInput { 35 | return TextInput(base: base, text: self.text) 36 | } 37 | } 38 | 39 | extension Reactive where Base: UITextView { 40 | /// Reactive text input. 41 | public var textInput: TextInput { 42 | return TextInput(base: base, text: self.text) 43 | } 44 | } 45 | 46 | #endif 47 | 48 | #if os(macOS) 49 | import Cocoa 50 | 51 | /// Represents text input with reactive extensions. 52 | public struct TextInput { 53 | /// Base text input to extend. 54 | public let base: Base 55 | 56 | /// Reactive wrapper for `text` property. 57 | public let text: ControlProperty 58 | 59 | /// Initializes new text input. 60 | /// 61 | /// - parameter base: Base object. 62 | /// - parameter text: Textual control property. 63 | public init(base: Base, text: ControlProperty) { 64 | self.base = base 65 | self.text = text 66 | } 67 | } 68 | 69 | extension Reactive where Base: NSTextField, Base: NSTextInputClient { 70 | /// Reactive text input. 71 | public var textInput: TextInput { 72 | return TextInput(base: base, text: self.text) 73 | } 74 | } 75 | 76 | #endif 77 | 78 | 79 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/KVORepresentable+CoreGraphics.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVORepresentable+CoreGraphics.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if !os(Linux) 10 | 11 | import RxSwift 12 | import CoreGraphics 13 | 14 | import class Foundation.NSValue 15 | 16 | #if arch(x86_64) || arch(arm64) 17 | let CGRectType = "{CGRect={CGPoint=dd}{CGSize=dd}}" 18 | let CGSizeType = "{CGSize=dd}" 19 | let CGPointType = "{CGPoint=dd}" 20 | #elseif arch(i386) || arch(arm) 21 | let CGRectType = "{CGRect={CGPoint=ff}{CGSize=ff}}" 22 | let CGSizeType = "{CGSize=ff}" 23 | let CGPointType = "{CGPoint=ff}" 24 | #endif 25 | 26 | extension CGRect : KVORepresentable { 27 | public typealias KVOType = NSValue 28 | 29 | /// Constructs self from `NSValue`. 30 | public init?(KVOValue: KVOType) { 31 | if strcmp(KVOValue.objCType, CGRectType) != 0 { 32 | return nil 33 | } 34 | var typedValue = CGRect(x: 0, y: 0, width: 0, height: 0) 35 | KVOValue.getValue(&typedValue) 36 | self = typedValue 37 | } 38 | } 39 | 40 | extension CGPoint : KVORepresentable { 41 | public typealias KVOType = NSValue 42 | 43 | /// Constructs self from `NSValue`. 44 | public init?(KVOValue: KVOType) { 45 | if strcmp(KVOValue.objCType, CGPointType) != 0 { 46 | return nil 47 | } 48 | var typedValue = CGPoint(x: 0, y: 0) 49 | KVOValue.getValue(&typedValue) 50 | self = typedValue 51 | } 52 | } 53 | 54 | extension CGSize : KVORepresentable { 55 | public typealias KVOType = NSValue 56 | 57 | /// Constructs self from `NSValue`. 58 | public init?(KVOValue: KVOType) { 59 | if strcmp(KVOValue.objCType, CGSizeType) != 0 { 60 | return nil 61 | } 62 | var typedValue = CGSize(width: 0, height: 0) 63 | KVOValue.getValue(&typedValue) 64 | self = typedValue 65 | } 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/KVORepresentable+Swift.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVORepresentable+Swift.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NSNumber 10 | 11 | extension Int : KVORepresentable { 12 | public typealias KVOType = NSNumber 13 | 14 | /// Constructs `Self` using KVO value. 15 | public init?(KVOValue: KVOType) { 16 | self.init(KVOValue.int32Value) 17 | } 18 | } 19 | 20 | extension Int32 : KVORepresentable { 21 | public typealias KVOType = NSNumber 22 | 23 | /// Constructs `Self` using KVO value. 24 | public init?(KVOValue: KVOType) { 25 | self.init(KVOValue.int32Value) 26 | } 27 | } 28 | 29 | extension Int64 : KVORepresentable { 30 | public typealias KVOType = NSNumber 31 | 32 | /// Constructs `Self` using KVO value. 33 | public init?(KVOValue: KVOType) { 34 | self.init(KVOValue.int64Value) 35 | } 36 | } 37 | 38 | extension UInt : KVORepresentable { 39 | public typealias KVOType = NSNumber 40 | 41 | /// Constructs `Self` using KVO value. 42 | public init?(KVOValue: KVOType) { 43 | self.init(KVOValue.uintValue) 44 | } 45 | } 46 | 47 | extension UInt32 : KVORepresentable { 48 | public typealias KVOType = NSNumber 49 | 50 | /// Constructs `Self` using KVO value. 51 | public init?(KVOValue: KVOType) { 52 | self.init(KVOValue.uint32Value) 53 | } 54 | } 55 | 56 | extension UInt64 : KVORepresentable { 57 | public typealias KVOType = NSNumber 58 | 59 | /// Constructs `Self` using KVO value. 60 | public init?(KVOValue: KVOType) { 61 | self.init(KVOValue.uint64Value) 62 | } 63 | } 64 | 65 | extension Bool : KVORepresentable { 66 | public typealias KVOType = NSNumber 67 | 68 | /// Constructs `Self` using KVO value. 69 | public init?(KVOValue: KVOType) { 70 | self.init(KVOValue.boolValue) 71 | } 72 | } 73 | 74 | 75 | extension RawRepresentable where RawValue: KVORepresentable { 76 | /// Constructs `Self` using optional KVO value. 77 | init?(KVOValue: RawValue.KVOType?) { 78 | guard let KVOValue = KVOValue else { 79 | return nil 80 | } 81 | 82 | guard let rawValue = RawValue(KVOValue: KVOValue) else { 83 | return nil 84 | } 85 | 86 | self.init(rawValue: rawValue) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/KVORepresentable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVORepresentable.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Type that is KVO representable (KVO mechanism can be used to observe it). 10 | public protocol KVORepresentable { 11 | /// Associated KVO type. 12 | associatedtype KVOType 13 | 14 | /// Constructs `Self` using KVO value. 15 | init?(KVOValue: KVOType) 16 | } 17 | 18 | extension KVORepresentable { 19 | /// Initializes `KVORepresentable` with optional value. 20 | init?(KVOValue: KVOType?) { 21 | guard let KVOValue = KVOValue else { 22 | return nil 23 | } 24 | 25 | self.init(KVOValue: KVOValue) 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/Logging.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logging.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/3/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.URLRequest 10 | 11 | /// Simple logging settings for RxCocoa library. 12 | public struct Logging { 13 | public typealias LogURLRequest = (URLRequest) -> Bool 14 | 15 | /// Log URL requests to standard output in curl format. 16 | public static var URLRequests: LogURLRequest = { _ in 17 | #if DEBUG 18 | return true 19 | #else 20 | return false 21 | #endif 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/NSObject+Rx+KVORepresentable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Rx+KVORepresentable.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if !os(Linux) 10 | 11 | import Foundation.NSObject 12 | import RxSwift 13 | 14 | /// Key value observing options 15 | public struct KeyValueObservingOptions: OptionSet { 16 | /// Raw value 17 | public let rawValue: UInt 18 | 19 | public init(rawValue: UInt) { 20 | self.rawValue = rawValue 21 | } 22 | 23 | /// Whether a sequence element should be sent to the observer immediately, before the subscribe method even returns. 24 | public static let initial = KeyValueObservingOptions(rawValue: 1 << 0) 25 | /// Whether to send updated values. 26 | public static let new = KeyValueObservingOptions(rawValue: 1 << 1) 27 | } 28 | 29 | extension Reactive where Base: NSObject { 30 | 31 | /** 32 | Specialization of generic `observe` method. 33 | 34 | This is a special overload because to observe values of some type (for example `Int`), first values of KVO type 35 | need to be observed (`NSNumber`), and then converted to result type. 36 | 37 | For more information take a look at `observe` method. 38 | */ 39 | public func observe(_ type: E.Type, _ keyPath: String, options: KeyValueObservingOptions = [.new, .initial], retainSelf: Bool = true) -> Observable { 40 | return observe(E.KVOType.self, keyPath, options: options, retainSelf: retainSelf) 41 | .map(E.init) 42 | } 43 | } 44 | 45 | #if !DISABLE_SWIZZLING && !os(Linux) 46 | // KVO 47 | extension Reactive where Base: NSObject { 48 | /** 49 | Specialization of generic `observeWeakly` method. 50 | 51 | For more information take a look at `observeWeakly` method. 52 | */ 53 | public func observeWeakly(_ type: E.Type, _ keyPath: String, options: KeyValueObservingOptions = [.new, .initial]) -> Observable { 54 | return observeWeakly(E.KVOType.self, keyPath, options: options) 55 | .map(E.init) 56 | } 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/NSObject+Rx+RawRepresentable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Rx+RawRepresentable.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/9/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if !os(Linux) 10 | 11 | import RxSwift 12 | 13 | import Foundation.NSObject 14 | 15 | extension Reactive where Base: NSObject { 16 | /** 17 | Specialization of generic `observe` method. 18 | 19 | This specialization first observes `KVORepresentable` value and then converts it to `RawRepresentable` value. 20 | 21 | It is useful for observing bridged ObjC enum values. 22 | 23 | For more information take a look at `observe` method. 24 | */ 25 | public func observe(_ type: E.Type, _ keyPath: String, options: KeyValueObservingOptions = [.new, .initial], retainSelf: Bool = true) -> Observable where E.RawValue: KVORepresentable { 26 | return observe(E.RawValue.KVOType.self, keyPath, options: options, retainSelf: retainSelf) 27 | .map(E.init) 28 | } 29 | } 30 | 31 | #if !DISABLE_SWIZZLING 32 | 33 | // observeWeakly + RawRepresentable 34 | extension Reactive where Base: NSObject { 35 | 36 | /** 37 | Specialization of generic `observeWeakly` method. 38 | 39 | This specialization first observes `KVORepresentable` value and then converts it to `RawRepresentable` value. 40 | 41 | It is useful for observing bridged ObjC enum values. 42 | 43 | For more information take a look at `observeWeakly` method. 44 | */ 45 | public func observeWeakly(_ type: E.Type, _ keyPath: String, options: KeyValueObservingOptions = [.new, .initial]) -> Observable where E.RawValue: KVORepresentable { 46 | return observeWeakly(E.RawValue.KVOType.self, keyPath, options: options) 47 | .map(E.init) 48 | } 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Foundation/NotificationCenter+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationCenter+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 5/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NotificationCenter 10 | import struct Foundation.Notification 11 | 12 | import RxSwift 13 | 14 | extension Reactive where Base: NotificationCenter { 15 | /** 16 | Transforms notifications posted to notification center to observable sequence of notifications. 17 | 18 | - parameter name: Optional name used to filter notifications. 19 | - parameter object: Optional object used to filter notifications. 20 | - returns: Observable sequence of posted notifications. 21 | */ 22 | public func notification(_ name: Notification.Name?, object: AnyObject? = nil) -> Observable { 23 | return Observable.create { [weak object] observer in 24 | let nsObserver = self.base.addObserver(forName: name, object: object, queue: nil) { notification in 25 | observer.on(.next(notification)) 26 | } 27 | 28 | return Disposables.create { 29 | self.base.removeObserver(nsObserver) 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Runtime/_RX.m: -------------------------------------------------------------------------------- 1 | // 2 | // _RX.m 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import "include/_RX.h" 10 | 11 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Runtime/_RXKVOObserver.m: -------------------------------------------------------------------------------- 1 | // 2 | // _RXKVOObserver.m 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/11/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import "include/_RXKVOObserver.h" 10 | 11 | @interface _RXKVOObserver () 12 | 13 | @property (nonatomic, unsafe_unretained) id target; 14 | @property (nonatomic, strong ) id retainedTarget; 15 | @property (nonatomic, copy ) NSString *keyPath; 16 | @property (nonatomic, copy ) void (^callback)(id); 17 | 18 | @end 19 | 20 | @implementation _RXKVOObserver 21 | 22 | -(instancetype)initWithTarget:(id)target 23 | retainTarget:(BOOL)retainTarget 24 | keyPath:(NSString*)keyPath 25 | options:(NSKeyValueObservingOptions)options 26 | callback:(void (^)(id))callback { 27 | self = [super init]; 28 | if (!self) return nil; 29 | 30 | self.target = target; 31 | if (retainTarget) { 32 | self.retainedTarget = target; 33 | } 34 | self.keyPath = keyPath; 35 | self.callback = callback; 36 | 37 | [self.target addObserver:self forKeyPath:self.keyPath options:options context:nil]; 38 | 39 | return self; 40 | } 41 | 42 | -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 43 | @synchronized(self) { 44 | self.callback(change[NSKeyValueChangeNewKey]); 45 | } 46 | } 47 | 48 | -(void)dispose { 49 | [self.target removeObserver:self forKeyPath:self.keyPath context:nil]; 50 | self.target = nil; 51 | self.retainedTarget = nil; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Runtime/include/RxCocoaRuntime.h: -------------------------------------------------------------------------------- 1 | // 2 | // RxCocoaRuntime.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "_RX.h" 11 | #import "_RXDelegateProxy.h" 12 | #import "_RXKVOObserver.h" 13 | #import "_RXObjCRuntime.h" 14 | 15 | //! Project version number for RxCocoa. 16 | FOUNDATION_EXPORT double RxCocoaVersionNumber; 17 | 18 | //! Project version string for RxCocoa. 19 | FOUNDATION_EXPORT const unsigned char RxCocoaVersionString[]; 20 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Runtime/include/_RXDelegateProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RXDelegateProxy.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface _RXDelegateProxy : NSObject 14 | 15 | @property (nonatomic, weak, readonly) id _forwardToDelegate; 16 | 17 | -(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate NS_SWIFT_NAME(_setForwardToDelegate(_:retainDelegate:)) ; 18 | 19 | -(BOOL)hasWiredImplementationForSelector:(SEL)selector; 20 | -(BOOL)voidDelegateMethodsContain:(SEL)selector; 21 | 22 | -(void)_sentMessage:(SEL)selector withArguments:(NSArray*)arguments; 23 | -(void)_methodInvoked:(SEL)selector withArguments:(NSArray*)arguments; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Runtime/include/_RXKVOObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RXKVOObserver.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/11/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | ################################################################################ 13 | This file is part of RX private API 14 | ################################################################################ 15 | */ 16 | 17 | // Exists because if written in Swift, reading unowned is disabled during dealloc process 18 | @interface _RXKVOObserver : NSObject 19 | 20 | -(instancetype)initWithTarget:(id)target 21 | retainTarget:(BOOL)retainTarget 22 | keyPath:(NSString*)keyPath 23 | options:(NSKeyValueObservingOptions)options 24 | callback:(void (^)(id))callback; 25 | 26 | -(void)dispose; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/RxCocoa.h: -------------------------------------------------------------------------------- 1 | // 2 | // RxCocoa.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "_RX.h" 11 | #import "_RXDelegateProxy.h" 12 | #import "_RXKVOObserver.h" 13 | #import "_RXObjCRuntime.h" 14 | 15 | //! Project version number for RxCocoa. 16 | FOUNDATION_EXPORT double RxCocoaVersionNumber; 17 | 18 | //! Project version string for RxCocoa. 19 | FOUNDATION_EXPORT const unsigned char RxCocoaVersionString[]; -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/BehaviorRelay.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BehaviorRelay.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 10/7/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | /// BehaviorRelay is a wrapper for `BehaviorSubject`. 12 | /// 13 | /// Unlike `BehaviorSubject` it can't terminate with error or completed. 14 | public final class BehaviorRelay: ObservableType { 15 | public typealias E = Element 16 | 17 | private let _subject: BehaviorSubject 18 | 19 | // Accepts `event` and emits it to subscribers 20 | public func accept(_ event: Element) { 21 | _subject.onNext(event) 22 | } 23 | 24 | /// Current value of behavior subject 25 | public var value: Element { 26 | // this try! is ok because subject can't error out or be disposed 27 | return try! _subject.value() 28 | } 29 | 30 | /// Initializes variable with initial value. 31 | public init(value: Element) { 32 | _subject = BehaviorSubject(value: value) 33 | } 34 | 35 | /// Subscribes observer 36 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 37 | return _subject.subscribe(observer) 38 | } 39 | 40 | /// - returns: Canonical interface for push style sequence 41 | public func asObservable() -> Observable { 42 | return _subject.asObservable() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Driver/BehaviorRelay+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BehaviorRelay+Driver.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 10/7/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension BehaviorRelay { 12 | /// Converts `BehaviorRelay` to `Driver`. 13 | /// 14 | /// - returns: Observable sequence. 15 | public func asDriver() -> Driver { 16 | let source = self.asObservable() 17 | .observeOn(DriverSharingStrategy.scheduler) 18 | return SharedSequence(source) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Driver/ControlEvent+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlEvent+Driver.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ControlEvent { 12 | /// Converts `ControlEvent` to `Driver` trait. 13 | /// 14 | /// `ControlEvent` already can't fail, so no special case needs to be handled. 15 | public func asDriver() -> Driver { 16 | return self.asDriver { (error) -> Driver in 17 | #if DEBUG 18 | rxFatalError("Somehow driver received error from a source that shouldn't fail.") 19 | #else 20 | return Driver.empty() 21 | #endif 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Driver/ControlProperty+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlProperty+Driver.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ControlProperty { 12 | /// Converts `ControlProperty` to `Driver` trait. 13 | /// 14 | /// `ControlProperty` already can't fail, so no special case needs to be handled. 15 | public func asDriver() -> Driver { 16 | return self.asDriver { (error) -> Driver in 17 | #if DEBUG 18 | rxFatalError("Somehow driver received error from a source that shouldn't fail.") 19 | #else 20 | return Driver.empty() 21 | #endif 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Driver.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/26/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | /** 12 | Trait that represents observable sequence with following properties: 13 | 14 | - it never fails 15 | - it delivers events on `MainScheduler.instance` 16 | - `share(replay: 1, scope: .whileConnected)` sharing strategy 17 | 18 | Additional explanation: 19 | - all observers share sequence computation resources 20 | - it's stateful, upon subscription (calling subscribe) last element is immediately replayed if it was produced 21 | - computation of elements is reference counted with respect to the number of observers 22 | - if there are no subscribers, it will release sequence computation resources 23 | 24 | In case trait that models event bus is required, please check `Signal`. 25 | 26 | `Driver` can be considered a builder pattern for observable sequences that drive the application. 27 | 28 | If observable sequence has produced at least one element, after new subscription is made last produced element will be 29 | immediately replayed on the same thread on which the subscription was made. 30 | 31 | When using `drive*`, `subscribe*` and `bind*` family of methods, they should always be called from main thread. 32 | 33 | If `drive*`, `subscribe*` and `bind*` are called from background thread, it is possible that initial replay 34 | will happen on background thread, and subsequent events will arrive on main thread. 35 | 36 | To find out more about traits and how to use them, please visit `Documentation/Traits.md`. 37 | */ 38 | public typealias Driver = SharedSequence 39 | 40 | public struct DriverSharingStrategy: SharingStrategyProtocol { 41 | public static var scheduler: SchedulerType { return SharingScheduler.make() } 42 | public static func share(_ source: Observable) -> Observable { 43 | return source.share(replay: 1, scope: .whileConnected) 44 | } 45 | } 46 | 47 | extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy { 48 | /// Adds `asDriver` to `SharingSequence` with `DriverSharingStrategy`. 49 | public func asDriver() -> Driver { 50 | return self.asSharedSequence() 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Driver/ObservableConvertibleType+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType+Driver.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ObservableConvertibleType { 12 | /** 13 | Converts observable sequence to `Driver` trait. 14 | 15 | - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. 16 | - returns: Driver trait. 17 | */ 18 | public func asDriver(onErrorJustReturn: E) -> Driver { 19 | let source = self 20 | .asObservable() 21 | .observeOn(DriverSharingStrategy.scheduler) 22 | .catchErrorJustReturn(onErrorJustReturn) 23 | return Driver(source) 24 | } 25 | 26 | /** 27 | Converts observable sequence to `Driver` trait. 28 | 29 | - parameter onErrorDriveWith: Driver that continues to drive the sequence in case of error. 30 | - returns: Driver trait. 31 | */ 32 | public func asDriver(onErrorDriveWith: Driver) -> Driver { 33 | let source = self 34 | .asObservable() 35 | .observeOn(DriverSharingStrategy.scheduler) 36 | .catchError { _ in 37 | onErrorDriveWith.asObservable() 38 | } 39 | return Driver(source) 40 | } 41 | 42 | /** 43 | Converts observable sequence to `Driver` trait. 44 | 45 | - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. 46 | - returns: Driver trait. 47 | */ 48 | public func asDriver(onErrorRecover: @escaping (_ error: Swift.Error) -> Driver) -> Driver { 49 | let source = self 50 | .asObservable() 51 | .observeOn(DriverSharingStrategy.scheduler) 52 | .catchError { error in 53 | onErrorRecover(error).asObservable() 54 | } 55 | return Driver(source) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/PublishRelay.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PublishRelay.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | /// PublishRelay is a wrapper for `PublishSubject`. 12 | /// 13 | /// Unlike `PublishSubject` it can't terminate with error or completed. 14 | public final class PublishRelay: ObservableType { 15 | public typealias E = Element 16 | 17 | private let _subject: PublishSubject 18 | 19 | // Accepts `event` and emits it to subscribers 20 | public func accept(_ event: Element) { 21 | _subject.onNext(event) 22 | } 23 | 24 | /// Initializes variable with initial value. 25 | public init() { 26 | _subject = PublishSubject() 27 | } 28 | 29 | /// Subscribes observer 30 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 31 | return _subject.subscribe(observer) 32 | } 33 | 34 | /// - returns: Canonical interface for push style sequence 35 | public func asObservable() -> Observable { 36 | return _subject.asObservable() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/ObservableConvertibleType+SharedSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType+SharedSequence.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/1/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ObservableConvertibleType { 12 | /** 13 | Converts anything convertible to `Observable` to `SharedSequence` unit. 14 | 15 | - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. 16 | - returns: Driving observable sequence. 17 | */ 18 | public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence { 19 | let source = self 20 | .asObservable() 21 | .observeOn(S.scheduler) 22 | .catchErrorJustReturn(onErrorJustReturn) 23 | return SharedSequence(source) 24 | } 25 | 26 | /** 27 | Converts anything convertible to `Observable` to `SharedSequence` unit. 28 | 29 | - parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error. 30 | - returns: Driving observable sequence. 31 | */ 32 | public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence) -> SharedSequence { 33 | let source = self 34 | .asObservable() 35 | .observeOn(S.scheduler) 36 | .catchError { _ in 37 | onErrorDriveWith.asObservable() 38 | } 39 | return SharedSequence(source) 40 | } 41 | 42 | /** 43 | Converts anything convertible to `Observable` to `SharedSequence` unit. 44 | 45 | - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. 46 | - returns: Driving observable sequence. 47 | */ 48 | public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence) -> SharedSequence { 49 | let source = self 50 | .asObservable() 51 | .observeOn(S.scheduler) 52 | .catchError { error in 53 | onErrorRecover(error).asObservable() 54 | } 55 | return SharedSequence(source) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SchedulerType+SharedSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchedulerType+SharedSequence.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 8/27/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | public enum SharingScheduler { 12 | /// Default scheduler used in SharedSequence based traits. 13 | public private(set) static var make: () -> SchedulerType = { MainScheduler() } 14 | 15 | /** 16 | This method can be used in unit tests to ensure that built in shared sequences are using mock schedulers instead 17 | of main schedulers. 18 | 19 | **This shouldn't be used in normal release builds.** 20 | */ 21 | static public func mock(scheduler: SchedulerType, action: () -> ()) { 22 | return mock(makeScheduler: { scheduler }, action: action) 23 | } 24 | 25 | /** 26 | This method can be used in unit tests to ensure that built in shared sequences are using mock schedulers instead 27 | of main schedulers. 28 | 29 | **This shouldn't be used in normal release builds.** 30 | */ 31 | static public func mock(makeScheduler: @escaping () -> SchedulerType, action: () -> ()) { 32 | let originalMake = make 33 | make = makeScheduler 34 | 35 | action() 36 | 37 | // If you remove this line , compiler buggy optimizations will change behavior of this code 38 | _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(makeScheduler) 39 | // Scary, I know 40 | 41 | make = originalMake 42 | } 43 | } 44 | 45 | #if os(Linux) 46 | import Glibc 47 | #else 48 | import func Foundation.arc4random 49 | #endif 50 | 51 | func _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(_ scheduler: () -> SchedulerType) { 52 | let a: Int32 = 1 53 | #if os(Linux) 54 | let b = 314 + Int32(Glibc.random() & 1) 55 | #else 56 | let b = 314 + Int32(arc4random() & 1) 57 | #endif 58 | if a == b { 59 | print(scheduler()) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Signal/ControlEvent+Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlEvent+Signal.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 11/1/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ControlEvent { 12 | /// Converts `ControlEvent` to `Signal` trait. 13 | /// 14 | /// `ControlEvent` already can't fail, so no special case needs to be handled. 15 | public func asSignal() -> Signal { 16 | return self.asSignal { (error) -> Signal in 17 | #if DEBUG 18 | rxFatalError("Somehow signal received error from a source that shouldn't fail.") 19 | #else 20 | return Signal.empty() 21 | #endif 22 | } 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Signal/ObservableConvertibleType+Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType+Signal.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension ObservableConvertibleType { 12 | /** 13 | Converts observable sequence to `Signal` trait. 14 | 15 | - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. 16 | - returns: Signal trait. 17 | */ 18 | public func asSignal(onErrorJustReturn: E) -> Signal { 19 | let source = self 20 | .asObservable() 21 | .observeOn(SignalSharingStrategy.scheduler) 22 | .catchErrorJustReturn(onErrorJustReturn) 23 | return Signal(source) 24 | } 25 | 26 | /** 27 | Converts observable sequence to `Driver` trait. 28 | 29 | - parameter onErrorDriveWith: Driver that continues to drive the sequence in case of error. 30 | - returns: Signal trait. 31 | */ 32 | public func asSignal(onErrorSignalWith: Signal) -> Signal { 33 | let source = self 34 | .asObservable() 35 | .observeOn(SignalSharingStrategy.scheduler) 36 | .catchError { _ in 37 | onErrorSignalWith.asObservable() 38 | } 39 | return Signal(source) 40 | } 41 | 42 | /** 43 | Converts observable sequence to `Driver` trait. 44 | 45 | - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. 46 | - returns: Signal trait. 47 | */ 48 | public func asSignal(onErrorRecover: @escaping (_ error: Swift.Error) -> Signal) -> Signal { 49 | let source = self 50 | .asObservable() 51 | .observeOn(SignalSharingStrategy.scheduler) 52 | .catchError { error in 53 | onErrorRecover(error).asObservable() 54 | } 55 | return Signal(source) 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Signal/PublishRelay+Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PublishRelay+Signal.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 12/28/15. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension PublishRelay { 12 | /// Converts `PublishRelay` to `Signal`. 13 | /// 14 | /// - returns: Observable sequence. 15 | public func asSignal() -> Signal { 16 | let source = self.asObservable() 17 | .observeOn(SignalSharingStrategy.scheduler) 18 | return SharedSequence(source) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Signal.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 9/26/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | /** 12 | Trait that represents observable sequence with following properties: 13 | 14 | - it never fails 15 | - it delivers events on `MainScheduler.instance` 16 | - `share(scope: .whileConnected)` sharing strategy 17 | 18 | Additional explanation: 19 | - all observers share sequence computation resources 20 | - there is no replaying of sequence elements on new observer subscription 21 | - computation of elements is reference counted with respect to the number of observers 22 | - if there are no subscribers, it will release sequence computation resources 23 | 24 | In case trait that models state propagation is required, please check `Driver`. 25 | 26 | `Signal` can be considered a builder pattern for observable sequences that model imperative events part of the application. 27 | 28 | To find out more about units and how to use them, please visit `Documentation/Traits.md`. 29 | */ 30 | public typealias Signal = SharedSequence 31 | 32 | public struct SignalSharingStrategy : SharingStrategyProtocol { 33 | public static var scheduler: SchedulerType { return SharingScheduler.make() } 34 | 35 | public static func share(_ source: Observable) -> Observable { 36 | return source.share(scope: .whileConnected) 37 | } 38 | } 39 | 40 | extension SharedSequenceConvertibleType where SharingStrategy == SignalSharingStrategy { 41 | /// Adds `asPublisher` to `SharingSequence` with `PublishSharingStrategy`. 42 | public func asSignal() -> Signal { 43 | return asSharedSequence() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Events/ItemEvents.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ItemEvents.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/20/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | 12 | public typealias ItemMovedEvent = (sourceIndex: IndexPath, destinationIndex: IndexPath) 13 | public typealias WillDisplayCellEvent = (cell: UITableViewCell, indexPath: IndexPath) 14 | public typealias DidEndDisplayingCellEvent = (cell: UITableViewCell, indexPath: IndexPath) 15 | #endif 16 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSTextStorage+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Segii Shulga on 12/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import RxSwift 11 | import UIKit 12 | 13 | extension Reactive where Base: NSTextStorage { 14 | 15 | /// Reactive wrapper for `delegate`. 16 | /// 17 | /// For more information take a look at `DelegateProxyType` protocol documentation. 18 | public var delegate: DelegateProxy { 19 | return RxTextStorageDelegateProxy.proxy(for: base) 20 | } 21 | 22 | /// Reactive wrapper for `delegate` message. 23 | public var didProcessEditingRangeChangeInLength: Observable<(editedMask:NSTextStorageEditActions, editedRange:NSRange, delta:Int)> { 24 | return delegate 25 | .methodInvoked(#selector(NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:))) 26 | .map { a in 27 | let editedMask = NSTextStorageEditActions(rawValue: try castOrThrow(UInt.self, a[1]) ) 28 | let editedRange = try castOrThrow(NSValue.self, a[2]).rangeValue 29 | let delta = try castOrThrow(Int.self, a[3]) 30 | 31 | return (editedMask, editedRange, delta) 32 | } 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCollectionViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// Marks data source as `UICollectionView` reactive data source enabling it to be used with one of the `bindTo` methods. 15 | public protocol RxCollectionViewDataSourceType /*: UICollectionViewDataSource*/ { 16 | 17 | /// Type of elements that can be bound to collection view. 18 | associatedtype Element 19 | 20 | /// New observable sequence event observed. 21 | /// 22 | /// - parameter collectionView: Bound collection view. 23 | /// - parameter observedEvent: Event 24 | func collectionView(_ collectionView: UICollectionView, observedEvent: Event) -> Void 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxPickerViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxPickerViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Sergey Shulga on 05/07/2017. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// Marks data source as `UIPickerView` reactive data source enabling it to be used with one of the `bindTo` methods. 15 | public protocol RxPickerViewDataSourceType { 16 | /// Type of elements that can be bound to picker view. 17 | associatedtype Element 18 | 19 | /// New observable sequence event observed. 20 | /// 21 | /// - parameter pickerView: Bound picker view. 22 | /// - parameter observedEvent: Event 23 | func pickerView(_ pickerView: UIPickerView, observedEvent: Event) 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTableViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/26/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// Marks data source as `UITableView` reactive data source enabling it to be used with one of the `bindTo` methods. 15 | public protocol RxTableViewDataSourceType /*: UITableViewDataSource*/ { 16 | 17 | /// Type of elements that can be bound to table view. 18 | associatedtype Element 19 | 20 | /// New observable sequence event observed. 21 | /// 22 | /// - parameter tableView: Bound table view. 23 | /// - parameter observedEvent: Event 24 | func tableView(_ tableView: UITableView, observedEvent: Event) -> Void 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCollectionViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// For more information take a look at `DelegateProxyType`. 15 | open class RxCollectionViewDelegateProxy 16 | : RxScrollViewDelegateProxy 17 | , UICollectionViewDelegate 18 | , UICollectionViewDelegateFlowLayout { 19 | 20 | /// Typed parent object. 21 | public weak private(set) var collectionView: UICollectionView? 22 | 23 | /// Initializes `RxCollectionViewDelegateProxy` 24 | /// 25 | /// - parameter collectionView: Parent object for delegate proxy. 26 | public init(collectionView: UICollectionView) { 27 | self.collectionView = collectionView 28 | super.init(scrollView: collectionView) 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxNavigationControllerDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxNavigationControllerDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Diogo on 13/04/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension UINavigationController: HasDelegate { 15 | public typealias Delegate = UINavigationControllerDelegate 16 | } 17 | 18 | /// For more information take a look at `DelegateProxyType`. 19 | open class RxNavigationControllerDelegateProxy 20 | : DelegateProxy 21 | , DelegateProxyType 22 | , UINavigationControllerDelegate { 23 | 24 | /// Typed parent object. 25 | public weak private(set) var navigationController: UINavigationController? 26 | 27 | /// - parameter navigationController: Parent object for delegate proxy. 28 | public init(navigationController: ParentObject) { 29 | self.navigationController = navigationController 30 | super.init(parentObject: navigationController, delegateProxy: RxNavigationControllerDelegateProxy.self) 31 | } 32 | 33 | // Register known implementations 34 | public static func registerKnownImplementations() { 35 | self.register { RxNavigationControllerDelegateProxy(navigationController: $0) } 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxPickerViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Segii Shulga on 5/12/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension UIPickerView: HasDelegate { 15 | public typealias Delegate = UIPickerViewDelegate 16 | } 17 | 18 | open class RxPickerViewDelegateProxy 19 | : DelegateProxy 20 | , DelegateProxyType 21 | , UIPickerViewDelegate { 22 | 23 | /// Typed parent object. 24 | public weak private(set) var pickerView: UIPickerView? 25 | 26 | /// - parameter pickerView: Parent object for delegate proxy. 27 | public init(pickerView: ParentObject) { 28 | self.pickerView = pickerView 29 | super.init(parentObject: pickerView, delegateProxy: RxPickerViewDelegateProxy.self) 30 | } 31 | 32 | // Register known implementationss 33 | public static func registerKnownImplementations() { 34 | self.register { RxPickerViewDelegateProxy(pickerView: $0) } 35 | } 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxSearchBarDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension UISearchBar: HasDelegate { 15 | public typealias Delegate = UISearchBarDelegate 16 | } 17 | 18 | /// For more information take a look at `DelegateProxyType`. 19 | open class RxSearchBarDelegateProxy 20 | : DelegateProxy 21 | , DelegateProxyType 22 | , UISearchBarDelegate { 23 | 24 | /// Typed parent object. 25 | public weak private(set) var searchBar: UISearchBar? 26 | 27 | /// - parameter searchBar: Parent object for delegate proxy. 28 | public init(searchBar: ParentObject) { 29 | self.searchBar = searchBar 30 | super.init(parentObject: searchBar, delegateProxy: RxSearchBarDelegateProxy.self) 31 | } 32 | 33 | // Register known implementations 34 | public static func registerKnownImplementations() { 35 | self.register { RxSearchBarDelegateProxy(searchBar: $0) } 36 | } 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxSearchControllerDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Segii Shulga on 3/17/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension UISearchController: HasDelegate { 15 | public typealias Delegate = UISearchControllerDelegate 16 | } 17 | 18 | /// For more information take a look at `DelegateProxyType`. 19 | @available(iOS 8.0, *) 20 | open class RxSearchControllerDelegateProxy 21 | : DelegateProxy 22 | , DelegateProxyType 23 | , UISearchControllerDelegate { 24 | 25 | /// Typed parent object. 26 | public weak private(set) var searchController: UISearchController? 27 | 28 | /// - parameter searchController: Parent object for delegate proxy. 29 | public init(searchController: UISearchController) { 30 | self.searchController = searchController 31 | super.init(parentObject: searchController, delegateProxy: RxSearchControllerDelegateProxy.self) 32 | } 33 | 34 | // Register known implementations 35 | public static func registerKnownImplementations() { 36 | self.register { RxSearchControllerDelegateProxy(searchController: $0) } 37 | } 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarControllerDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTabBarControllerDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Yusuke Kita on 2016/12/07. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension UITabBarController: HasDelegate { 15 | public typealias Delegate = UITabBarControllerDelegate 16 | } 17 | 18 | /// For more information take a look at `DelegateProxyType`. 19 | open class RxTabBarControllerDelegateProxy 20 | : DelegateProxy 21 | , DelegateProxyType 22 | , UITabBarControllerDelegate { 23 | 24 | /// Typed parent object. 25 | public weak private(set) var tabBar: UITabBarController? 26 | 27 | /// - parameter tabBar: Parent object for delegate proxy. 28 | public init(tabBar: ParentObject) { 29 | self.tabBar = tabBar 30 | super.init(parentObject: tabBar, delegateProxy: RxTabBarControllerDelegateProxy.self) 31 | } 32 | 33 | // Register known implementations 34 | public static func registerKnownImplementations() { 35 | self.register { RxTabBarControllerDelegateProxy(tabBar: $0) } 36 | } 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTabBarDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Jesse Farless on 5/14/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension UITabBar: HasDelegate { 15 | public typealias Delegate = UITabBarDelegate 16 | } 17 | 18 | /// For more information take a look at `DelegateProxyType`. 19 | open class RxTabBarDelegateProxy 20 | : DelegateProxy 21 | , DelegateProxyType 22 | , UITabBarDelegate { 23 | 24 | /// Typed parent object. 25 | public weak private(set) var tabBar: UITabBar? 26 | 27 | /// - parameter tabBar: Parent object for delegate proxy. 28 | public init(tabBar: ParentObject) { 29 | self.tabBar = tabBar 30 | super.init(parentObject: tabBar, delegateProxy: RxTabBarDelegateProxy.self) 31 | } 32 | 33 | // Register known implementations 34 | public static func registerKnownImplementations() { 35 | self.register { RxTabBarDelegateProxy(tabBar: $0) } 36 | } 37 | 38 | /// For more information take a look at `DelegateProxyType`. 39 | open class func currentDelegate(for object: ParentObject) -> UITabBarDelegate? { 40 | return object.delegate 41 | } 42 | 43 | /// For more information take a look at `DelegateProxyType`. 44 | open class func setCurrentDelegate(_ delegate: UITabBarDelegate?, to object: ParentObject) { 45 | object.delegate = delegate 46 | } 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTableViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// For more information take a look at `DelegateProxyType`. 15 | open class RxTableViewDelegateProxy 16 | : RxScrollViewDelegateProxy 17 | , UITableViewDelegate { 18 | 19 | /// Typed parent object. 20 | public weak private(set) var tableView: UITableView? 21 | 22 | /// - parameter tableView: Parent object for delegate proxy. 23 | public init(tableView: UITableView) { 24 | self.tableView = tableView 25 | super.init(scrollView: tableView) 26 | } 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTextStorageDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Segii Shulga on 12/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension NSTextStorage: HasDelegate { 15 | public typealias Delegate = NSTextStorageDelegate 16 | } 17 | 18 | open class RxTextStorageDelegateProxy 19 | : DelegateProxy 20 | , DelegateProxyType 21 | , NSTextStorageDelegate { 22 | 23 | /// Typed parent object. 24 | public weak private(set) var textStorage: NSTextStorage? 25 | 26 | /// - parameter textStorage: Parent object for delegate proxy. 27 | public init(textStorage: NSTextStorage) { 28 | self.textStorage = textStorage 29 | super.init(parentObject: textStorage, delegateProxy: RxTextStorageDelegateProxy.self) 30 | } 31 | 32 | // Register known implementations 33 | public static func registerKnownImplementations() { 34 | self.register { RxTextStorageDelegateProxy(textStorage: $0) } 35 | } 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTextViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Yuta ToKoRo on 7/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | /// For more information take a look at `DelegateProxyType`. 15 | open class RxTextViewDelegateProxy 16 | : RxScrollViewDelegateProxy 17 | , UITextViewDelegate { 18 | 19 | /// Typed parent object. 20 | public weak private(set) var textView: UITextView? 21 | 22 | /// - parameter textview: Parent object for delegate proxy. 23 | public init(textView: UITextView) { 24 | self.textView = textView 25 | super.init(scrollView: textView) 26 | } 27 | 28 | // MARK: delegate methods 29 | 30 | /// For more information take a look at `DelegateProxyType`. 31 | @objc open func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { 32 | /** 33 | We've had some issues with observing text changes. This is here just in case we need the same hack in future and that 34 | we wouldn't need to change the public interface. 35 | */ 36 | let forwardToDelegate = self.forwardToDelegate() as? UITextViewDelegate 37 | return forwardToDelegate?.textView?(textView, 38 | shouldChangeTextIn: range, 39 | replacementText: text) ?? true 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxWebViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxWebViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Andrew Breckenridge on 9/26/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension UIWebView: HasDelegate { 15 | public typealias Delegate = UIWebViewDelegate 16 | } 17 | 18 | open class RxWebViewDelegateProxy 19 | : DelegateProxy 20 | , DelegateProxyType 21 | , UIWebViewDelegate { 22 | 23 | /// Typed parent object. 24 | public weak private(set) var webView: UIWebView? 25 | 26 | /// - parameter webView: Parent object for delegate proxy. 27 | public init(webView: ParentObject) { 28 | self.webView = webView 29 | super.init(parentObject: webView, delegateProxy: RxWebViewDelegateProxy.self) 30 | } 31 | 32 | // Register known implementations 33 | public static func registerKnownImplementations() { 34 | self.register { RxWebViewDelegateProxy(webView: $0) } 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIActivityIndicatorView+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Ivan Persidskiy on 02/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIActivityIndicatorView { 15 | 16 | /// Bindable sink for `startAnimating()`, `stopAnimating()` methods. 17 | public var isAnimating: Binder { 18 | return Binder(self.base) { activityIndicator, active in 19 | if active { 20 | activityIndicator.startAnimating() 21 | } else { 22 | activityIndicator.stopAnimating() 23 | } 24 | } 25 | } 26 | 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertAction+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Andrew Breckenridge on 5/7/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIAlertAction { 15 | 16 | /// Bindable sink for `enabled` property. 17 | public var isEnabled: Binder { 18 | return Binder(self.base) { alertAction, value in 19 | alertAction.isEnabled = value 20 | } 21 | } 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Mads Bøgeskov on 18/01/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIApplication { 15 | 16 | /// Bindable sink for `networkActivityIndicatorVisible`. 17 | public var isNetworkActivityIndicatorVisible: Binder { 18 | return Binder(self.base) { application, active in 19 | application.isNetworkActivityIndicatorVisible = active 20 | } 21 | } 22 | } 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UIButton { 15 | 16 | /// Reactive wrapper for `TouchUpInside` control event. 17 | public var tap: ControlEvent { 18 | return controlEvent(.touchUpInside) 19 | } 20 | } 21 | 22 | #endif 23 | 24 | #if os(tvOS) 25 | 26 | import RxSwift 27 | import UIKit 28 | 29 | extension Reactive where Base: UIButton { 30 | 31 | /// Reactive wrapper for `PrimaryActionTriggered` control event. 32 | public var primaryAction: ControlEvent { 33 | return controlEvent(.primaryActionTriggered) 34 | } 35 | 36 | } 37 | 38 | #endif 39 | 40 | #if os(iOS) || os(tvOS) 41 | 42 | import RxSwift 43 | import UIKit 44 | 45 | extension Reactive where Base: UIButton { 46 | 47 | /// Reactive wrapper for `setTitle(_:for:)` 48 | public func title(for controlState: UIControlState = []) -> Binder { 49 | return Binder(self.base) { (button, title) -> () in 50 | button.setTitle(title, for: controlState) 51 | } 52 | } 53 | 54 | /// Reactive wrapper for `setImage(_:for:)` 55 | public func image(for controlState: UIControlState = []) -> Binder { 56 | return Binder(self.base) { (button, image) -> () in 57 | button.setImage(image, for: controlState) 58 | } 59 | } 60 | 61 | /// Reactive wrapper for `setBackgroundImage(_:for:)` 62 | public func backgroundImage(for controlState: UIControlState = []) -> Binder { 63 | return Binder(self.base) { (button, image) -> () in 64 | button.setBackgroundImage(image, for: controlState) 65 | } 66 | } 67 | 68 | } 69 | #endif 70 | 71 | #if os(iOS) || os(tvOS) 72 | 73 | import RxSwift 74 | import UIKit 75 | 76 | extension Reactive where Base: UIButton { 77 | 78 | /// Reactive wrapper for `setAttributedTitle(_:controlState:)` 79 | public func attributedTitle(for controlState: UIControlState = []) -> Binder { 80 | return Binder(self.base) { (button, attributedTitle) -> () in 81 | button.setAttributedTitle(attributedTitle, for: controlState) 82 | } 83 | } 84 | 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIDatePicker+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Daniel Tartaglia on 5/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UIDatePicker { 15 | /// Reactive wrapper for `date` property. 16 | public var date: ControlProperty { 17 | return value 18 | } 19 | 20 | /// Reactive wrapper for `date` property. 21 | public var value: ControlProperty { 22 | return base.rx.controlPropertyWithDefaultEvents( 23 | getter: { datePicker in 24 | datePicker.date 25 | }, setter: { datePicker, value in 26 | datePicker.date = value 27 | } 28 | ) 29 | } 30 | 31 | /// Reactive wrapper for `countDownDuration` property. 32 | public var countDownDuration: ControlProperty { 33 | return base.rx.controlPropertyWithDefaultEvents( 34 | getter: { datePicker in 35 | datePicker.countDownDuration 36 | }, setter: { datePicker, value in 37 | datePicker.countDownDuration = value 38 | } 39 | ) 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIGestureRecognizer+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIGestureRecognizer+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 10/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | // This should be only used from `MainScheduler` 15 | final class GestureTarget: RxTarget { 16 | typealias Callback = (Recognizer) -> Void 17 | 18 | let selector = #selector(ControlTarget.eventHandler(_:)) 19 | 20 | weak var gestureRecognizer: Recognizer? 21 | var callback: Callback? 22 | 23 | init(_ gestureRecognizer: Recognizer, callback: @escaping Callback) { 24 | self.gestureRecognizer = gestureRecognizer 25 | self.callback = callback 26 | 27 | super.init() 28 | 29 | gestureRecognizer.addTarget(self, action: selector) 30 | 31 | let method = self.method(for: selector) 32 | if method == nil { 33 | fatalError("Can't find method") 34 | } 35 | } 36 | 37 | @objc func eventHandler(_ sender: UIGestureRecognizer) { 38 | if let callback = self.callback, let gestureRecognizer = self.gestureRecognizer { 39 | callback(gestureRecognizer) 40 | } 41 | } 42 | 43 | override func dispose() { 44 | super.dispose() 45 | 46 | self.gestureRecognizer?.removeTarget(self, action: self.selector) 47 | self.callback = nil 48 | } 49 | } 50 | 51 | extension Reactive where Base: UIGestureRecognizer { 52 | 53 | /// Reactive wrapper for gesture recognizer events. 54 | public var event: ControlEvent { 55 | let source: Observable = Observable.create { [weak control = self.base] observer in 56 | MainScheduler.ensureExecutingOnScheduler() 57 | 58 | guard let control = control else { 59 | observer.on(.completed) 60 | return Disposables.create() 61 | } 62 | 63 | let observer = GestureTarget(control) { 64 | control in 65 | observer.on(.next(control)) 66 | } 67 | 68 | return observer 69 | }.takeUntil(deallocated) 70 | 71 | return ControlEvent(events: source) 72 | } 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UIImageView { 15 | 16 | /// Bindable sink for `image` property. 17 | public var image: Binder { 18 | return Binder(base) { imageView, image in 19 | imageView.image = image 20 | } 21 | } 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UILabel { 15 | 16 | /// Bindable sink for `text` property. 17 | public var text: Binder { 18 | return Binder(self.base) { label, text in 19 | label.text = text 20 | } 21 | } 22 | 23 | /// Bindable sink for `attributedText` property. 24 | public var attributedText: Binder { 25 | return Binder(self.base) { label, text in 26 | label.attributedText = text 27 | } 28 | } 29 | 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UINavigationController+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Diogo on 13/04/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UINavigationController { 15 | public typealias ShowEvent = (viewController: UIViewController, animated: Bool) 16 | 17 | /// Reactive wrapper for `delegate`. 18 | /// 19 | /// For more information take a look at `DelegateProxyType` protocol documentation. 20 | public var delegate: DelegateProxy { 21 | return RxNavigationControllerDelegateProxy.proxy(for: base) 22 | } 23 | 24 | /// Reactive wrapper for delegate method `navigationController(:willShow:animated:)`. 25 | public var willShow: ControlEvent { 26 | let source: Observable = delegate 27 | .methodInvoked(#selector(UINavigationControllerDelegate.navigationController(_:willShow:animated:))) 28 | .map { arg in 29 | let viewController = try castOrThrow(UIViewController.self, arg[1]) 30 | let animated = try castOrThrow(Bool.self, arg[2]) 31 | return (viewController, animated) 32 | } 33 | return ControlEvent(events: source) 34 | } 35 | 36 | /// Reactive wrapper for delegate method `navigationController(:didShow:animated:)`. 37 | public var didShow: ControlEvent { 38 | let source: Observable = delegate 39 | .methodInvoked(#selector(UINavigationControllerDelegate.navigationController(_:didShow:animated:))) 40 | .map { arg in 41 | let viewController = try castOrThrow(UIViewController.self, arg[1]) 42 | let animated = try castOrThrow(Bool.self, arg[2]) 43 | return (viewController, animated) 44 | } 45 | return ControlEvent(events: source) 46 | } 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationItem+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by kumapo on 2016/05/09. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UINavigationItem { 15 | 16 | /// Bindable sink for `title` property. 17 | public var title: Binder { 18 | return Binder(self.base) { navigationItem, text in 19 | navigationItem.title = text 20 | } 21 | } 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIPageControl+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Francesco Puntillo on 14/04/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UIPageControl { 15 | 16 | /// Bindable sink for `currentPage` property. 17 | public var currentPage: Binder { 18 | return Binder(self.base) { controller, page in 19 | controller.currentPage = page 20 | } 21 | } 22 | 23 | /// Bindable sink for `numberOfPages` property. 24 | public var numberOfPages: Binder { 25 | return Binder(self.base) { controller, page in 26 | controller.numberOfPages = page 27 | } 28 | } 29 | 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIProgressView+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Samuel Bae on 2/27/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UIProgressView { 15 | 16 | /// Bindable sink for `progress` property 17 | public var progress: Binder { 18 | return Binder(self.base) { progressView, progress in 19 | progressView.progress = progress 20 | } 21 | } 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIRefreshControl+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Yosuke Ishikawa on 1/31/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIRefreshControl { 15 | /// Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. 16 | public var isRefreshing: Binder { 17 | return Binder(self.base) { refreshControl, refresh in 18 | if refresh { 19 | refreshControl.beginRefreshing() 20 | } else { 21 | refreshControl.endRefreshing() 22 | } 23 | } 24 | } 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISearchController+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Segii Shulga on 3/17/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | @available(iOS 8.0, *) 15 | extension Reactive where Base: UISearchController { 16 | /// Reactive wrapper for `delegate`. 17 | /// For more information take a look at `DelegateProxyType` protocol documentation. 18 | public var delegate: DelegateProxy { 19 | return RxSearchControllerDelegateProxy.proxy(for: base) 20 | } 21 | 22 | /// Reactive wrapper for `delegate` message. 23 | public var didDismiss: Observable { 24 | return delegate 25 | .methodInvoked( #selector(UISearchControllerDelegate.didDismissSearchController(_:))) 26 | .map {_ in} 27 | } 28 | 29 | /// Reactive wrapper for `delegate` message. 30 | public var didPresent: Observable { 31 | return delegate 32 | .methodInvoked(#selector(UISearchControllerDelegate.didPresentSearchController(_:))) 33 | .map {_ in} 34 | } 35 | 36 | /// Reactive wrapper for `delegate` message. 37 | public var present: Observable { 38 | return delegate 39 | .methodInvoked( #selector(UISearchControllerDelegate.presentSearchController(_:))) 40 | .map {_ in} 41 | } 42 | 43 | /// Reactive wrapper for `delegate` message. 44 | public var willDismiss: Observable { 45 | return delegate 46 | .methodInvoked(#selector(UISearchControllerDelegate.willDismissSearchController(_:))) 47 | .map {_ in} 48 | } 49 | 50 | /// Reactive wrapper for `delegate` message. 51 | public var willPresent: Observable { 52 | return delegate 53 | .methodInvoked( #selector(UISearchControllerDelegate.willPresentSearchController(_:))) 54 | .map {_ in} 55 | } 56 | 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UISegmentedControl+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISegmentedControl+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 8/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UISegmentedControl { 15 | /// Reactive wrapper for `selectedSegmentIndex` property. 16 | public var selectedSegmentIndex: ControlProperty { 17 | return value 18 | } 19 | 20 | /// Reactive wrapper for `selectedSegmentIndex` property. 21 | public var value: ControlProperty { 22 | return base.rx.controlPropertyWithDefaultEvents( 23 | getter: { segmentedControl in 24 | segmentedControl.selectedSegmentIndex 25 | }, setter: { segmentedControl, value in 26 | segmentedControl.selectedSegmentIndex = value 27 | } 28 | ) 29 | } 30 | 31 | /// Reactive wrapper for `setEnabled(_:forSegmentAt:)` 32 | public func enabled(forSegmentAt segmentAt: Int) -> Binder { 33 | return Binder(self.base) { (segmentedControl, segmentEnabled) -> () in 34 | segmentedControl.setEnabled(segmentEnabled, forSegmentAt: segmentAt) 35 | } 36 | } 37 | 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISlider+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Alexander van der Werff on 28/05/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UISlider { 15 | 16 | /// Reactive wrapper for `value` property. 17 | public var value: ControlProperty { 18 | return base.rx.controlPropertyWithDefaultEvents( 19 | getter: { slider in 20 | slider.value 21 | }, setter: { slider, value in 22 | slider.value = value 23 | } 24 | ) 25 | } 26 | 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIStepper+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Yuta ToKoRo on 9/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIStepper { 15 | 16 | /// Reactive wrapper for `value` property. 17 | public var value: ControlProperty { 18 | return base.rx.controlPropertyWithDefaultEvents( 19 | getter: { stepper in 20 | stepper.value 21 | }, setter: { stepper, value in 22 | stepper.value = value 23 | } 24 | ) 25 | } 26 | 27 | /// Reactive wrapper for `stepValue` property. 28 | public var stepValue: Binder { 29 | return Binder(self.base) { stepper, value in 30 | stepper.stepValue = value 31 | } 32 | } 33 | 34 | } 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISwitch+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 8/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UISwitch { 15 | 16 | /// Reactive wrapper for `isOn` property. 17 | public var isOn: ControlProperty { 18 | return value 19 | } 20 | 21 | /** 22 | Reactive wrapper for `isOn` property. 23 | 24 | **⚠️ Versions prior to iOS 10.2 were leaking `UISwitch`s, so on those versions 25 | underlying observable sequence won't complete when nothing holds a strong reference 26 | to UISwitch.⚠️** 27 | */ 28 | public var value: ControlProperty { 29 | return base.rx.controlPropertyWithDefaultEvents( 30 | getter: { uiSwitch in 31 | uiSwitch.isOn 32 | }, setter: { uiSwitch, value in 33 | uiSwitch.isOn = value 34 | } 35 | ) 36 | } 37 | 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITabBarItem+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Mateusz Derks on 04/03/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UITabBarItem { 15 | 16 | /// Bindable sink for `badgeValue` property. 17 | public var badgeValue: Binder { 18 | return Binder(self.base) { tabBarItem, badgeValue in 19 | tabBarItem.badgeValue = badgeValue 20 | } 21 | } 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import RxSwift 12 | import UIKit 13 | 14 | extension Reactive where Base: UITextField { 15 | /// Reactive wrapper for `text` property. 16 | public var text: ControlProperty { 17 | return value 18 | } 19 | 20 | /// Reactive wrapper for `text` property. 21 | public var value: ControlProperty { 22 | return base.rx.controlPropertyWithDefaultEvents( 23 | getter: { textField in 24 | textField.text 25 | }, 26 | setter: { textField, value in 27 | // This check is important because setting text value always clears control state 28 | // including marked text selection which is imporant for proper input 29 | // when IME input method is used. 30 | if textField.text != value { 31 | textField.text = value 32 | } 33 | } 34 | ) 35 | } 36 | 37 | /// Bindable sink for `attributedText` property. 38 | public var attributedText: ControlProperty { 39 | return base.rx.controlPropertyWithDefaultEvents( 40 | getter: { textField in 41 | textField.attributedText 42 | }, 43 | setter: { textField, value in 44 | // This check is important because setting text value always clears control state 45 | // including marked text selection which is imporant for proper input 46 | // when IME input method is used. 47 | if textField.attributedText != value { 48 | textField.attributedText = value 49 | } 50 | } 51 | ) 52 | } 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIView { 15 | /// Bindable sink for `hidden` property. 16 | public var isHidden: Binder { 17 | return Binder(self.base) { view, hidden in 18 | view.isHidden = hidden 19 | } 20 | } 21 | 22 | /// Bindable sink for `alpha` property. 23 | public var alpha: Binder { 24 | return Binder(self.base) { view, alpha in 25 | view.alpha = alpha 26 | } 27 | } 28 | 29 | /// Bindable sink for `isUserInteractionEnabled` property. 30 | public var isUserInteractionEnabled: Binder { 31 | return Binder(self.base) { view, userInteractionEnabled in 32 | view.isUserInteractionEnabled = userInteractionEnabled 33 | } 34 | } 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Kyle Fuller on 27/05/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIViewController { 15 | 16 | /// Bindable sink for `title`. 17 | public var title: Binder { 18 | return Binder(self.base) { viewController, title in 19 | viewController.title = title 20 | } 21 | } 22 | 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /Example/Pods/RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIWebView+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Andrew Breckenridge on 8/30/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | import RxSwift 13 | 14 | extension Reactive where Base: UIWebView { 15 | 16 | /// Reactive wrapper for `delegate`. 17 | /// For more information take a look at `DelegateProxyType` protocol documentation. 18 | public var delegate: DelegateProxy { 19 | return RxWebViewDelegateProxy.proxy(for: base) 20 | } 21 | 22 | /// Reactive wrapper for `delegate` message. 23 | public var didStartLoad: Observable { 24 | return delegate 25 | .methodInvoked(#selector(UIWebViewDelegate.webViewDidStartLoad(_:))) 26 | .map {_ in} 27 | } 28 | 29 | /// Reactive wrapper for `delegate` message. 30 | public var didFinishLoad: Observable { 31 | return delegate 32 | .methodInvoked(#selector(UIWebViewDelegate.webViewDidFinishLoad(_:))) 33 | .map {_ in} 34 | } 35 | 36 | /// Reactive wrapper for `delegate` message. 37 | public var didFailLoad: Observable { 38 | return delegate 39 | .methodInvoked(#selector(UIWebViewDelegate.webView(_:didFailLoadWithError:))) 40 | .map { a in 41 | return try castOrThrow(Error.self, a[1]) 42 | } 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/LICENSE.md: -------------------------------------------------------------------------------- 1 | **The MIT License** 2 | **Copyright © 2015 Krunoslav Zaher** 3 | **All rights reserved.** 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteSequence.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Sequence that repeats `repeatedValue` infinite number of times. 10 | struct InfiniteSequence : Sequence { 11 | typealias Element = E 12 | typealias Iterator = AnyIterator 13 | 14 | private let _repeatedValue: E 15 | 16 | init(repeatedValue: E) { 17 | _repeatedValue = repeatedValue 18 | } 19 | 20 | func makeIterator() -> Iterator { 21 | let repeatedValue = _repeatedValue 22 | return AnyIterator { 23 | return repeatedValue 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/DeprecationWarner.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DeprecationWarner.swift 3 | // Platform 4 | // 5 | // Created by Shai Mishali on 1/9/18. 6 | // Copyright © 2018 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if DEBUG 12 | class DeprecationWarner { 13 | private static var warned = Set() 14 | private static var _lock = NSRecursiveLock() 15 | 16 | static func warnIfNeeded(_ kind: Kind) { 17 | _lock.lock(); defer { _lock.unlock() } 18 | guard !warned.contains(kind) else { return } 19 | 20 | warned.insert(kind) 21 | print("ℹ️ [DEPRECATED] \(kind.message)") 22 | } 23 | } 24 | 25 | extension DeprecationWarner { 26 | enum Kind { 27 | case variable 28 | case globalTestFunctionNext 29 | case globalTestFunctionError 30 | case globalTestFunctionCompleted 31 | 32 | var message: String { 33 | switch self { 34 | case .variable: return "`Variable` is planned for future deprecation. Please consider `BehaviorRelay` as a replacement. Read more at: https://git.io/vNqvx" 35 | case .globalTestFunctionNext: return "The `next()` global function is planned for future deprecation. Please use `Recorded.next()` instead." 36 | case .globalTestFunctionError: return "The `error()` global function is planned for future deprecation. Please use `Recorded.error()` instead." 37 | case .globalTestFunctionCompleted: return "The `completed()` global function is planned for future deprecation. Please use `Recorded.completed()` instead." 38 | } 39 | } 40 | } 41 | } 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DispatchQueue+Extensions.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 10/22/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Dispatch 10 | 11 | extension DispatchQueue { 12 | private static var token: DispatchSpecificKey<()> = { 13 | let key = DispatchSpecificKey<()>() 14 | DispatchQueue.main.setSpecific(key: key, value: ()) 15 | return key 16 | }() 17 | 18 | static var isMain: Bool { 19 | return DispatchQueue.getSpecific(key: token) != nil 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/Platform.Darwin.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Platform.Darwin.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) 10 | 11 | import Darwin 12 | import class Foundation.Thread 13 | import func Foundation.OSAtomicCompareAndSwap32Barrier 14 | import func Foundation.OSAtomicIncrement32Barrier 15 | import func Foundation.OSAtomicDecrement32Barrier 16 | import protocol Foundation.NSCopying 17 | 18 | typealias AtomicInt = Int32 19 | 20 | fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer) -> UnsafeMutablePointer { 21 | let raw = UnsafeMutableRawPointer(pointer) 22 | return raw.assumingMemoryBound(to: UInt32.self) 23 | } 24 | 25 | let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier 26 | let AtomicIncrement = OSAtomicIncrement32Barrier 27 | let AtomicDecrement = OSAtomicDecrement32Barrier 28 | func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Int32 { 29 | return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue)) 30 | } 31 | func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Bool { 32 | // just used to create a barrier 33 | OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue)) 34 | return (theValue.pointee & Int32(mask)) != 0 35 | } 36 | 37 | extension Thread { 38 | 39 | static func setThreadLocalStorageValue(_ value: T?, forKey key: NSCopying 40 | ) { 41 | let currentThread = Thread.current 42 | let threadDictionary = currentThread.threadDictionary 43 | 44 | if let newValue = value { 45 | threadDictionary[key] = newValue 46 | } 47 | else { 48 | threadDictionary[key] = nil 49 | } 50 | 51 | } 52 | static func getThreadLocalStorageValueForKey(_ key: NSCopying) -> T? { 53 | let currentThread = Thread.current 54 | let threadDictionary = currentThread.threadDictionary 55 | 56 | return threadDictionary[key] as? T 57 | } 58 | } 59 | 60 | extension AtomicInt { 61 | func valueSnapshot() -> Int32 { 62 | return self 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/RecursiveLock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RecursiveLock.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/18/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NSRecursiveLock 10 | 11 | #if TRACE_RESOURCES 12 | class RecursiveLock: NSRecursiveLock { 13 | override init() { 14 | _ = Resources.incrementTotal() 15 | super.init() 16 | } 17 | 18 | override func lock() { 19 | super.lock() 20 | _ = Resources.incrementTotal() 21 | } 22 | 23 | override func unlock() { 24 | super.unlock() 25 | _ = Resources.decrementTotal() 26 | } 27 | 28 | deinit { 29 | _ = Resources.decrementTotal() 30 | } 31 | } 32 | #else 33 | typealias RecursiveLock = NSRecursiveLock 34 | #endif 35 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Cancelable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cancelable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents disposable resource with state tracking. 10 | public protocol Cancelable : Disposable { 11 | /// Was resource disposed. 12 | var isDisposed: Bool { get } 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/Lock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Lock.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol Lock { 10 | func lock() 11 | func unlock() 12 | } 13 | 14 | // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html 15 | typealias SpinLock = RecursiveLock 16 | 17 | extension RecursiveLock : Lock { 18 | @inline(__always) 19 | final func performLocked(_ action: () -> Void) { 20 | lock(); defer { unlock() } 21 | action() 22 | } 23 | 24 | @inline(__always) 25 | final func calculateLocked(_ action: () -> T) -> T { 26 | lock(); defer { unlock() } 27 | return action() 28 | } 29 | 30 | @inline(__always) 31 | final func calculateLockedOrFail(_ action: () throws -> T) throws -> T { 32 | lock(); defer { unlock() } 33 | let result = try action() 34 | return result 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LockOwnerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol LockOwnerType : class, Lock { 10 | var _lock: RecursiveLock { get } 11 | } 12 | 13 | extension LockOwnerType { 14 | func lock() { 15 | _lock.lock() 16 | } 17 | 18 | func unlock() { 19 | _lock.unlock() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedDisposeType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedDisposeType : class, Disposable, Lock { 10 | func _synchronized_dispose() 11 | } 12 | 13 | extension SynchronizedDisposeType { 14 | func synchronizedDispose() { 15 | lock(); defer { unlock() } 16 | _synchronized_dispose() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedOnType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedOnType : class, ObserverType, Lock { 10 | func _synchronized_on(_ event: Event) 11 | } 12 | 13 | extension SynchronizedOnType { 14 | func synchronizedOn(_ event: Event) { 15 | lock(); defer { unlock() } 16 | _synchronized_on(event) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedUnsubscribeType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedUnsubscribeType : class { 10 | associatedtype DisposeKey 11 | 12 | func synchronizedUnsubscribe(_ disposeKey: DisposeKey) 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ConnectableObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectableObservableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence. 11 | */ 12 | public protocol ConnectableObservableType : ObservableType { 13 | /** 14 | Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established. 15 | 16 | - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. 17 | */ 18 | func connect() -> Disposable 19 | } 20 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Respresents a disposable resource. 10 | public protocol Disposable { 11 | /// Dispose resource. 12 | func dispose() 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an Action-based disposable. 10 | /// 11 | /// When dispose method is called, disposal action will be dereferenced. 12 | fileprivate final class AnonymousDisposable : DisposeBase, Cancelable { 13 | public typealias DisposeAction = () -> Void 14 | 15 | private var _isDisposed: AtomicInt = 0 16 | private var _disposeAction: DisposeAction? 17 | 18 | /// - returns: Was resource disposed. 19 | public var isDisposed: Bool { 20 | return _isDisposed == 1 21 | } 22 | 23 | /// Constructs a new disposable with the given action used for disposal. 24 | /// 25 | /// - parameter disposeAction: Disposal action which will be run upon calling `dispose`. 26 | fileprivate init(_ disposeAction: @escaping DisposeAction) { 27 | _disposeAction = disposeAction 28 | super.init() 29 | } 30 | 31 | // Non-deprecated version of the constructor, used by `Disposables.create(with:)` 32 | fileprivate init(disposeAction: @escaping DisposeAction) { 33 | _disposeAction = disposeAction 34 | super.init() 35 | } 36 | 37 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet. 38 | /// 39 | /// After invoking disposal action, disposal action will be dereferenced. 40 | fileprivate func dispose() { 41 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 42 | assert(_isDisposed == 1) 43 | 44 | if let action = _disposeAction { 45 | _disposeAction = nil 46 | action() 47 | } 48 | } 49 | } 50 | } 51 | 52 | extension Disposables { 53 | 54 | /// Constructs a new disposable with the given action used for disposal. 55 | /// 56 | /// - parameter dispose: Disposal action which will be run upon calling `dispose`. 57 | public static func create(with dispose: @escaping () -> ()) -> Cancelable { 58 | return AnonymousDisposable(disposeAction: dispose) 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents two disposable resources that are disposed together. 10 | private final class BinaryDisposable : DisposeBase, Cancelable { 11 | 12 | private var _isDisposed: AtomicInt = 0 13 | 14 | // state 15 | private var _disposable1: Disposable? 16 | private var _disposable2: Disposable? 17 | 18 | /// - returns: Was resource disposed. 19 | var isDisposed: Bool { 20 | return _isDisposed > 0 21 | } 22 | 23 | /// Constructs new binary disposable from two disposables. 24 | /// 25 | /// - parameter disposable1: First disposable 26 | /// - parameter disposable2: Second disposable 27 | init(_ disposable1: Disposable, _ disposable2: Disposable) { 28 | _disposable1 = disposable1 29 | _disposable2 = disposable2 30 | super.init() 31 | } 32 | 33 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet. 34 | /// 35 | /// After invoking disposal action, disposal action will be dereferenced. 36 | func dispose() { 37 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 38 | _disposable1?.dispose() 39 | _disposable2?.dispose() 40 | _disposable1 = nil 41 | _disposable2 = nil 42 | } 43 | } 44 | } 45 | 46 | extension Disposables { 47 | 48 | /// Creates a disposable with the given disposables. 49 | public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Cancelable { 50 | return BinaryDisposable(disposable1, disposable2) 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BooleanDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 10/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a disposable resource that can be checked for disposal status. 10 | public final class BooleanDisposable : Cancelable { 11 | 12 | internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true) 13 | private var _isDisposed = false 14 | 15 | /// Initializes a new instance of the `BooleanDisposable` class 16 | public init() { 17 | } 18 | 19 | /// Initializes a new instance of the `BooleanDisposable` class with given value 20 | public init(isDisposed: Bool) { 21 | self._isDisposed = isDisposed 22 | } 23 | 24 | /// - returns: Was resource disposed. 25 | public var isDisposed: Bool { 26 | return _isDisposed 27 | } 28 | 29 | /// Sets the status to disposed, which can be observer through the `isDisposed` property. 30 | public func dispose() { 31 | _isDisposed = true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/Disposables.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposables.swift 3 | // RxSwift 4 | // 5 | // Created by Mohsen Ramezanpoor on 01/08/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// A collection of utility methods for common disposable operations. 10 | public struct Disposables { 11 | private init() {} 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBag.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension Disposable { 10 | /// Adds `self` to `bag` 11 | /// 12 | /// - parameter bag: `DisposeBag` to add `self` to. 13 | public func disposed(by bag: DisposeBag) { 14 | bag.insert(self) 15 | } 16 | } 17 | 18 | /** 19 | Thread safe bag that disposes added disposables on `deinit`. 20 | 21 | This returns ARC (RAII) like resource management to `RxSwift`. 22 | 23 | In case contained disposables need to be disposed, just put a different dispose bag 24 | or create a new one in its place. 25 | 26 | self.existingDisposeBag = DisposeBag() 27 | 28 | In case explicit disposal is necessary, there is also `CompositeDisposable`. 29 | */ 30 | public final class DisposeBag: DisposeBase { 31 | 32 | private var _lock = SpinLock() 33 | 34 | // state 35 | private var _disposables = [Disposable]() 36 | private var _isDisposed = false 37 | 38 | /// Constructs new empty dispose bag. 39 | public override init() { 40 | super.init() 41 | } 42 | 43 | /// Adds `disposable` to be disposed when dispose bag is being deinited. 44 | /// 45 | /// - parameter disposable: Disposable to add. 46 | public func insert(_ disposable: Disposable) { 47 | _insert(disposable)?.dispose() 48 | } 49 | 50 | private func _insert(_ disposable: Disposable) -> Disposable? { 51 | _lock.lock(); defer { _lock.unlock() } 52 | if _isDisposed { 53 | return disposable 54 | } 55 | 56 | _disposables.append(disposable) 57 | 58 | return nil 59 | } 60 | 61 | /// This is internal on purpose, take a look at `CompositeDisposable` instead. 62 | private func dispose() { 63 | let oldDisposables = _dispose() 64 | 65 | for disposable in oldDisposables { 66 | disposable.dispose() 67 | } 68 | } 69 | 70 | private func _dispose() -> [Disposable] { 71 | _lock.lock(); defer { _lock.unlock() } 72 | 73 | let disposables = _disposables 74 | 75 | _disposables.removeAll(keepingCapacity: false) 76 | _isDisposed = true 77 | 78 | return disposables 79 | } 80 | 81 | deinit { 82 | dispose() 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBase.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Base class for all disposables. 10 | public class DisposeBase { 11 | init() { 12 | #if TRACE_RESOURCES 13 | let _ = Resources.incrementTotal() 14 | #endif 15 | } 16 | 17 | deinit { 18 | #if TRACE_RESOURCES 19 | let _ = Resources.decrementTotal() 20 | #endif 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NopDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a disposable that does nothing on disposal. 10 | /// 11 | /// Nop = No Operation 12 | fileprivate struct NopDisposable : Disposable { 13 | 14 | fileprivate static let noOp: Disposable = NopDisposable() 15 | 16 | fileprivate init() { 17 | 18 | } 19 | 20 | /// Does nothing. 21 | public func dispose() { 22 | } 23 | } 24 | 25 | extension Disposables { 26 | /** 27 | Creates a disposable that does nothing on disposal. 28 | */ 29 | static public func create() -> Disposable { 30 | return NopDisposable.noOp 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in 10 | sd.disposeInner() 11 | return Disposables.create() 12 | } 13 | 14 | /// Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler. 15 | public final class ScheduledDisposable : Cancelable { 16 | public let scheduler: ImmediateSchedulerType 17 | 18 | private var _isDisposed: AtomicInt = 0 19 | 20 | // state 21 | private var _disposable: Disposable? 22 | 23 | /// - returns: Was resource disposed. 24 | public var isDisposed: Bool { 25 | return _isDisposed == 1 26 | } 27 | 28 | /** 29 | Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`. 30 | 31 | - parameter scheduler: Scheduler where the disposable resource will be disposed on. 32 | - parameter disposable: Disposable resource to dispose on the given scheduler. 33 | */ 34 | public init(scheduler: ImmediateSchedulerType, disposable: Disposable) { 35 | self.scheduler = scheduler 36 | _disposable = disposable 37 | } 38 | 39 | /// Disposes the wrapped disposable on the provided scheduler. 40 | public func dispose() { 41 | let _ = scheduler.schedule(self, action: disposeScheduledDisposable) 42 | } 43 | 44 | func disposeInner() { 45 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 46 | _disposable!.dispose() 47 | _disposable = nil 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscriptionDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct SubscriptionDisposable : Disposable { 10 | private let _key: T.DisposeKey 11 | private weak var _owner: T? 12 | 13 | init(owner: T, key: T.DisposeKey) { 14 | _owner = owner 15 | _key = key 16 | } 17 | 18 | func dispose() { 19 | _owner?.synchronizedUnsubscribe(_key) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | let RxErrorDomain = "RxErrorDomain" 10 | let RxCompositeFailures = "RxCompositeFailures" 11 | 12 | /// Generic Rx error codes. 13 | public enum RxError 14 | : Swift.Error 15 | , CustomDebugStringConvertible { 16 | /// Unknown error occurred. 17 | case unknown 18 | /// Performing an action on disposed object. 19 | case disposed(object: AnyObject) 20 | /// Aritmetic overflow error. 21 | case overflow 22 | /// Argument out of range error. 23 | case argumentOutOfRange 24 | /// Sequence doesn't contain any elements. 25 | case noElements 26 | /// Sequence contains more than one element. 27 | case moreThanOneElement 28 | /// Timeout error. 29 | case timeout 30 | } 31 | 32 | extension RxError { 33 | /// A textual representation of `self`, suitable for debugging. 34 | public var debugDescription: String { 35 | switch self { 36 | case .unknown: 37 | return "Unknown error occurred." 38 | case .disposed(let object): 39 | return "Object `\(object)` was already disposed." 40 | case .overflow: 41 | return "Arithmetic overflow occurred." 42 | case .argumentOutOfRange: 43 | return "Argument out of range." 44 | case .noElements: 45 | return "Sequence doesn't contain any elements." 46 | case .moreThanOneElement: 47 | return "Sequence contains more than one element." 48 | case .timeout: 49 | return "Sequence timeout." 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bag+Rx.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/19/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | 10 | // MARK: forEach 11 | 12 | @inline(__always) 13 | func dispatch(_ bag: Bag<(Event) -> ()>, _ event: Event) { 14 | if bag._onlyFastPath { 15 | bag._value0?(event) 16 | return 17 | } 18 | 19 | let value0 = bag._value0 20 | let dictionary = bag._dictionary 21 | 22 | if let value0 = value0 { 23 | value0(event) 24 | } 25 | 26 | let pairs = bag._pairs 27 | for i in 0 ..< pairs.count { 28 | pairs[i].value(event) 29 | } 30 | 31 | if let dictionary = dictionary { 32 | for element in dictionary.values { 33 | element(event) 34 | } 35 | } 36 | } 37 | 38 | /// Dispatches `dispose` to all disposables contained inside bag. 39 | func disposeAll(in bag: Bag) { 40 | if bag._onlyFastPath { 41 | bag._value0?.dispose() 42 | return 43 | } 44 | 45 | let value0 = bag._value0 46 | let dictionary = bag._dictionary 47 | 48 | if let value0 = value0 { 49 | value0.dispose() 50 | } 51 | 52 | let pairs = bag._pairs 53 | for i in 0 ..< pairs.count { 54 | pairs[i].value.dispose() 55 | } 56 | 57 | if let dictionary = dictionary { 58 | for element in dictionary.values { 59 | element.dispose() 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+Rx.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension String { 10 | /// This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)` 11 | func lastIndexOf(_ character: Character) -> Index? { 12 | var index = endIndex 13 | while index > startIndex { 14 | index = self.index(before: index) 15 | if self[index] == character { 16 | return index 17 | } 18 | } 19 | 20 | return nil 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/GroupedObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GroupedObservable.swift 3 | // RxSwift 4 | // 5 | // Created by Tomi Koskinen on 01/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an observable sequence of elements that have a common key. 10 | public struct GroupedObservable : ObservableType { 11 | public typealias E = Element 12 | 13 | /// Gets the common key. 14 | public let key: Key 15 | 16 | private let source: Observable 17 | 18 | /// Initializes grouped observable sequence with key and source observable sequence. 19 | /// 20 | /// - parameter key: Grouped observable sequence key 21 | /// - parameter source: Observable sequence that represents sequence of elements for the key 22 | /// - returns: Grouped observable sequence of elements for the specific key 23 | public init(key: Key, source: Observable) { 24 | self.key = key 25 | self.source = source 26 | } 27 | 28 | /// Subscribes `observer` to receive events for this sequence. 29 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 30 | return self.source.subscribe(observer) 31 | } 32 | 33 | /// Converts `self` to `Observable` sequence. 34 | public func asObservable() -> Observable { 35 | return source 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImmediateSchedulerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an object that immediately schedules units of work. 10 | public protocol ImmediateSchedulerType { 11 | /** 12 | Schedules an action to be executed immediately. 13 | 14 | - parameter state: State passed to the action to be executed. 15 | - parameter action: Action to be executed. 16 | - returns: The disposable object used to cancel the scheduled action (best effort). 17 | */ 18 | func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable 19 | } 20 | 21 | extension ImmediateSchedulerType { 22 | /** 23 | Schedules an action to be executed recursively. 24 | 25 | - parameter state: State passed to the action to be executed. 26 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. 27 | - returns: The disposable object used to cancel the scheduled action (best effort). 28 | */ 29 | public func scheduleRecursive(_ state: State, action: @escaping (_ state: State, _ recurse: (State) -> ()) -> ()) -> Disposable { 30 | let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self) 31 | 32 | recursiveScheduler.schedule(state) 33 | 34 | return Disposables.create(with: recursiveScheduler.dispose) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// A type-erased `ObservableType`. 10 | /// 11 | /// It represents a push style sequence. 12 | public class Observable : ObservableType { 13 | /// Type of elements in sequence. 14 | public typealias E = Element 15 | 16 | init() { 17 | #if TRACE_RESOURCES 18 | let _ = Resources.incrementTotal() 19 | #endif 20 | } 21 | 22 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 23 | rxAbstractMethod() 24 | } 25 | 26 | public func asObservable() -> Observable { 27 | return self 28 | } 29 | 30 | deinit { 31 | #if TRACE_RESOURCES 32 | let _ = Resources.decrementTotal() 33 | #endif 34 | } 35 | 36 | // this is kind of ugly I know :( 37 | // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯ 38 | 39 | /// Optimizations for map operator 40 | internal func composeMap(_ transform: @escaping (Element) throws -> R) -> Observable { 41 | return _map(source: self, transform: transform) 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Type that can be converted to observable sequence (`Observable`). 10 | public protocol ObservableConvertibleType { 11 | /// Type of elements in sequence. 12 | associatedtype E 13 | 14 | /// Converts `self` to `Observable` sequence. 15 | /// 16 | /// - returns: Observable sequence that represents `self`. 17 | func asObservable() -> Observable 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a push style sequence. 10 | public protocol ObservableType : ObservableConvertibleType { 11 | /** 12 | Subscribes `observer` to receive events for this sequence. 13 | 14 | ### Grammar 15 | 16 | **Next\* (Error | Completed)?** 17 | 18 | * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` 19 | * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements 20 | 21 | It is possible that events are sent from different threads, but no two events can be sent concurrently to 22 | `observer`. 23 | 24 | ### Resource Management 25 | 26 | When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements 27 | will be freed. 28 | 29 | To cancel production of sequence elements and free resources immediately, call `dispose` on returned 30 | subscription. 31 | 32 | - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources. 33 | */ 34 | func subscribe(_ observer: O) -> Disposable where O.E == E 35 | } 36 | 37 | extension ObservableType { 38 | 39 | /// Default implementation of converting `ObservableType` to `Observable`. 40 | public func asObservable() -> Observable { 41 | // temporary workaround 42 | //return Observable.create(subscribe: self.subscribe) 43 | return Observable.create { o in 44 | return self.subscribe(o) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AddRef.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddRef.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 30/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | final class AddRefSink : Sink, ObserverType { 10 | typealias Element = O.E 11 | 12 | override init(observer: O, cancel: Cancelable) { 13 | super.init(observer: observer, cancel: cancel) 14 | } 15 | 16 | func on(_ event: Event) { 17 | switch event { 18 | case .next(_): 19 | forwardOn(event) 20 | case .completed, .error(_): 21 | forwardOn(event) 22 | dispose() 23 | } 24 | } 25 | } 26 | 27 | final class AddRef : Producer { 28 | typealias EventHandler = (Event) throws -> Void 29 | 30 | private let _source: Observable 31 | private let _refCount: RefCountDisposable 32 | 33 | init(source: Observable, refCount: RefCountDisposable) { 34 | _source = source 35 | _refCount = refCount 36 | } 37 | 38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 39 | let releaseDisposable = _refCount.retain() 40 | let sink = AddRefSink(observer: observer, cancel: cancel) 41 | let subscription = Disposables.create(releaseDisposable, _source.subscribe(sink)) 42 | 43 | return (sink: sink, subscription: subscription) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsMaybe.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class AsMaybeSink : Sink, ObserverType { 10 | typealias ElementType = O.E 11 | typealias E = ElementType 12 | 13 | private var _element: Event? = nil 14 | 15 | func on(_ event: Event) { 16 | switch event { 17 | case .next: 18 | if _element != nil { 19 | forwardOn(.error(RxError.moreThanOneElement)) 20 | dispose() 21 | } 22 | 23 | _element = event 24 | case .error: 25 | forwardOn(event) 26 | dispose() 27 | case .completed: 28 | if let element = _element { 29 | forwardOn(element) 30 | } 31 | forwardOn(.completed) 32 | dispose() 33 | } 34 | } 35 | } 36 | 37 | final class AsMaybe: Producer { 38 | fileprivate let _source: Observable 39 | 40 | init(source: Observable) { 41 | _source = source 42 | } 43 | 44 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 45 | let sink = AsMaybeSink(observer: observer, cancel: cancel) 46 | let subscription = _source.subscribe(sink) 47 | return (sink: sink, subscription: subscription) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AsSingle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsSingle.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class AsSingleSink : Sink, ObserverType { 10 | typealias ElementType = O.E 11 | typealias E = ElementType 12 | 13 | private var _element: Event? = nil 14 | 15 | func on(_ event: Event) { 16 | switch event { 17 | case .next: 18 | if _element != nil { 19 | forwardOn(.error(RxError.moreThanOneElement)) 20 | dispose() 21 | } 22 | 23 | _element = event 24 | case .error: 25 | forwardOn(event) 26 | dispose() 27 | case .completed: 28 | if let element = _element { 29 | forwardOn(element) 30 | forwardOn(.completed) 31 | } 32 | else { 33 | forwardOn(.error(RxError.noElements)) 34 | } 35 | dispose() 36 | } 37 | } 38 | } 39 | 40 | final class AsSingle: Producer { 41 | fileprivate let _source: Observable 42 | 43 | init(source: Observable) { 44 | _source = source 45 | } 46 | 47 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 48 | let sink = AsSingleSink(observer: observer, cancel: cancel) 49 | let subscription = _source.subscribe(sink) 50 | return (sink: sink, subscription: subscription) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultIfEmpty.swift 3 | // RxSwift 4 | // 5 | // Created by sergdort on 23/12/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Emits elements from the source observable sequence, or a default element if the source observable sequence is empty. 13 | 14 | - seealso: [DefaultIfEmpty operator on reactivex.io](http://reactivex.io/documentation/operators/defaultifempty.html) 15 | 16 | - parameter default: Default element to be sent if the source does not emit any elements 17 | - returns: An observable sequence which emits default element end completes in case the original sequence is empty 18 | */ 19 | public func ifEmpty(default: E) -> Observable { 20 | return DefaultIfEmpty(source: self.asObservable(), default: `default`) 21 | } 22 | } 23 | 24 | final fileprivate class DefaultIfEmptySink: Sink, ObserverType { 25 | typealias E = O.E 26 | private let _default: E 27 | private var _isEmpty = true 28 | 29 | init(default: E, observer: O, cancel: Cancelable) { 30 | _default = `default` 31 | super.init(observer: observer, cancel: cancel) 32 | } 33 | 34 | func on(_ event: Event) { 35 | switch event { 36 | case .next(_): 37 | _isEmpty = false 38 | forwardOn(event) 39 | case .error(_): 40 | forwardOn(event) 41 | dispose() 42 | case .completed: 43 | if _isEmpty { 44 | forwardOn(.next(_default)) 45 | } 46 | forwardOn(.completed) 47 | dispose() 48 | } 49 | } 50 | } 51 | 52 | final fileprivate class DefaultIfEmpty: Producer { 53 | private let _source: Observable 54 | private let _default: SourceType 55 | 56 | init(source: Observable, `default`: SourceType) { 57 | _source = source 58 | _default = `default` 59 | } 60 | 61 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == SourceType { 62 | let sink = DefaultIfEmptySink(default: _default, observer: observer, cancel: cancel) 63 | let subscription = _source.subscribe(sink) 64 | return (sink: sink, subscription: subscription) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Dematerialize.swift 3 | // RxSwift 4 | // 5 | // Created by Jamie Pinkham on 3/13/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType where E: EventConvertible { 10 | /** 11 | Convert any previously materialized Observable into it's original form. 12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html) 13 | - returns: The dematerialized observable sequence. 14 | */ 15 | public func dematerialize() -> Observable { 16 | return Dematerialize(source: self.asObservable()) 17 | } 18 | 19 | } 20 | 21 | fileprivate final class DematerializeSink: Sink, ObserverType where O.E == Element.ElementType { 22 | fileprivate func on(_ event: Event) { 23 | switch event { 24 | case .next(let element): 25 | forwardOn(element.event) 26 | if element.event.isStopEvent { 27 | dispose() 28 | } 29 | case .completed: 30 | forwardOn(.completed) 31 | dispose() 32 | case .error(let error): 33 | forwardOn(.error(error)) 34 | dispose() 35 | } 36 | } 37 | } 38 | 39 | final fileprivate class Dematerialize: Producer { 40 | private let _source: Observable 41 | 42 | init(source: Observable) { 43 | _source = source 44 | } 45 | 46 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element.ElementType { 47 | let sink = DematerializeSink(observer: observer, cancel: cancel) 48 | let subscription = _source.subscribe(sink) 49 | return (sink: sink, subscription: subscription) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Empty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Empty.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message. 12 | 13 | - seealso: [empty operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 14 | 15 | - returns: An observable sequence with no elements. 16 | */ 17 | public static func empty() -> Observable { 18 | return EmptyProducer() 19 | } 20 | } 21 | 22 | final fileprivate class EmptyProducer : Producer { 23 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 24 | observer.on(.completed) 25 | return Disposables.create() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Enumerated.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Enumerated.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/6/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Enumerates the elements of an observable sequence. 13 | 14 | - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) 15 | 16 | - returns: An observable sequence that contains tuples of source sequence elements and their indexes. 17 | */ 18 | public func enumerated() 19 | -> Observable<(index: Int, element: E)> { 20 | return Enumerated(source: self.asObservable()) 21 | } 22 | } 23 | 24 | final fileprivate class EnumeratedSink: Sink, ObserverType where O.E == (index: Int, element: Element) { 25 | typealias E = Element 26 | var index = 0 27 | 28 | func on(_ event: Event) { 29 | switch event { 30 | case .next(let value): 31 | do { 32 | let nextIndex = try incrementChecked(&index) 33 | let next = (index: nextIndex, element: value) 34 | forwardOn(.next(next)) 35 | } 36 | catch let e { 37 | forwardOn(.error(e)) 38 | dispose() 39 | } 40 | case .completed: 41 | forwardOn(.completed) 42 | dispose() 43 | case .error(let error): 44 | forwardOn(.error(error)) 45 | dispose() 46 | } 47 | } 48 | } 49 | 50 | final fileprivate class Enumerated : Producer<(index: Int, element: Element)> { 51 | private let _source: Observable 52 | 53 | init(source: Observable) { 54 | _source = source 55 | } 56 | 57 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == (index: Int, element: Element) { 58 | let sink = EnumeratedSink(observer: observer, cancel: cancel) 59 | let subscription = _source.subscribe(sink) 60 | return (sink: sink, subscription: subscription) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Error.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Error.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an observable sequence that terminates with an `error`. 12 | 13 | - seealso: [throw operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 14 | 15 | - returns: The observable sequence that terminates with specified error. 16 | */ 17 | public static func error(_ error: Swift.Error) -> Observable { 18 | return ErrorProducer(error: error) 19 | } 20 | } 21 | 22 | final fileprivate class ErrorProducer : Producer { 23 | private let _error: Swift.Error 24 | 25 | init(error: Swift.Error) { 26 | _error = error 27 | } 28 | 29 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 30 | observer.on(.error(_error)) 31 | return Disposables.create() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/First.swift: -------------------------------------------------------------------------------- 1 | // 2 | // First.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 7/31/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class FirstSink : Sink, ObserverType where O.E == Element? { 10 | typealias E = Element 11 | typealias Parent = First 12 | 13 | func on(_ event: Event) { 14 | switch event { 15 | case .next(let value): 16 | forwardOn(.next(value)) 17 | forwardOn(.completed) 18 | dispose() 19 | case .error(let error): 20 | forwardOn(.error(error)) 21 | dispose() 22 | case .completed: 23 | forwardOn(.next(nil)) 24 | forwardOn(.completed) 25 | dispose() 26 | } 27 | } 28 | } 29 | 30 | final class First: Producer { 31 | fileprivate let _source: Observable 32 | 33 | init(source: Observable) { 34 | _source = source 35 | } 36 | 37 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element? { 38 | let sink = FirstSink(observer: observer, cancel: cancel) 39 | let subscription = _source.subscribe(sink) 40 | return (sink: sink, subscription: subscription) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Materialize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Materialize.swift 3 | // RxSwift 4 | // 5 | // Created by sergdort on 08/03/2017. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Convert any Observable into an Observable of its events. 12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html) 13 | - returns: An observable sequence that wraps events in an Event. The returned Observable never errors, but it does complete after observing all of the events of the underlying Observable. 14 | */ 15 | public func materialize() -> Observable> { 16 | return Materialize(source: self.asObservable()) 17 | } 18 | } 19 | 20 | fileprivate final class MaterializeSink: Sink, ObserverType where O.E == Event { 21 | 22 | func on(_ event: Event) { 23 | forwardOn(.next(event)) 24 | if event.isStopEvent { 25 | forwardOn(.completed) 26 | dispose() 27 | } 28 | } 29 | } 30 | 31 | final fileprivate class Materialize: Producer> { 32 | private let _source: Observable 33 | 34 | init(source: Observable) { 35 | _source = source 36 | } 37 | 38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 39 | let sink = MaterializeSink(observer: observer, cancel: cancel) 40 | let subscription = _source.subscribe(sink) 41 | 42 | return (sink: sink, subscription: subscription) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Never.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Never.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Returns a non-terminating observable sequence, which can be used to denote an infinite duration. 13 | 14 | - seealso: [never operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 15 | 16 | - returns: An observable sequence whose observers will never get called. 17 | */ 18 | public static func never() -> Observable { 19 | return NeverProducer() 20 | } 21 | } 22 | 23 | final fileprivate class NeverProducer : Producer { 24 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 25 | return Disposables.create() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Repeat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Repeat.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages. 12 | 13 | - seealso: [repeat operator on reactivex.io](http://reactivex.io/documentation/operators/repeat.html) 14 | 15 | - parameter element: Element to repeat. 16 | - parameter scheduler: Scheduler to run the producer loop on. 17 | - returns: An observable sequence that repeats the given element infinitely. 18 | */ 19 | public static func repeatElement(_ element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { 20 | return RepeatElement(element: element, scheduler: scheduler) 21 | } 22 | } 23 | 24 | final fileprivate class RepeatElement : Producer { 25 | fileprivate let _element: Element 26 | fileprivate let _scheduler: ImmediateSchedulerType 27 | 28 | init(element: Element, scheduler: ImmediateSchedulerType) { 29 | _element = element 30 | _scheduler = scheduler 31 | } 32 | 33 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 34 | let sink = RepeatElementSink(parent: self, observer: observer, cancel: cancel) 35 | let subscription = sink.run() 36 | 37 | return (sink: sink, subscription: subscription) 38 | } 39 | } 40 | 41 | final fileprivate class RepeatElementSink : Sink { 42 | typealias Parent = RepeatElement 43 | 44 | private let _parent: Parent 45 | 46 | init(parent: Parent, observer: O, cancel: Cancelable) { 47 | _parent = parent 48 | super.init(observer: observer, cancel: cancel) 49 | } 50 | 51 | func run() -> Disposable { 52 | return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in 53 | self.forwardOn(.next(e)) 54 | recurse(e) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Sink.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sink.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | class Sink : Disposable { 10 | fileprivate let _observer: O 11 | fileprivate let _cancel: Cancelable 12 | fileprivate var _disposed: Bool 13 | 14 | #if DEBUG 15 | fileprivate let _synchronizationTracker = SynchronizationTracker() 16 | #endif 17 | 18 | init(observer: O, cancel: Cancelable) { 19 | #if TRACE_RESOURCES 20 | let _ = Resources.incrementTotal() 21 | #endif 22 | _observer = observer 23 | _cancel = cancel 24 | _disposed = false 25 | } 26 | 27 | final func forwardOn(_ event: Event) { 28 | #if DEBUG 29 | _synchronizationTracker.register(synchronizationErrorMessage: .default) 30 | defer { _synchronizationTracker.unregister() } 31 | #endif 32 | if _disposed { 33 | return 34 | } 35 | _observer.on(event) 36 | } 37 | 38 | final func forwarder() -> SinkForward { 39 | return SinkForward(forward: self) 40 | } 41 | 42 | final var disposed: Bool { 43 | return _disposed 44 | } 45 | 46 | func dispose() { 47 | _disposed = true 48 | _cancel.dispose() 49 | } 50 | 51 | deinit { 52 | #if TRACE_RESOURCES 53 | let _ = Resources.decrementTotal() 54 | #endif 55 | } 56 | } 57 | 58 | final class SinkForward: ObserverType { 59 | typealias E = O.E 60 | 61 | private let _forward: Sink 62 | 63 | init(forward: Sink) { 64 | _forward = forward 65 | } 66 | 67 | final func on(_ event: Event) { 68 | switch event { 69 | case .next: 70 | _forward._observer.on(event) 71 | case .error, .completed: 72 | _forward._observer.on(event) 73 | _forward._cancel.dispose() 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/StartWith.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StartWith.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Prepends a sequence of values to an observable sequence. 13 | 14 | - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html) 15 | 16 | - parameter elements: Elements to prepend to the specified sequence. 17 | - returns: The source sequence prepended with the specified values. 18 | */ 19 | public func startWith(_ elements: E ...) 20 | -> Observable { 21 | return StartWith(source: self.asObservable(), elements: elements) 22 | } 23 | } 24 | 25 | final fileprivate class StartWith: Producer { 26 | let elements: [Element] 27 | let source: Observable 28 | 29 | init(source: Observable, elements: [Element]) { 30 | self.source = source 31 | self.elements = elements 32 | super.init() 33 | } 34 | 35 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 36 | for e in elements { 37 | observer.on(.next(e)) 38 | } 39 | 40 | return (sink: Disposables.create(), subscription: source.subscribe(observer)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/ToArray.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ToArray.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 20/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | 10 | extension ObservableType { 11 | 12 | /** 13 | Converts an Observable into another Observable that emits the whole sequence as a single array and then terminates. 14 | 15 | For aggregation behavior see `reduce`. 16 | 17 | - seealso: [toArray operator on reactivex.io](http://reactivex.io/documentation/operators/to.html) 18 | 19 | - returns: An observable sequence containing all the emitted elements as array. 20 | */ 21 | public func toArray() 22 | -> Observable<[E]> { 23 | return ToArray(source: self.asObservable()) 24 | } 25 | } 26 | 27 | final fileprivate class ToArraySink : Sink, ObserverType where O.E == [SourceType] { 28 | typealias Parent = ToArray 29 | 30 | let _parent: Parent 31 | var _list = Array() 32 | 33 | init(parent: Parent, observer: O, cancel: Cancelable) { 34 | _parent = parent 35 | 36 | super.init(observer: observer, cancel: cancel) 37 | } 38 | 39 | func on(_ event: Event) { 40 | switch event { 41 | case .next(let value): 42 | self._list.append(value) 43 | case .error(let e): 44 | forwardOn(.error(e)) 45 | self.dispose() 46 | case .completed: 47 | forwardOn(.next(_list)) 48 | forwardOn(.completed) 49 | self.dispose() 50 | } 51 | } 52 | } 53 | 54 | final fileprivate class ToArray : Producer<[SourceType]> { 55 | let _source: Observable 56 | 57 | init(source: Observable) { 58 | _source = source 59 | } 60 | 61 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == [SourceType] { 62 | let sink = ToArraySink(parent: self, observer: observer, cancel: cancel) 63 | let subscription = _source.subscribe(sink) 64 | return (sink: sink, subscription: subscription) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObserverType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Supports push-style iteration over an observable sequence. 10 | public protocol ObserverType { 11 | /// The type of elements in sequence that observer can observe. 12 | associatedtype E 13 | 14 | /// Notify observer about sequence event. 15 | /// 16 | /// - parameter event: Event that occurred. 17 | func on(_ event: Event) 18 | } 19 | 20 | /// Convenience API extensions to provide alternate next, error, completed events 21 | extension ObserverType { 22 | 23 | /// Convenience method equivalent to `on(.next(element: E))` 24 | /// 25 | /// - parameter element: Next element to send to observer(s) 26 | public func onNext(_ element: E) { 27 | on(.next(element)) 28 | } 29 | 30 | /// Convenience method equivalent to `on(.completed)` 31 | public func onCompleted() { 32 | on(.completed) 33 | } 34 | 35 | /// Convenience method equivalent to `on(.error(Swift.Error))` 36 | /// - parameter error: Swift.Error to send to observer(s) 37 | public func onError(_ error: Swift.Error) { 38 | on(.error(error)) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousObserver.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | final class AnonymousObserver : ObserverBase { 10 | typealias Element = ElementType 11 | 12 | typealias EventHandler = (Event) -> Void 13 | 14 | private let _eventHandler : EventHandler 15 | 16 | init(_ eventHandler: @escaping EventHandler) { 17 | #if TRACE_RESOURCES 18 | let _ = Resources.incrementTotal() 19 | #endif 20 | _eventHandler = eventHandler 21 | } 22 | 23 | override func onCore(_ event: Event) { 24 | return _eventHandler(event) 25 | } 26 | 27 | #if TRACE_RESOURCES 28 | deinit { 29 | let _ = Resources.decrementTotal() 30 | } 31 | #endif 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverBase.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | class ObserverBase : Disposable, ObserverType { 10 | typealias E = ElementType 11 | 12 | private var _isStopped: AtomicInt = 0 13 | 14 | func on(_ event: Event) { 15 | switch event { 16 | case .next: 17 | if _isStopped == 0 { 18 | onCore(event) 19 | } 20 | case .error, .completed: 21 | if AtomicCompareAndSwap(0, 1, &_isStopped) { 22 | onCore(event) 23 | } 24 | } 25 | } 26 | 27 | func onCore(_ event: Event) { 28 | rxAbstractMethod() 29 | } 30 | 31 | func dispose() { 32 | _ = AtomicCompareAndSwap(0, 1, &_isStopped) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Reactive.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Reactive.swift 3 | // RxSwift 4 | // 5 | // Created by Yury Korolev on 5/2/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | Use `Reactive` proxy as customization point for constrained protocol extensions. 11 | 12 | General pattern would be: 13 | 14 | // 1. Extend Reactive protocol with constrain on Base 15 | // Read as: Reactive Extension where Base is a SomeType 16 | extension Reactive where Base: SomeType { 17 | // 2. Put any specific reactive extension for SomeType here 18 | } 19 | 20 | With this approach we can have more specialized methods and properties using 21 | `Base` and not just specialized on common base type. 22 | 23 | */ 24 | 25 | public struct Reactive { 26 | /// Base object to extend. 27 | public let base: Base 28 | 29 | /// Creates extensions with base object. 30 | /// 31 | /// - parameter base: Base object. 32 | public init(_ base: Base) { 33 | self.base = base 34 | } 35 | } 36 | 37 | /// A type that has reactive extensions. 38 | public protocol ReactiveCompatible { 39 | /// Extended type 40 | associatedtype CompatibleType 41 | 42 | /// Reactive extensions. 43 | static var rx: Reactive.Type { get set } 44 | 45 | /// Reactive extensions. 46 | var rx: Reactive { get set } 47 | } 48 | 49 | extension ReactiveCompatible { 50 | /// Reactive extensions. 51 | public static var rx: Reactive.Type { 52 | get { 53 | return Reactive.self 54 | } 55 | set { 56 | // this enables using Reactive to "mutate" base type 57 | } 58 | } 59 | 60 | /// Reactive extensions. 61 | public var rx: Reactive { 62 | get { 63 | return Reactive(self) 64 | } 65 | set { 66 | // this enables using Reactive to "mutate" base object 67 | } 68 | } 69 | } 70 | 71 | import class Foundation.NSObject 72 | 73 | /// Extend NSObject with `rx` proxy. 74 | extension NSObject: ReactiveCompatible { } 75 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/RxMutableBox.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxMutableBox.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/22/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Creates mutable reference wrapper for any type. 10 | final class RxMutableBox : CustomDebugStringConvertible { 11 | /// Wrapped value 12 | var value : T 13 | 14 | /// Creates reference wrapper for `value`. 15 | /// 16 | /// - parameter value: Value to wrap. 17 | init (_ value: T) { 18 | self.value = value 19 | } 20 | } 21 | 22 | extension RxMutableBox { 23 | /// - returns: Box description. 24 | var debugDescription: String { 25 | return "MutatingBox(\(self.value))" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HistoricalScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/27/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.Date 10 | 11 | /// Provides a virtual time scheduler that uses `Date` for absolute time and `NSTimeInterval` for relative time. 12 | public class HistoricalScheduler : VirtualTimeScheduler { 13 | 14 | /** 15 | Creates a new historical scheduler with initial clock value. 16 | 17 | - parameter initialClock: Initial value for virtual clock. 18 | */ 19 | public init(initialClock: RxTime = Date(timeIntervalSince1970: 0)) { 20 | super.init(initialClock: initialClock, converter: HistoricalSchedulerTimeConverter()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableScheduledItem.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct InvocableScheduledItem : InvocableType { 10 | 11 | let _invocable: I 12 | let _state: I.Value 13 | 14 | init(invocable: I, state: I.Value) { 15 | _invocable = invocable 16 | _state = state 17 | } 18 | 19 | func invoke() { 20 | _invocable.invoke(_state) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol InvocableType { 10 | func invoke() 11 | } 12 | 13 | protocol InvocableWithValueType { 14 | associatedtype Value 15 | 16 | func invoke(_ value: Value) 17 | } 18 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItem.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct ScheduledItem 10 | : ScheduledItemType 11 | , InvocableType { 12 | typealias Action = (T) -> Disposable 13 | 14 | private let _action: Action 15 | private let _state: T 16 | 17 | private let _disposable = SingleAssignmentDisposable() 18 | 19 | var isDisposed: Bool { 20 | return _disposable.isDisposed 21 | } 22 | 23 | init(action: @escaping Action, state: T) { 24 | _action = action 25 | _state = state 26 | } 27 | 28 | func invoke() { 29 | _disposable.setDisposable(_action(_state)) 30 | } 31 | 32 | func dispose() { 33 | _disposable.dispose() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItemType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol ScheduledItemType 10 | : Cancelable 11 | , InvocableType { 12 | func invoke() 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OperationQueueScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.OperationQueue 10 | import class Foundation.BlockOperation 11 | import Dispatch 12 | 13 | /// Abstracts the work that needs to be performed on a specific `NSOperationQueue`. 14 | /// 15 | /// This scheduler is suitable for cases when there is some bigger chunk of work that needs to be performed in background and you want to fine tune concurrent processing using `maxConcurrentOperationCount`. 16 | public class OperationQueueScheduler: ImmediateSchedulerType { 17 | public let operationQueue: OperationQueue 18 | 19 | /// Constructs new instance of `OperationQueueScheduler` that performs work on `operationQueue`. 20 | /// 21 | /// - parameter operationQueue: Operation queue targeted to perform work on. 22 | public init(operationQueue: OperationQueue) { 23 | self.operationQueue = operationQueue 24 | } 25 | 26 | /** 27 | Schedules an action to be executed recursively. 28 | 29 | - parameter state: State passed to the action to be executed. 30 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. 31 | - returns: The disposable object used to cancel the scheduled action (best effort). 32 | */ 33 | public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { 34 | let cancel = SingleAssignmentDisposable() 35 | 36 | let operation = BlockOperation { 37 | if cancel.isDisposed { 38 | return 39 | } 40 | 41 | 42 | cancel.setDisposable(action(state)) 43 | } 44 | 45 | self.operationQueue.addOperation(operation) 46 | 47 | return cancel 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubjectType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an object that is both an observable sequence as well as an observer. 10 | public protocol SubjectType : ObservableType { 11 | /// The type of the observer that represents this subject. 12 | /// 13 | /// Usually this type is type of subject itself, but it doesn't have to be. 14 | associatedtype SubjectObserverType : ObserverType 15 | 16 | /// Returns observer interface for subject. 17 | /// 18 | /// - returns: Observer interface for subject. 19 | func asObserver() -> SubjectObserverType 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftSupport.swift 3 | // RxSwift 4 | // 5 | // Created by Volodymyr Gorbenko on 3/6/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if swift(>=4.0) 12 | typealias IntMax = Int64 13 | public typealias RxAbstractInteger = FixedWidthInteger 14 | 15 | extension SignedInteger { 16 | func toIntMax() -> IntMax { 17 | return IntMax(self) 18 | } 19 | } 20 | #else 21 | public typealias RxAbstractInteger = SignedInteger 22 | 23 | extension Array { 24 | public mutating func swapAt(_ i: Int, _ j: Int) { 25 | swap(&self[i], &self[j]) 26 | } 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableType+PrimitiveSequence.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/17/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | The `asSingle` operator throws a `RxError.noElements` or `RxError.moreThanOneElement` 12 | if the source Observable does not emit exactly one element before successfully completing. 13 | 14 | - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) 15 | 16 | - returns: An observable sequence that emits a single element or throws an exception if more (or none) of them are emitted. 17 | */ 18 | public func asSingle() -> Single { 19 | return PrimitiveSequence(raw: AsSingle(source: self.asObservable())) 20 | } 21 | 22 | /** 23 | The `asMaybe` operator throws a ``RxError.moreThanOneElement` 24 | if the source Observable does not emit at most one element before successfully completing. 25 | 26 | - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) 27 | 28 | - returns: An observable sequence that emits a single element, completes or throws an exception if more of them are emitted. 29 | */ 30 | public func asMaybe() -> Maybe { 31 | return PrimitiveSequence(raw: AsMaybe(source: self.asObservable())) 32 | } 33 | } 34 | 35 | extension ObservableType where E == Never { 36 | /** 37 | - returns: An observable sequence that completes. 38 | */ 39 | public func asCompletable() 40 | -> Completable { 41 | return PrimitiveSequence(raw: self.asObservable()) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.1.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/RxCocoa-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RxCocoa : NSObject 3 | @end 4 | @implementation PodsDummy_RxCocoa 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/RxCocoa-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/RxCocoa-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "RxCocoa.h" 14 | #import "RxCocoaRuntime.h" 15 | #import "_RX.h" 16 | #import "_RXDelegateProxy.h" 17 | #import "_RXKVOObserver.h" 18 | #import "_RXObjCRuntime.h" 19 | 20 | FOUNDATION_EXPORT double RxCocoaVersionNumber; 21 | FOUNDATION_EXPORT const unsigned char RxCocoaVersionString[]; 22 | 23 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/RxCocoa.modulemap: -------------------------------------------------------------------------------- 1 | framework module RxCocoa { 2 | umbrella header "RxCocoa-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxCocoa/RxCocoa.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/RxCocoa 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/RxCocoa 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.1.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RxSwift : NSObject 3 | @end 4 | @implementation PodsDummy_RxSwift 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double RxSwiftVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char RxSwiftVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift.modulemap: -------------------------------------------------------------------------------- 1 | framework module RxSwift { 2 | umbrella header "RxSwift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/RxSwift 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/RxSwift 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/TinyConstraints-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_TinyConstraints : NSObject 3 | @end 4 | @implementation PodsDummy_TinyConstraints 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/TinyConstraints-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/TinyConstraints-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double TinyConstraintsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char TinyConstraintsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/TinyConstraints.modulemap: -------------------------------------------------------------------------------- 1 | framework module TinyConstraints { 2 | umbrella header "TinyConstraints-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/TinyConstraints/TinyConstraints.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/TinyConstraints 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/TinyConstraints 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/TinyConstraints/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2017 Robert-Hein Hooijmans 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Example/Pods/TinyConstraints/TinyConstraints/Classes/Abstraction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MIT License 3 | // 4 | // Copyright (c) 2017 Robert-Hein Hooijmans 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import Foundation 25 | 26 | #if os(OSX) 27 | import AppKit 28 | 29 | public typealias View = NSView 30 | public typealias LayoutGuide = NSLayoutGuide 31 | public typealias ConstraintAxis = NSLayoutConstraint.Orientation 32 | public typealias LayoutPriority = NSLayoutConstraint.Priority 33 | public typealias TinyEdgeInsets = NSEdgeInsets 34 | 35 | public extension NSEdgeInsets { 36 | static var zero = NSEdgeInsetsZero 37 | } 38 | #else 39 | import UIKit 40 | 41 | public typealias View = UIView 42 | public typealias LayoutGuide = UILayoutGuide 43 | public typealias ConstraintAxis = UILayoutConstraintAxis 44 | public typealias LayoutPriority = UILayoutPriority 45 | 46 | public typealias TinyEdgeInsets = UIEdgeInsets 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /Example/Pods/TinyConstraints/TinyConstraints/Classes/Constrainable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MIT License 3 | // 4 | // Copyright (c) 2017 Robert-Hein Hooijmans 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(OSX) 25 | import AppKit 26 | #else 27 | import UIKit 28 | #endif 29 | 30 | extension View: Constrainable { 31 | 32 | @discardableResult 33 | public func prepareForLayout() -> Self { 34 | translatesAutoresizingMaskIntoConstraints = false 35 | return self 36 | } 37 | } 38 | 39 | extension LayoutGuide: Constrainable { 40 | @discardableResult 41 | public func prepareForLayout() -> Self { return self } 42 | } 43 | 44 | public protocol Constrainable { 45 | var topAnchor: NSLayoutYAxisAnchor { get } 46 | var bottomAnchor: NSLayoutYAxisAnchor { get } 47 | var leftAnchor: NSLayoutXAxisAnchor { get } 48 | var rightAnchor: NSLayoutXAxisAnchor { get } 49 | var leadingAnchor: NSLayoutXAxisAnchor { get } 50 | var trailingAnchor: NSLayoutXAxisAnchor { get } 51 | 52 | var centerXAnchor: NSLayoutXAxisAnchor { get } 53 | var centerYAnchor: NSLayoutYAxisAnchor { get } 54 | 55 | var widthAnchor: NSLayoutDimension { get } 56 | var heightAnchor: NSLayoutDimension { get } 57 | 58 | @discardableResult 59 | func prepareForLayout() -> Self 60 | } 61 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Example/XPlayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/XPlayer.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/XPlayer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/XPlayer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // XPlayer 4 | // 5 | // Created by wddwyss@gmail.com on 05/04/2018. 6 | // Copyright (c) 2018 wddwyss@gmail.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Example/XPlayer/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Example/XPlayer/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/XPlayer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/XPlayer/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // XPlayer 4 | // 5 | // Created by wddwyss@gmail.com on 05/04/2018. 6 | // Copyright (c) 2018 wddwyss@gmail.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import TinyConstraints 11 | import RxSwift 12 | import RxCocoa 13 | import XPlayer 14 | 15 | 16 | class ViewController: UIViewController { 17 | private let disposeBag = DisposeBag() 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | let button = UIButton.init(type: .system) 23 | button.setTitle("Play", for: []) 24 | view.addSubview(button) 25 | button.centerInSuperview() 26 | 27 | button.rx.tap 28 | .subscribe { _ in 29 | let videoURL = URL(string: "https://www.quirksmode.org/html5/videos/big_buck_bunny.mp4")! 30 | XPlayer.play(videoURL) 31 | } 32 | .disposed(by: disposeBag) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 monk-studio 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | 3 | url = "https://pypi.python.org/simple" 4 | verify_ssl = true 5 | name = "pypi" 6 | 7 | 8 | [packages] 9 | 10 | requests = "*" 11 | cairosvg = "*" 12 | pillow = "*" 13 | 14 | 15 | [dev-packages] 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XPlayer 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/XPlayer.svg?style=flat)](https://cocoapods.org/pods/XPlayer) 4 | [![License](https://img.shields.io/cocoapods/l/XPlayer.svg?style=flat)](https://cocoapods.org/pods/XPlayer) 5 | [![Platform](https://img.shields.io/cocoapods/p/XPlayer.svg?style=flat)](https://cocoapods.org/pods/XPlayer) 6 | 7 | ![](https://storage.googleapis.com/duan/etc/69D3CB50-0CEF-4FA6-999F-926FB5A2C731/XPlayer_demo.gif 8 | ) 9 | 10 | ## Introduction 11 | 12 | XPlayer is a **drop to use** lib for playing video on iOS with: 13 | 14 | * playback control 15 | * landscape & portrait switch 16 | * picture in picture mode with smooth interactive transition 17 | 18 | 19 | To keep it simple, the lib currently only provides two methods: 20 | 21 | ```swift 22 | class XPlayer { 23 | static func play(_ url: URL, themeColor: UIColor) 24 | static func dismiss(completion: (() -> ())? = nil) 25 | } 26 | ``` 27 | 28 | ## Example 29 | 30 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 31 | 32 | ## Requirements 33 | 34 | * iOS >= 10.0 35 | 36 | ## Installation 37 | 38 | XPlayer is available through [CocoaPods](https://cocoapods.org). To install 39 | it, simply add the following line to your Podfile: 40 | 41 | ```ruby 42 | pod 'XPlayer' 43 | ``` 44 | 45 | ## Author 46 | 47 | wddwycc, wddwyss@gmail.com 48 | 49 | ## License 50 | 51 | XPlayer is available under the MIT license. See the LICENSE file for more info. 52 | -------------------------------------------------------------------------------- /XPlayer.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint XPlayer.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'XPlayer' 11 | s.version = '0.2.1' 12 | s.swift_version = '4.1' 13 | s.summary = 'PIP Video player for iOS' 14 | 15 | # This description is used to generate tags and improve search results. 16 | # * Think: What does it do? Why did you write it? What is the focus? 17 | # * Try to keep it short, snappy and to the point. 18 | # * Write the description between the DESC delimiters below. 19 | # * Finally, don't worry about the indent, CocoaPods strips it! 20 | 21 | s.description = <<-DESC 22 | TODO: Add long description of the pod here. 23 | DESC 24 | 25 | s.homepage = 'https://github.com/wddwycc/XPlayer' 26 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 27 | s.license = { :type => 'MIT', :file => 'LICENSE' } 28 | s.author = { 'wddwycc' => 'wddwyss@gmail.com' } 29 | s.source = { :git => 'https://github.com/wddwycc/XPlayer.git', :tag => s.version.to_s } 30 | s.social_media_url = 'https://twitter.com/wddwycc' 31 | 32 | s.ios.deployment_target = '10.0' 33 | s.requires_arc = true 34 | 35 | s.source_files = 'XPlayer/Classes/**/*' 36 | 37 | s.resource_bundles = { 38 | 'XPlayer' => ['XPlayer/Assets/*.png'] 39 | } 40 | 41 | s.dependency 'TinyConstraints', '~>3.0' 42 | end 43 | -------------------------------------------------------------------------------- /XPlayer/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/.gitkeep -------------------------------------------------------------------------------- /XPlayer/Assets/maximize_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/maximize_24.png -------------------------------------------------------------------------------- /XPlayer/Assets/minimize_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/minimize_24.png -------------------------------------------------------------------------------- /XPlayer/Assets/pause_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/pause_24.png -------------------------------------------------------------------------------- /XPlayer/Assets/play_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/play_24.png -------------------------------------------------------------------------------- /XPlayer/Assets/x_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Assets/x_24.png -------------------------------------------------------------------------------- /XPlayer/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/XPlayer/868a807adce6490d1f8d5abf8966cf0d274ba7f1/XPlayer/Classes/.gitkeep -------------------------------------------------------------------------------- /XPlayer/Classes/Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Utils.swift 3 | // XPlayer 4 | // 5 | // Created by duan on 16/9/20. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIImage { 12 | static func bundleImage(_ name: String) -> UIImage? { 13 | let frameworkBundle = Bundle.init(for: XPlayer.self) 14 | guard 15 | let url = frameworkBundle.resourceURL?.appendingPathComponent("XPlayer.bundle"), 16 | let bundle = Bundle.init(url: url) 17 | else { return nil } 18 | return UIImage(named: name, in: bundle, compatibleWith: nil) 19 | } 20 | } 21 | 22 | extension CGSize { 23 | static func square(_ border: CGFloat) -> CGSize { 24 | return CGSize(width: border, height: border) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /XPlayer/Classes/WOMaintainer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WOMaintainer.swift 3 | // XPlayer 4 | // 5 | // Created by duan on 16/6/24. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import TinyConstraints 11 | 12 | 13 | enum WOState { 14 | case fullscreen 15 | case pip 16 | case out 17 | } 18 | 19 | struct WOMaintainerInfo { 20 | static let pipDefaultSize = CGSize(width: 170, height: 96) 21 | static func pipRect(size: CGSize) -> CGRect { 22 | let screenSize = UIScreen.main.bounds.size 23 | let offset: CGFloat = 12 24 | return CGRect(x: screenSize.width - offset - size.width, 25 | y: screenSize.height - offset - size.height, 26 | width: size.width, 27 | height: size.height) 28 | } 29 | } 30 | 31 | class WOMaintainer { 32 | static var state: WOState = .out 33 | static var vc: WOViewController? 34 | static func show(vc: WOViewController) { 35 | guard let window = UIApplication.shared.keyWindow else { return } 36 | if WOMaintainer.state != .out { 37 | dismiss(completion: { 38 | WOMaintainer.show(vc: vc) 39 | }) 40 | return 41 | } 42 | WOMaintainer.vc = vc 43 | vc.view.alpha = 0 44 | UIView.animate(withDuration: 0.3) { 45 | WOMaintainer.vc!.view.alpha = 1 46 | } 47 | window.addSubview(WOMaintainer.vc!.view) 48 | 49 | vc.leadingConstraint = vc.view.leadingToSuperview() 50 | vc.topConstraint = vc.view.topToSuperview() 51 | vc.trailingConstraint = vc.view.trailingToSuperview() 52 | vc.bottomConstraint = vc.view.bottomToSuperview() 53 | 54 | WOMaintainer.state = .fullscreen 55 | } 56 | 57 | static func dismiss(completion: (()->())?) { 58 | guard let vc = WOMaintainer.vc else { return } 59 | UIView.animate(withDuration: 0.3, animations: { 60 | vc.view.alpha = 0 61 | }) { _ in 62 | vc.view.removeFromSuperview() 63 | vc.didEnterOut() 64 | WOMaintainer.vc = nil 65 | WOMaintainer.state = .out 66 | completion?() 67 | } 68 | } 69 | } 70 | 71 | func delay(seconds: Double, completion:@escaping ()->()) { 72 | let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC) 73 | DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: { 74 | completion() 75 | }) 76 | } 77 | -------------------------------------------------------------------------------- /XPlayer/Classes/XPlayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XPlayer.swift 3 | // XPlayer 4 | // 5 | // Created by duan on 16/6/24. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class XPlayer: NSObject { 12 | public static func play(_ url: URL, themeColor: UIColor = #colorLiteral(red: 0, green: 0.6980392157, blue: 0.1137254902, alpha: 1)) { 13 | let vc = XPlayerViewController(url: url, themeColor: themeColor) 14 | WOMaintainer.show(vc: vc) 15 | } 16 | 17 | public static func dismiss(completion: (() -> ())? = nil) { 18 | WOMaintainer.dismiss(completion: completion) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /XPlayer/Classes/XPlayerViewController+State.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XPlayerViewController+Action.swift 3 | // XPlayer 4 | // 5 | // Created by duan on 16/9/19. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | extension XPlayerViewController { 13 | override func didEnterPIP() { 14 | super.didEnterPIP() 15 | self.toggleControlTapGesture.isEnabled = false 16 | } 17 | 18 | override func didEnterOut() { 19 | super.didEnterOut() 20 | self.playerVC.player!.removeObserver(self, forKeyPath: "rate") 21 | self.playerVC.player!.currentItem!.removeObserver(self, forKeyPath: "status") 22 | NotificationCenter.default.removeObserver(self) 23 | self.playerVC.player!.pause() 24 | self.playerVC.player = nil 25 | } 26 | 27 | override func didEnterFullScreen() { 28 | super.didEnterFullScreen() 29 | self.toggleControlTapGesture.isEnabled = true 30 | UIView.animate(withDuration: 0.3) { [weak self] in 31 | guard let _self = self else { return } 32 | [ 33 | _self.playButtton, _self.closeButton, 34 | _self.fullScreenButton, _self.timelineLabel, 35 | _self.closeButton, _self.timelineViewContainer 36 | ].forEach { (element) in 37 | element.layer.transform = CATransform3DIdentity 38 | _self.showingControls = true 39 | element.alpha = 1 40 | } 41 | self?.progress += CGFloat(UInt.min) 42 | } 43 | } 44 | 45 | override func didStartTransition() { 46 | super.didStartTransition() 47 | UIView.animate(withDuration: 0.3) { [weak self] in 48 | guard let _self = self else { return } 49 | [ 50 | _self.playButtton, _self.closeButton, 51 | _self.fullScreenButton, _self.timelineLabel, 52 | _self.closeButton, _self.timelineViewContainer 53 | ].forEach { (element) in 54 | element.alpha = 0 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /scripts/gen_icon.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | 5 | import cairosvg 6 | import requests 7 | 8 | ORIGIN = 'https://raw.githubusercontent.com/feathericons/feather/master/icons' 9 | ORIGIN_SIZE = 24 10 | 11 | 12 | def run(icon_name, size=24): 13 | source_name = icon_name + '.svg' 14 | source_url = os.path.join(ORIGIN, source_name) 15 | r = requests.get(source_url) 16 | icon_name = icon_name + '_' + str(size) 17 | factor = size / ORIGIN_SIZE 18 | cairosvg.svg2png( 19 | bytestring=r.text, 20 | write_to=os.path.join('./XPlayer/Assets', icon_name + '.png'), 21 | scale=factor * 2 22 | ) 23 | print('🎉') 24 | 25 | 26 | if __name__ == '__main__': 27 | try: 28 | size = sys.argv[2] 29 | size = int(size) 30 | except IndexError: 31 | size = 24 32 | run(sys.argv[1], size) 33 | --------------------------------------------------------------------------------