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.swift24
1 files changed, 18 insertions, 6 deletions
diff --git a/Sources/SwiftyCrop/SwiftyCrop.swift b/Sources/SwiftyCrop/SwiftyCrop.swift
index ab252e6..0de933d 100644
--- a/Sources/SwiftyCrop/SwiftyCrop.swift
+++ b/Sources/SwiftyCrop/SwiftyCrop.swift
@@ -9,13 +9,25 @@ import SwiftUI
/// - maskShape: The shape of the mask used for cropping.
/// - configuration: The configuration for the cropping behavior. If nothing is specified, the default is used.
/// - 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.
-struct SwiftyCropView: View {
- let imageToCrop: UIImage
- let maskShape: MaskShape
- let configuration: SwiftyCropConfiguration = SwiftyCropConfiguration()
- let onComplete: (UIImage?) -> Void
+public struct SwiftyCropView: View {
+ private let imageToCrop: UIImage
+ private let maskShape: MaskShape
+ private let configuration: SwiftyCropConfiguration
+ private let onComplete: (UIImage?) -> Void
- var body: some View {
+ public init(
+ imageToCrop: UIImage,
+ maskShape: MaskShape,
+ configuration: SwiftyCropConfiguration = SwiftyCropConfiguration(),
+ onComplete: @escaping (UIImage?) -> Void
+ ) {
+ self.imageToCrop = imageToCrop
+ self.maskShape = maskShape
+ self.configuration = configuration
+ self.onComplete = onComplete
+ }
+
+ public var body: some View {
CropView(
image: imageToCrop,
maskShape: maskShape,