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,20 +152,31 @@ public struct CropImageView<Controls: View>: View {
image: image, image: image,
initialImageSize: initialImageSize initialImageSize: initialImageSize
) )
.overlay( ZStack { }
RectHoleShape(size: targetSize)
.fill(style: FillStyle(eoFill: true)) var rectHole: some View {
.foregroundColor(.black.opacity(0.6)) RectHoleShape(size: targetSize)
.animation(.default, value: targetSize) .fill(style: FillStyle(eoFill: true))
.allowsHitTesting(false) .foregroundColor(.black.opacity(0.6))
controls($offset, $scale, $rotation) { .animation(.default, value: targetSize)
do { .allowsHitTesting(false)
onCrop(.success(try crop())) }
} catch {
onCrop(.failure(error)) @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)
} }
} }