mirror of
https://github.com/laosb/CropImage.git
synced 2025-04-30 23:51:08 +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(
|
||||
offset: $offset,
|
||||
scale: $scale,
|
||||
|
@ -152,20 +152,31 @@ public struct CropImageView<Controls: View>: View {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue