diff options
Diffstat (limited to 'Sources')
-rw-r--r-- | Sources/SwiftyCrop/Models/MaskShape.swift | 2 | ||||
-rw-r--r-- | Sources/SwiftyCrop/Models/SwiftyCropConfiguration.swift (renamed from Sources/SwiftyCrop/Models/Configuration.swift) | 4 | ||||
-rw-r--r-- | Sources/SwiftyCrop/SwiftyCrop.swift | 24 | ||||
-rw-r--r-- | Sources/SwiftyCrop/View/CropView.swift | 6 |
4 files changed, 24 insertions, 12 deletions
diff --git a/Sources/SwiftyCrop/Models/MaskShape.swift b/Sources/SwiftyCrop/Models/MaskShape.swift index c4b1538..d20e722 100644 --- a/Sources/SwiftyCrop/Models/MaskShape.swift +++ b/Sources/SwiftyCrop/Models/MaskShape.swift @@ -1,3 +1,3 @@ -enum MaskShape { +public enum MaskShape { case circle, square } diff --git a/Sources/SwiftyCrop/Models/Configuration.swift b/Sources/SwiftyCrop/Models/SwiftyCropConfiguration.swift index bacdab0..cc3d47a 100644 --- a/Sources/SwiftyCrop/Models/Configuration.swift +++ b/Sources/SwiftyCrop/Models/SwiftyCropConfiguration.swift @@ -1,7 +1,7 @@ import CoreGraphics /// `SwiftyCropConfiguration` is a struct that defines the configuration for cropping behavior. -struct SwiftyCropConfiguration { +public struct SwiftyCropConfiguration { let maxMagnificationScale: CGFloat let maskRadius: CGFloat @@ -10,7 +10,7 @@ struct SwiftyCropConfiguration { /// - Parameters: /// - maxMagnificationScale: The maximum scale factor that the image can be magnified while cropping. Defaults to `4.0`. /// - maskRadius: The radius of the mask used for cropping. Defaults to `130`. - init(maxMagnificationScale: CGFloat = 4.0, maskRadius: CGFloat = 130) { + public init(maxMagnificationScale: CGFloat = 4.0, maskRadius: CGFloat = 130) { self.maxMagnificationScale = maxMagnificationScale self.maskRadius = maskRadius } 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, diff --git a/Sources/SwiftyCrop/View/CropView.swift b/Sources/SwiftyCrop/View/CropView.swift index 29cfb8a..3cb453a 100644 --- a/Sources/SwiftyCrop/View/CropView.swift +++ b/Sources/SwiftyCrop/View/CropView.swift @@ -31,7 +31,7 @@ struct CropView: View { var body: some View { VStack { - Text("interaction_instructions", tableName: localizableTableName) + Text("interaction_instructions", tableName: localizableTableName, bundle: .module) .font(.system(size: 16, weight: .regular)) .foregroundColor(.white) .padding(.top, 30) @@ -100,7 +100,7 @@ struct CropView: View { Button { dismiss() } label: { - Text("cancel_button", tableName: localizableTableName) + Text("cancel_button", tableName: localizableTableName, bundle: .module) } .foregroundColor(.white) @@ -110,7 +110,7 @@ struct CropView: View { onComplete(viewModel.crop(image)) dismiss() } label: { - Text("save_button", tableName: localizableTableName) + Text("save_button", tableName: localizableTableName, bundle: .module) } .foregroundColor(.white) } |