mirror of
				https://github.com/laosb/CropImage.git
				synced 2025-10-30 22:01:38 +00:00 
			
		
		
		
	feat: supports Swift 6
This commit is contained in:
		
							parent
							
								
									54861801e6
								
							
						
					
					
						commit
						a9672b8a33
					
				
					 2 changed files with 9 additions and 8 deletions
				
			
		|  | @ -26,5 +26,6 @@ let package = Package( | ||||||
|         .target( |         .target( | ||||||
|             name: "CropImage", |             name: "CropImage", | ||||||
|             dependencies: []) |             dependencies: []) | ||||||
|     ] |     ], | ||||||
|  |     swiftLanguageVersions: [.version("6"), .v5] | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View { | ||||||
|     ///   - scale: The scale binding of the image. |     ///   - scale: The scale binding of the image. | ||||||
|     ///   - rotation: The rotation binding of the image. |     ///   - rotation: The rotation binding of the image. | ||||||
|     ///   - crop: An async function to trigger crop action. Result will be delivered via ``onCrop``. |     ///   - crop: An async function to trigger crop action. Result will be delivered via ``onCrop``. | ||||||
|     public typealias ControlClosure<Controls> = ( |     public typealias ControlClosure = ( | ||||||
|         _ offset: Binding<CGSize>, |         _ offset: Binding<CGSize>, | ||||||
|         _ scale: Binding<CGFloat>, |         _ scale: Binding<CGFloat>, | ||||||
|         _ rotation: Binding<Angle>, |         _ rotation: Binding<Angle>, | ||||||
|  | @ -30,7 +30,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View { | ||||||
|     /// |     /// | ||||||
|     /// - Parameters: |     /// - Parameters: | ||||||
|     ///   - targetSize: The size of the cut hole. |     ///   - targetSize: The size of the cut hole. | ||||||
|     public typealias CutHoleClosure<CutHole> = (_ targetSize: CGSize) -> CutHole |     public typealias CutHoleClosure = (_ targetSize: CGSize) -> CutHole | ||||||
| 
 | 
 | ||||||
|     /// Errors that could happen during the cropping process. |     /// Errors that could happen during the cropping process. | ||||||
|     public enum CropError: Error { |     public enum CropError: Error { | ||||||
|  | @ -66,8 +66,8 @@ public struct CropImageView<Controls: View, CutHole: View>: View { | ||||||
|     /// |     /// | ||||||
|     /// The error should be a ``CropError``. |     /// The error should be a ``CropError``. | ||||||
|     public var onCrop: (Result<PlatformImage, Error>) -> Void |     public var onCrop: (Result<PlatformImage, Error>) -> Void | ||||||
|     var controls: ControlClosure<Controls> |     var controls: ControlClosure | ||||||
|     var cutHole: CutHoleClosure<CutHole> |     var cutHole: CutHoleClosure | ||||||
|     /// Create a ``CropImageView`` with a custom controls view and a custom cut hole. |     /// Create a ``CropImageView`` with a custom controls view and a custom cut hole. | ||||||
|     public init( |     public init( | ||||||
|         image: PlatformImage, |         image: PlatformImage, | ||||||
|  | @ -75,8 +75,8 @@ public struct CropImageView<Controls: View, CutHole: View>: View { | ||||||
|         targetScale: CGFloat = 1, |         targetScale: CGFloat = 1, | ||||||
|         fulfillTargetFrame: Bool = true, |         fulfillTargetFrame: Bool = true, | ||||||
|         onCrop: @escaping (Result<PlatformImage, Error>) -> Void, |         onCrop: @escaping (Result<PlatformImage, Error>) -> Void, | ||||||
|         @ViewBuilder controls: @escaping ControlClosure<Controls>, |         @ViewBuilder controls: @escaping ControlClosure, | ||||||
|         @ViewBuilder cutHole: @escaping CutHoleClosure<CutHole> |         @ViewBuilder cutHole: @escaping CutHoleClosure | ||||||
|     ) { |     ) { | ||||||
|         self.image = image |         self.image = image | ||||||
|         self.targetSize = targetSize |         self.targetSize = targetSize | ||||||
|  | @ -92,7 +92,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View { | ||||||
|         targetScale: CGFloat = 1, |         targetScale: CGFloat = 1, | ||||||
|         fulfillTargetFrame: Bool = true, |         fulfillTargetFrame: Bool = true, | ||||||
|         onCrop: @escaping (Result<PlatformImage, Error>) -> Void, |         onCrop: @escaping (Result<PlatformImage, Error>) -> Void, | ||||||
|         @ViewBuilder controls: @escaping ControlClosure<Controls> |         @ViewBuilder controls: @escaping ControlClosure | ||||||
|     ) where CutHole == DefaultCutHoleView { |     ) where CutHole == DefaultCutHoleView { | ||||||
|         self.image = image |         self.image = image | ||||||
|         self.targetSize = targetSize |         self.targetSize = targetSize | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shibo Lyu
						Shibo Lyu