fix: Overflow.

This commit is contained in:
Shibo Lyu 2023-08-10 18:04:13 +08:00
parent 1f3cf71c83
commit 8a4b71757c

View file

@ -144,7 +144,7 @@ public struct CropImageView<Controls: View>: View {
} }
} }
public var body: some View { var underlyingImage: some View {
UnderlyingImageView( UnderlyingImageView(
offset: $offset, offset: $offset,
scale: $scale, scale: $scale,
@ -152,12 +152,17 @@ public struct CropImageView<Controls: View>: View {
image: image, image: image,
initialImageSize: initialImageSize initialImageSize: initialImageSize
) )
.overlay( ZStack { }
var rectHole: some View {
RectHoleShape(size: targetSize) RectHoleShape(size: targetSize)
.fill(style: FillStyle(eoFill: true)) .fill(style: FillStyle(eoFill: true))
.foregroundColor(.black.opacity(0.6)) .foregroundColor(.black.opacity(0.6))
.animation(.default, value: targetSize) .animation(.default, value: targetSize)
.allowsHitTesting(false) .allowsHitTesting(false)
}
@MainActor var control: some View {
controls($offset, $scale, $rotation) { controls($offset, $scale, $rotation) {
do { do {
onCrop(.success(try crop())) onCrop(.success(try crop()))
@ -165,7 +170,13 @@ public struct CropImageView<Controls: View>: View {
onCrop(.failure(error)) onCrop(.failure(error))
} }
} }
} ) }
public var body: some View {
underlyingImage
.clipped()
.overlay(rectHole)
.overlay(control)
} }
} }