From 18b2a661663efd63b2a5d4cf30c9122d6f2e80fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Gomo=CC=81=C5=82ka?= Date: Mon, 16 Jun 2025 11:02:15 +0200 Subject: [PATCH] Drop view highlighting for iOS 17 to fix the problem with scrolling --- .../Sources/LongPressFormBigButton.swift | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Modules/InboxCoreUI/Sources/LongPressFormBigButton.swift b/Modules/InboxCoreUI/Sources/LongPressFormBigButton.swift index 767c163f48..6f11f062a1 100644 --- a/Modules/InboxCoreUI/Sources/LongPressFormBigButton.swift +++ b/Modules/InboxCoreUI/Sources/LongPressFormBigButton.swift @@ -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 + } + } + +}