Skip to content

Commit 752e435

Browse files
committed
Fix ambiguity for UIView.animate(withDuration:)
Fixes #2
1 parent 534b62b commit 752e435

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

PMKUIKit.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
6304D6FE1D5F986A00CE6C99 /* PMKUIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6304D6FD1D5F986A00CE6C99 /* PMKUIKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
1111
630B2E161D5D0B3200DC10E9 /* TestUIImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 630B2DF71D5D0AD400DC10E9 /* TestUIImagePickerController.swift */; };
12+
6332142B1D83CD17009F67CE /* TestUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6332142A1D83CD17009F67CE /* TestUIView.swift */; };
1213
637E2C7D1D5C2E0B0043E370 /* PMKAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C701D5C2E0B0043E370 /* PMKAlertController.swift */; };
1314
637E2C841D5C2E0B0043E370 /* UIView+AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 637E2C771D5C2E0B0043E370 /* UIView+AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
1415
637E2C851D5C2E0B0043E370 /* UIView+AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C781D5C2E0B0043E370 /* UIView+AnyPromise.m */; };
@@ -78,6 +79,7 @@
7879
630B2DF51D5D0AD400DC10E9 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "UITests/Default-568h@2x.png"; sourceTree = "<group>"; };
7980
630B2DF71D5D0AD400DC10E9 /* TestUIImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIImagePickerController.swift; path = UITests/TestUIImagePickerController.swift; sourceTree = "<group>"; };
8081
630B2E131D5D0AF500DC10E9 /* PMKUIUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKUIUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
82+
6332142A1D83CD17009F67CE /* TestUIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIView.swift; path = Tests/TestUIView.swift; sourceTree = SOURCE_ROOT; };
8183
637E2C701D5C2E0B0043E370 /* PMKAlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PMKAlertController.swift; path = Sources/PMKAlertController.swift; sourceTree = SOURCE_ROOT; };
8284
637E2C771D5C2E0B0043E370 /* UIView+AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+AnyPromise.h"; path = "Sources/UIView+AnyPromise.h"; sourceTree = SOURCE_ROOT; };
8385
637E2C781D5C2E0B0043E370 /* UIView+AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+AnyPromise.m"; path = "Sources/UIView+AnyPromise.m"; sourceTree = SOURCE_ROOT; };
@@ -187,11 +189,12 @@
187189
637E2C8E1D5C2E720043E370 /* TestUIImagePickerController.swift */,
188190
637E2C8F1D5C2E720043E370 /* TestUIViewController.m */,
189191
637E2C901D5C2E720043E370 /* TestUIViewController.swift */,
192+
6332142A1D83CD17009F67CE /* TestUIView.swift */,
190193
637E2C9A1D5C2F600043E370 /* infrastructure.swift */,
191194
);
192195
name = Tests;
193196
path = PMKTests/NS;
194-
sourceTree = "<group>";
197+
sourceTree = SOURCE_ROOT;
195198
};
196199
/* End PBXGroup section */
197200

@@ -406,6 +409,7 @@
406409
637E2C971D5C2E720043E370 /* TestUIViewController.swift in Sources */,
407410
637E2C961D5C2E720043E370 /* TestUIViewController.m in Sources */,
408411
637E2C9B1D5C2F600043E370 /* infrastructure.swift in Sources */,
412+
6332142B1D83CD17009F67CE /* TestUIView.swift in Sources */,
409413
);
410414
runOnlyForDeploymentPostprocessing = 0;
411415
};

Sources/UIView+Promise.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ extension UIView {
2323
Animate changes to one or more views using the specified duration, delay,
2424
options, and completion handler.
2525

26-
@param duration The total duration of the animations, measured in
26+
- Parameter duration: The total duration of the animations, measured in
2727
seconds. If you specify a negative value or 0, the changes are made
2828
without animating them.
2929

30-
@param delay The amount of time (measured in seconds) to wait before
30+
- Parameter delay: The amount of time (measured in seconds) to wait before
3131
beginning the animations. Specify a value of 0 to begin the animations
3232
immediately.
3333

34-
@param options A mask of options indicating how you want to perform the
34+
- Parameter options: A mask of options indicating how you want to perform the
3535
animations. For a list of valid constants, see UIViewAnimationOptions.
3636

37-
@param animations A block object containing the changes to commit to the
37+
- Parameter animations: A block object containing the changes to commit to the
3838
views.
3939

40-
@return A promise that fulfills with a boolean NSNumber indicating
40+
- Returns: A promise that fulfills with a boolean NSNumber indicating
4141
whether or not the animations actually finished.
4242
*/
43-
public class func animate(withDuration duration: TimeInterval = 0.3, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Promise<Bool> {
43+
public class func promise(animateWithDuration duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Promise<Bool> {
4444
return PromiseKit.wrap { animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: $0) }
4545
}
4646
}

Tests/TestUIView.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import PromiseKit
2+
import PMKUIKit
3+
import XCTest
4+
import UIKit
5+
6+
class UIViewTests: XCTestCase {
7+
func test() {
8+
let ex1 = expectation(description: "")
9+
let ex2 = expectation(description: "")
10+
11+
UIView.promise(animateWithDuration: 0.1) {
12+
ex1.fulfill()
13+
}.then { _ -> Void in
14+
ex2.fulfill()
15+
}
16+
17+
waitForExpectations(timeout: 1)
18+
}
19+
}

0 commit comments

Comments
 (0)