Restored Link long pressing (#2449)

This commit is contained in:
Mauro
2024-02-12 10:42:45 +01:00
committed by GitHub
parent 84703806d0
commit 316e351dbb
3 changed files with 25 additions and 4 deletions
@@ -30,7 +30,7 @@ struct LongPressWithFeedback: ViewModifier {
.shadow(color: .black.opacity(isLongPressing ? 0.1 : 0.0), radius: isLongPressing ? 3 : 0)
.scaleEffect(x: isLongPressing ? 1.05 : 1,
y: isLongPressing ? 1.05 : 1)
.animation(.spring(response: 0.5).delay(isLongPressing ? 0.1 : 0).disabledDuringTests(),
.animation(.spring(response: 0.7).delay(isLongPressing ? 0.1 : 0).disabledDuringTests(),
value: isLongPressing)
// The minimum duration here doesn't actually invoke the perform block when elapsed (thus
// the implementation below) but it does cancel other system gestures e.g. swipe to reply
@@ -45,7 +45,8 @@ struct LongPressWithFeedback: ViewModifier {
feedbackGenerator.prepare()
triggerTask = Task {
try? await Task.sleep(for: .seconds(0.35))
// The wait time needs to be at least 0.5 seconds or the long press gesture will take precedence over long pressing links.
try? await Task.sleep(for: .seconds(0.5))
if Task.isCancelled { return }