From bfee9ea1241949c76bd55b4b1b65586b9840c6c4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 23 Feb 2025 00:15:35 -0500 Subject: [PATCH] Fix poll button animation being weird on iOS 15 --- .../ComposeUI/Views/DraftContentEditor.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift index 0d25936c5a..cfed3e4370 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift @@ -87,11 +87,26 @@ private struct LanguageButtonStyle: ButtonStyle { .padding(.vertical, 2) .padding(.horizontal, 4) .background(.tint.opacity(configuration.isPressed ? 0.15 : 0.2), in: RoundedRectangle(cornerRadius: 3)) - .animation(.linear(duration: 0.1), value: configuration.isPressed) + .modifier(LanguageButtonStyleAnimationModifier(isPressed: configuration.isPressed)) .padding(2) } } +@available(iOS, obsoleted: 16.0) +private struct LanguageButtonStyleAnimationModifier: ViewModifier { + let isPressed: Bool + + func body(content: Content) -> some View { + // This looks weird while the button is being pressed on iOS 15 for some reason. + if #available(iOS 16.0, *) { + content + .animation(.linear(duration: 0.1), value: isPressed) + } else { + content + } + } +} + private struct TogglePollButton: View { @ObservedObject var draft: Draft @FocusState.Binding var focusedField: FocusableField?