-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
216 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.0 | ||
4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
language: swift | ||
osx_image: xcode9.4 | ||
osx_image: xcode10 | ||
|
||
script: | ||
- set -o pipefail && xcodebuild clean test -project Bond.xcodeproj -scheme Bond-iOS -destination "platform=iOS Simulator,name=iPhone 7,OS=11.4" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet | xcpretty | ||
- swift test -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.11" | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) | ||
jobs: | ||
include: | ||
- stage: "Tests" | ||
name: "Run Xcode Tests" | ||
script: | ||
- set -o pipefail && xcodebuild clean test -project Bond.xcodeproj -scheme Bond-iOS -destination "platform=iOS Simulator,name=iPhone 7,OS=11.4" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet | xcpretty | ||
after_success: bash <(curl -s https://codecov.io/bash) | ||
- script: swift test | ||
name: "Run Swift Package Manager Tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
github "DeclarativeHub/ReactiveKit" ~> 3.9 | ||
github "tonyarnold/Differ" ~> 1.2 | ||
github "tonyarnold/Differ" ~> 1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
[![Platform](https://img.shields.io/cocoapods/p/Bond.svg?style=flat)](http://cocoadocs.org/docsets/Bond/) | ||
[![CI Status](https://travis-ci.org/DeclarativeHub/Bond.svg?branch=master)](https://travis-ci.org/DeclarativeHub/Bond) | ||
[![Join Us on Gitter](https://img.shields.io/badge/GITTER-join%20chat-blue.svg)](https://gitter.im/ReactiveKit/General) | ||
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/srdanrasic) | ||
|
||
<br> | ||
|
@@ -186,8 +185,7 @@ Bond uses protocol proxies to implement table and collection view bindings and t | |
|
||
## Communication | ||
|
||
* If you'd like to ask a general question, use Stack Overflow. | ||
* If you'd like to ask a quick question or chat about the project, try [Gitter](https://gitter.im/ReactiveKit/General). | ||
* If you'd like to ask a question, open an issue. | ||
* If you found a bug, open an issue. | ||
* If you have a feature request, open an issue. | ||
* If you want to contribute, submit a pull request (include unit tests). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2016 Tony Arnold (@tonyarnold) | ||
// | ||
// 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: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// 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. | ||
// | ||
|
||
#if os(macOS) | ||
|
||
import AppKit | ||
import ReactiveKit | ||
|
||
extension NSGestureRecognizer: BindingExecutionContextProvider { | ||
public var bindingExecutionContext: ExecutionContext { return .immediateOnMain } | ||
} | ||
|
||
public extension ReactiveExtensions where Base: NSGestureRecognizer { | ||
public var isEnabled: Bond<Bool> { | ||
return bond { $0.isEnabled = $1 } | ||
} | ||
} | ||
|
||
public extension ReactiveExtensions where Base: NSView { | ||
public func addGestureRecognizer<T: NSGestureRecognizer>(_ gestureRecognizer: T) -> SafeSignal<T> { | ||
let base = self.base | ||
return Signal { [weak base] observer in | ||
guard let base = base else { | ||
observer.completed() | ||
return NonDisposable.instance | ||
} | ||
let target = BNDGestureTarget(view: base, gestureRecognizer: gestureRecognizer) { recog in | ||
// swiftlint:disable:next force_cast | ||
observer.next(recog as! T) | ||
} | ||
return BlockDisposable { | ||
target.unregister() | ||
} | ||
} | ||
.take(until: base.deallocated) | ||
} | ||
|
||
public func clickGesture(numberOfClicks: Int = 1, numberOfTouches: Int = 1) -> SafeSignal<NSClickGestureRecognizer> { | ||
let gesture = NSClickGestureRecognizer() | ||
gesture.numberOfClicksRequired = numberOfClicks | ||
|
||
if #available(macOS 10.12.2, *) { | ||
gesture.numberOfTouchesRequired = numberOfTouches | ||
} | ||
|
||
return addGestureRecognizer(gesture) | ||
} | ||
|
||
public func magnificationGesture(magnification: CGFloat = 1.0, numberOfTouches: Int = 1) -> SafeSignal<NSMagnificationGestureRecognizer> { | ||
let gesture = NSMagnificationGestureRecognizer() | ||
gesture.magnification = magnification | ||
return addGestureRecognizer(gesture) | ||
} | ||
|
||
public func panGesture(buttonMask: Int = 0x01, numberOfTouches: Int = 1) -> SafeSignal<NSPanGestureRecognizer> { | ||
let gesture = NSPanGestureRecognizer() | ||
gesture.buttonMask = buttonMask | ||
|
||
if #available(macOS 10.12.2, *) { | ||
gesture.numberOfTouchesRequired = numberOfTouches | ||
} | ||
|
||
return addGestureRecognizer(gesture) | ||
} | ||
|
||
public func pressGesture(buttonMask: Int = 0x01, minimumPressDuration: TimeInterval = NSEvent.doubleClickInterval, allowableMovement: CGFloat = 10.0, numberOfTouches: Int = 1) -> SafeSignal<NSPressGestureRecognizer> { | ||
let gesture = NSPressGestureRecognizer() | ||
gesture.buttonMask = buttonMask | ||
gesture.minimumPressDuration = minimumPressDuration | ||
gesture.allowableMovement = allowableMovement | ||
|
||
if #available(macOS 10.12.2, *) { | ||
gesture.numberOfTouchesRequired = numberOfTouches | ||
} | ||
|
||
return addGestureRecognizer(gesture) | ||
} | ||
|
||
public func rotationGesture() -> SafeSignal<NSRotationGestureRecognizer> { | ||
return addGestureRecognizer(NSRotationGestureRecognizer()) | ||
} | ||
} | ||
|
||
@objc private class BNDGestureTarget: NSObject { | ||
private weak var view: NSView? | ||
private let observer: (NSGestureRecognizer) -> Void | ||
private let gestureRecognizer: NSGestureRecognizer | ||
|
||
fileprivate init(view: NSView, gestureRecognizer: NSGestureRecognizer, observer: @escaping (NSGestureRecognizer) -> Void) { | ||
self.view = view | ||
self.gestureRecognizer = gestureRecognizer | ||
self.observer = observer | ||
|
||
super.init() | ||
|
||
gestureRecognizer.target = self | ||
gestureRecognizer.action = #selector(actionHandler(recogniser:)) | ||
view.addGestureRecognizer(gestureRecognizer) | ||
} | ||
|
||
@objc private func actionHandler(recogniser: NSGestureRecognizer) { | ||
observer(recogniser) | ||
} | ||
|
||
fileprivate func unregister() { | ||
view?.removeGestureRecognizer(gestureRecognizer) | ||
} | ||
|
||
deinit { | ||
unregister() | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.