Drop view highlighting for iOS 17 to fix the problem with scrolling

This commit is contained in:
Maciej Gomółka
2025-06-16 11:01:38 +00:00
committed by MargeBot
parent 9dd5804f79
commit 18b2a66166
@@ -45,9 +45,31 @@ public struct LongPressFormBigButton: View {
symbol: .none
)
.textSelection(.enabled)
.onLongPressGesture(perform: {}, onPressingChanged: { changed in isPressed = changed })
.conditionalLongPress(onPressingChanged: { changed in isPressed = changed })
.onTapGesture(perform: onTap)
.background(isPressed && hasAccentTextColor ? DS.Color.InteractionWeak.pressed : .clear)
.background(DS.Color.BackgroundInverted.secondary)
}
}
private extension View {
func conditionalLongPress(onPressingChanged: ((Bool) -> Void)?) -> some View {
modifier(ConditionalLongPress(onPressingChanged: onPressingChanged))
}
}
private struct ConditionalLongPress: ViewModifier {
let onPressingChanged: ((Bool) -> Void)?
func body(content: Content) -> some View {
if #available(iOS 18, *) {
content
.onLongPressGesture(perform: {}, onPressingChanged: onPressingChanged)
} else {
content
}
}
}