Update long press gesture animation. (#1195)

This commit is contained in:
Doug 2023-06-28 16:06:43 +01:00 committed by GitHub
parent e4959ff156
commit fbb17e9288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -24,9 +24,12 @@ struct LongPressWithFeedback: ViewModifier {
func body(content: Content) -> some View {
content
.scaleEffect(x: isLongPressing ? 0.93 : 1,
y: isLongPressing ? 0.93 : 1)
.animation(isLongPressing ? .spring(response: 0.8).delay(0.2) : .spring(response: 0.2),
.compositingGroup() // Apply the shadow to the view as a whole.
.shadow(color: .black.opacity(0.2), radius: isLongPressing ? 12 : 0)
.shadow(color: .black.opacity(0.1), radius: isLongPressing ? 3 : 0)
.scaleEffect(x: isLongPressing ? 1.05 : 1,
y: isLongPressing ? 1.05 : 1)
.animation(isLongPressing ? .spring(response: 1.5).delay(0.2) : .spring(response: 0.5),
value: isLongPressing)
.onLongPressGesture(minimumDuration: 0.25) {
action()
@ -90,6 +93,7 @@ struct FakeContextMenu_Previews: PreviewProvider {
.padding(.horizontal, 12)
.padding(.vertical, 4)
.background(Color.compound._bgBubbleOutgoing, in: RoundedRectangle(cornerRadius: 12))
.contentShape(.contextMenuPreview, RoundedRectangle(cornerRadius: 12))
.onTapGesture { /* Fix long press gesture blocking the scroll view */ }
}
}

View File

@ -0,0 +1 @@
Update long press gesture animation