Skip to content

Commit

Permalink
fix: Overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Aug 10, 2023
1 parent 1f3cf71 commit 8a4b717
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions Sources/CropImage/CropImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,39 @@ public struct CropImageView<Controls: View>: View {
}
}

public var body: some View {
var underlyingImage: some View {
UnderlyingImageView(
offset: $offset,
scale: $scale,
rotation: $rotation,
image: image,
initialImageSize: initialImageSize
)
.overlay( ZStack {
RectHoleShape(size: targetSize)
.fill(style: FillStyle(eoFill: true))
.foregroundColor(.black.opacity(0.6))
.animation(.default, value: targetSize)
.allowsHitTesting(false)
controls($offset, $scale, $rotation) {
do {
onCrop(.success(try crop()))
} catch {
onCrop(.failure(error))
}
}

var rectHole: some View {
RectHoleShape(size: targetSize)
.fill(style: FillStyle(eoFill: true))
.foregroundColor(.black.opacity(0.6))
.animation(.default, value: targetSize)
.allowsHitTesting(false)
}

@MainActor var control: some View {
controls($offset, $scale, $rotation) {
do {
onCrop(.success(try crop()))
} catch {
onCrop(.failure(error))
}
} )
}
}

public var body: some View {
underlyingImage
.clipped()
.overlay(rectHole)
.overlay(control)
}
}

Expand Down

0 comments on commit 8a4b717

Please sign in to comment.