Add double tap gesture and fix bugs

Changlog-Added: Image double-tap gesture
Closes: #397
This commit is contained in:
OlegAba
2023-01-25 16:25:55 -05:00
committed by William Casarin
parent 1baae90beb
commit 5de745fb19
4 changed files with 179 additions and 66 deletions

View File

@@ -11,13 +11,17 @@ struct SwipeToDismissModifier: ViewModifier {
let minDistance: CGFloat?
var onDismiss: () -> Void
@State private var offset: CGSize = .zero
@GestureState private var viewOffset: CGSize = .zero
func body(content: Content) -> some View {
content
.offset(y: offset.height)
.animation(.interactiveSpring(), value: offset)
.offset(y: viewOffset.height)
.animation(.interactiveSpring(), value: viewOffset)
.simultaneousGesture(
DragGesture(minimumDistance: minDistance ?? 10)
.updating($viewOffset, body: { value, gestureState, transaction in
gestureState = CGSize(width: value.location.x - value.startLocation.x, height: value.location.y - value.startLocation.y)
})
.onChanged { gesture in
if gesture.translation.width < 50 {
offset = gesture.translation