diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..5fa8641 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "PromiseKit", + "repositoryURL": "https://github.com/mxcl/PromiseKit.git", + "state": { + "branch": null, + "revision": "f14f16cc2602afec1030e4f492100d6d43dca544", + "version": "6.13.1" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..f490872 --- /dev/null +++ b/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:5.0 + +import PackageDescription + +let pkg = Package(name: "PMKUIKit") +pkg.products = [ + .library(name: "PMKUIKit", targets: ["PMKUIKit"]), +] +pkg.dependencies = [ + .package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.8.3") +] +pkg.swiftLanguageVersions = [.v4, .v4_2, .v5] + +let target: Target = .target(name: "PMKUIKit") +target.path = "Sources" +target.exclude = ["UIView", "UIViewController"].flatMap { + ["\($0)+AnyPromise.m", "\($0)+AnyPromise.h"] +} +target.exclude.append("PMKUIKit.h") + +target.dependencies = [ + "PromiseKit" +] + +pkg.targets = [target] + +pkg.platforms = [ + .iOS(.v8) +] diff --git a/Sources/UIImagePickerController+Promise.swift b/Sources/UIImagePickerController+Promise.swift index d112c64..463ff8d 100644 --- a/Sources/UIImagePickerController+Promise.swift +++ b/Sources/UIImagePickerController+Promise.swift @@ -5,10 +5,21 @@ import UIKit #if !os(tvOS) +public struct AnimationOptions: OptionSet { + public let rawValue: Int + + public static let appear = AnimationOptions(rawValue: 1 << 1) + public static let disappear = AnimationOptions(rawValue: 1 << 2) + + public init(rawValue: Int) { + self.rawValue = rawValue + } +} + extension UIViewController { #if swift(>=4.2) /// Presents the UIImagePickerController, resolving with the user action. - public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[UIImagePickerController.InfoKey: Any]> { + public func promise(_ vc: UIImagePickerController, animate: AnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[UIImagePickerController.InfoKey: Any]> { let animated = animate.contains(.appear) let proxy = UIImagePickerControllerProxy() vc.delegate = proxy @@ -19,7 +30,7 @@ extension UIViewController { } #else /// Presents the UIImagePickerController, resolving with the user action. - public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[String: Any]> { + public func promise(_ vc: UIImagePickerController, animate: AnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[String: Any]> { let animated = animate.contains(.appear) let proxy = UIImagePickerControllerProxy() vc.delegate = proxy