aboutsummaryrefslogtreecommitdiff
path: root/Sources/SwiftyCrop/SwiftyCrop.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sources/SwiftyCrop/SwiftyCrop.swift')
-rw-r--r--Sources/SwiftyCrop/SwiftyCrop.swift21
1 files changed, 20 insertions, 1 deletions
diff --git a/Sources/SwiftyCrop/SwiftyCrop.swift b/Sources/SwiftyCrop/SwiftyCrop.swift
index 22268a9..bb6164c 100644
--- a/Sources/SwiftyCrop/SwiftyCrop.swift
+++ b/Sources/SwiftyCrop/SwiftyCrop.swift
@@ -11,11 +11,17 @@ import SwiftUI
/// - onComplete: A closure that's called when the cropping is complete. This closure returns the cropped `UIImage?`.
/// If an error occurs the return value is nil.
public struct SwiftyCropView: View {
- private let imageToCrop: UIImage
private let maskShape: MaskShape
private let configuration: SwiftyCropConfiguration
+ #if canImport(UIKit)
+ private let imageToCrop: UIImage
private let onComplete: (UIImage?) -> Void
+ #elseif canImport(AppKit)
+ private let imageToCrop: NSImage
+ private let onComplete: (NSImage?) -> Void
+ #endif
+ #if canImport(UIKit)
public init(
imageToCrop: UIImage,
maskShape: MaskShape,
@@ -27,6 +33,19 @@ public struct SwiftyCropView: View {
self.configuration = configuration
self.onComplete = onComplete
}
+ #elseif canImport(AppKit)
+ public init(
+ imageToCrop: NSImage,
+ maskShape: MaskShape,
+ configuration: SwiftyCropConfiguration = SwiftyCropConfiguration(),
+ onComplete: @escaping (NSImage?) -> Void
+ ) {
+ self.imageToCrop = imageToCrop
+ self.maskShape = maskShape
+ self.configuration = configuration
+ self.onComplete = onComplete
+ }
+ #endif
public var body: some View {
CropView(