Skip to content

Commit e577495

Browse files
committed
Add UIViewPropertyAnimator; Fill out UIView
1 parent c94d5b2 commit e577495

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "mxcl/PromiseKit" "5.0.0-beta.5"
1+
github "mxcl/PromiseKit" "5.0.0"

Sources/UIView+Promise.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import PromiseKit
1818

1919
import PromiseKit
2020
*/
21-
extension UIView {
21+
public extension UIView {
2222
/**
2323
Animate changes to one or more views using the specified duration, delay,
2424
options, and completion handler.
@@ -40,11 +40,23 @@ extension UIView {
4040
- Returns: A promise that fulfills with a boolean NSNumber indicating
4141
whether or not the animations actually finished.
4242
*/
43-
public class func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
43+
static func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
4444
return Guarantee(.pending) { animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: $0) }
4545
}
4646

47-
public class func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping damping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
47+
static func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping damping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
4848
return Guarantee(.pending) { animate(withDuration: duration, delay: delay, usingSpringWithDamping: damping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations, completion: $0) }
4949
}
50+
51+
static func transition(_: PMKNamespacer, with view: UIView, duration: TimeInterval, options: UIViewAnimationOptions = [], animations: (() -> Void)?) -> Guarantee<Bool> {
52+
return Guarantee(.pending) { transition(with: view, duration: duration, options: options, animations: animations, completion: $0) }
53+
}
54+
55+
static func transition(_: PMKNamespacer, from: UIView, to: UIView, duration: TimeInterval, options: UIViewAnimationOptions = []) -> Guarantee<Bool> {
56+
return Guarantee(.pending) { transition(from: from, to: to, duration: duration, options: options, completion: $0) }
57+
}
58+
59+
static func perform(_: PMKNamespacer, animation: UISystemAnimation, on views: [UIView], options: UIViewAnimationOptions = [], animations: (() -> Void)?) -> Guarantee<Bool> {
60+
return Guarantee(.pending) { perform(animation, on: views, options: options, animations: animations, completion: $0) }
61+
}
5062
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import PromiseKit
2+
import UIKit
3+
4+
public extension UIViewPropertyAnimator {
5+
func startAnimation(_: PMKNamespacer) -> Guarantee<UIViewAnimatingPosition> {
6+
return Guarantee(.pending) {
7+
addCompletion($0)
8+
startAnimation()
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)