Skip to content

Commit

Permalink
Merge pull request #3636 from eimantas/nsview-bindings
Browse files Browse the repository at this point in the history
Add bindings for `NSView.alphaValue`
  • Loading branch information
mdiep committed Nov 27, 2018
2 parents 0389452 + 0018adb commit 5c1e1a1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# master
*Please put new entries at the top.
1. Add extension for `alphaValue` property of `NSView` class. (#3636, kuds to @eimantas)
1. Add extension for `isHidden` property of `NSView` class. (#3634, kudos to @eimantas)

# 8.0.2
Expand Down
5 changes: 5 additions & 0 deletions ReactiveCocoa/AppKit/NSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ extension Reactive where Base: NSView {
public var isHidden: BindingTarget<Bool> {
return makeBindingTarget { $0.isHidden = $1 }
}

/// Sets the alpha value of the view.
public var alphaValue: BindingTarget<CGFloat> {
return makeBindingTarget { $0.alphaValue = $1 }
}
}
14 changes: 12 additions & 2 deletions ReactiveCocoaTests/AppKit/NSViewSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ class NSViewSpec: QuickSpec {

it("should allow binding of `isHidden` property") {
let (hSignal, hSink) = Signal<Bool, NoError>.pipe()
expect(view.isHidden).to(beFalse())
expect(view.isHidden) == false

view.reactive.isHidden <~ hSignal
hSink.send(value: true)

expect(view.isHidden).to(beTrue())
expect(view.isHidden) == true
}

it("should allow binding of `alphaValue` property") {
let (avSignal, avSink) = Signal<CGFloat, NoError>.pipe()
expect(view.alphaValue) == 1.0

view.reactive.alphaValue <~ avSignal
avSink.send(value: 0.5)

expect(view.alphaValue) == 0.5
}
}
}
Expand Down

0 comments on commit 5c1e1a1

Please sign in to comment.