mirror of
https://github.com/laosb/CropImage.git
synced 2025-05-01 08:01:09 +00:00
fix: Overflow.
This commit is contained in:
parent
1f3cf71c83
commit
8a4b71757c
1 changed files with 25 additions and 14 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue