mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 06:05:20 +00:00
Reblur images via swipe
This commit is contained in:
@@ -105,8 +105,7 @@ struct BlockRevealImageView: View {
|
|||||||
isBlurred = initiallyBlurred
|
isBlurred = initiallyBlurred
|
||||||
loadImage()
|
loadImage()
|
||||||
}
|
}
|
||||||
.gesture(gestureHandler)
|
.gesture(mainGesture)
|
||||||
.simultaneousGesture(longPressGesture)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func loadImage() {
|
private func loadImage() {
|
||||||
@@ -124,7 +123,7 @@ struct BlockRevealImageView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var gestureHandler: some Gesture {
|
private var mainGesture: some Gesture {
|
||||||
let doubleTap = TapGesture(count: 2).onEnded {
|
let doubleTap = TapGesture(count: 2).onEnded {
|
||||||
guard !isSending else { return }
|
guard !isSending else { return }
|
||||||
onDelete?()
|
onDelete?()
|
||||||
@@ -139,18 +138,18 @@ struct BlockRevealImageView: View {
|
|||||||
onOpen?()
|
onOpen?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return doubleTap.exclusively(before: singleTap)
|
let swipe = DragGesture(minimumDistance: 20, coordinateSpace: .local).onEnded { value in
|
||||||
}
|
|
||||||
|
|
||||||
private var longPressGesture: some Gesture {
|
|
||||||
LongPressGesture(minimumDuration: 0.4).onEnded { _ in
|
|
||||||
guard !isSending else { return }
|
guard !isSending else { return }
|
||||||
|
let horizontal = value.translation.width
|
||||||
|
let vertical = value.translation.height
|
||||||
|
guard abs(horizontal) > abs(vertical), abs(horizontal) > 40 else { return }
|
||||||
if !isBlurred {
|
if !isBlurred {
|
||||||
withAnimation(.easeInOut(duration: 0.2)) {
|
withAnimation(.easeInOut(duration: 0.2)) {
|
||||||
isBlurred = true
|
isBlurred = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return doubleTap.exclusively(before: singleTap).simultaneously(with: swipe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user