Prevent the longPressWithFeedback gesture from adding a shadow to its content before the gesture is triggered

This commit is contained in:
Stefan Ceriu
2023-06-30 12:33:14 +03:00
committed by Stefan Ceriu
parent 6dc96295f6
commit 4a72ca1b08
@@ -25,8 +25,8 @@ struct LongPressWithFeedback: ViewModifier {
func body(content: Content) -> some View { func body(content: Content) -> some View {
content content
.compositingGroup() // Apply the shadow to the view as a whole. .compositingGroup() // Apply the shadow to the view as a whole.
.shadow(color: .black.opacity(0.2), radius: isLongPressing ? 12 : 0) .shadow(color: .black.opacity(isLongPressing ? 0.2 : 0.0), radius: isLongPressing ? 12 : 0)
.shadow(color: .black.opacity(0.1), radius: isLongPressing ? 3 : 0) .shadow(color: .black.opacity(isLongPressing ? 0.1 : 0.0), radius: isLongPressing ? 3 : 0)
.scaleEffect(x: isLongPressing ? 1.05 : 1, .scaleEffect(x: isLongPressing ? 1.05 : 1,
y: isLongPressing ? 1.05 : 1) y: isLongPressing ? 1.05 : 1)
.animation(isLongPressing ? .spring(response: 1.5).delay(0.2) : .spring(response: 0.5), .animation(isLongPressing ? .spring(response: 1.5).delay(0.2) : .spring(response: 0.5),