Skip to content

Commit

Permalink
feat: supports Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Dec 18, 2024
1 parent 5486180 commit a9672b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ let package = Package(
.target(
name: "CropImage",
dependencies: [])
]
],
swiftLanguageVersions: [.version("6"), .v5]
)
14 changes: 7 additions & 7 deletions Sources/CropImage/CropImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View {
/// - scale: The scale 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``.
public typealias ControlClosure<Controls> = (
public typealias ControlClosure = (
_ offset: Binding<CGSize>,
_ scale: Binding<CGFloat>,
_ rotation: Binding<Angle>,
Expand All @@ -30,7 +30,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View {
///
/// - Parameters:
/// - 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.
public enum CropError: Error {
Expand Down Expand Up @@ -66,17 +66,17 @@ public struct CropImageView<Controls: View, CutHole: View>: View {
///
/// The error should be a ``CropError``.
public var onCrop: (Result<PlatformImage, Error>) -> Void
var controls: ControlClosure<Controls>
var cutHole: CutHoleClosure<CutHole>
var controls: ControlClosure
var cutHole: CutHoleClosure
/// Create a ``CropImageView`` with a custom controls view and a custom cut hole.
public init(
image: PlatformImage,
targetSize: CGSize,
targetScale: CGFloat = 1,
fulfillTargetFrame: Bool = true,
onCrop: @escaping (Result<PlatformImage, Error>) -> Void,
@ViewBuilder controls: @escaping ControlClosure<Controls>,
@ViewBuilder cutHole: @escaping CutHoleClosure<CutHole>
@ViewBuilder controls: @escaping ControlClosure,
@ViewBuilder cutHole: @escaping CutHoleClosure
) {
self.image = image
self.targetSize = targetSize
Expand All @@ -92,7 +92,7 @@ public struct CropImageView<Controls: View, CutHole: View>: View {
targetScale: CGFloat = 1,
fulfillTargetFrame: Bool = true,
onCrop: @escaping (Result<PlatformImage, Error>) -> Void,
@ViewBuilder controls: @escaping ControlClosure<Controls>
@ViewBuilder controls: @escaping ControlClosure
) where CutHole == DefaultCutHoleView {
self.image = image
self.targetSize = targetSize
Expand Down

0 comments on commit a9672b8

Please sign in to comment.