Skip to content

Commit 16b296f

Browse files
committed
Deprecates image(transitionType:) in favor of image.
1 parent 69ae352 commit 16b296f

File tree

3 files changed

+56
-40
lines changed

3 files changed

+56
-40
lines changed

RxCocoa/Deprecated.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,57 @@ public final class UIBindingObserver<UIElementType, Value> : ObserverType where
339339
}
340340
}
341341
#endif
342+
343+
#if os(iOS) || os(tvOS)
344+
extension Reactive where Base: UIImageView {
345+
346+
/// Bindable sink for `image` property.
347+
/// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
348+
@available(*, deprecated, renamed: "image")
349+
public func image(transitionType: String? = nil) -> Binder<UIImage?> {
350+
return Binder(base) { imageView, image in
351+
if let transitionType = transitionType {
352+
if image != nil {
353+
let transition = CATransition()
354+
transition.duration = 0.25
355+
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
356+
transition.type = transitionType
357+
imageView.layer.add(transition, forKey: kCATransition)
358+
}
359+
}
360+
else {
361+
imageView.layer.removeAllAnimations()
362+
}
363+
imageView.image = image
364+
}
365+
}
366+
}
367+
#endif
368+
369+
#if os(macOS)
370+
371+
extension Reactive where Base: NSImageView {
372+
373+
/// Bindable sink for `image` property.
374+
///
375+
/// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
376+
@available(*, deprecated, renamed: "image")
377+
public func image(transitionType: String? = nil) -> Binder<NSImage?> {
378+
return Binder(self.base) { control, value in
379+
if let transitionType = transitionType {
380+
if value != nil {
381+
let transition = CATransition()
382+
transition.duration = 0.25
383+
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
384+
transition.type = transitionType
385+
control.layer?.add(transition, forKey: kCATransition)
386+
}
387+
}
388+
else {
389+
control.layer?.removeAllAnimations()
390+
}
391+
control.image = value
392+
}
393+
}
394+
}
395+
#endif

RxCocoa/iOS/UIImageView+Rx.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,7 @@ extension Reactive where Base: UIImageView {
1717

1818
/// Bindable sink for `image` property.
1919
public var image: Binder<UIImage?> {
20-
return image(transitionType: nil)
21-
}
22-
23-
/// Bindable sink for `image` property.
24-
25-
/// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
26-
public func image(transitionType: String? = nil) -> Binder<UIImage?> {
2720
return Binder(base) { imageView, image in
28-
if let transitionType = transitionType {
29-
if image != nil {
30-
let transition = CATransition()
31-
transition.duration = 0.25
32-
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
33-
transition.type = transitionType
34-
imageView.layer.add(transition, forKey: kCATransition)
35-
}
36-
}
37-
else {
38-
imageView.layer.removeAllAnimations()
39-
}
4021
imageView.image = image
4122
}
4223
}

RxCocoa/macOS/NSImageView+Rx.swift

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,8 @@ extension Reactive where Base: NSImageView {
1717

1818
/// Bindable sink for `image` property.
1919
public var image: Binder<NSImage?> {
20-
return image(transitionType: nil)
21-
}
22-
23-
/// Bindable sink for `image` property.
24-
///
25-
/// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
26-
public func image(transitionType: String? = nil) -> Binder<NSImage?> {
27-
return Binder(self.base) { control, value in
28-
if let transitionType = transitionType {
29-
if value != nil {
30-
let transition = CATransition()
31-
transition.duration = 0.25
32-
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
33-
transition.type = transitionType
34-
control.layer?.add(transition, forKey: kCATransition)
35-
}
36-
}
37-
else {
38-
control.layer?.removeAllAnimations()
39-
}
40-
control.image = value
20+
return Binder(base) { imageView, image in
21+
imageView.image = image
4122
}
4223
}
4324
}

0 commit comments

Comments
 (0)