Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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)
]
15 changes: 13 additions & 2 deletions Sources/UIImagePickerController+Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import UIKit

#if !os(tvOS)

public struct AnimationOptions: OptionSet {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @lstomberg
Why do you need to re-define PMKAnimationOptions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably for SwiftPM since it won't get the objective-c portions

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
Expand All @@ -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
Expand Down