From 019a9920f04b781068cbef5202e508f3c8f64d23 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 20 Dec 2022 12:56:04 -0500 Subject: [PATCH] better animations? or at least different --- .../View/Content/MediaAltTextOverlay.swift | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift index 09aeaa9e0..1bab0bc24 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift @@ -27,16 +27,22 @@ struct MediaAltTextOverlay: View { .frame(width: 20, height: 20) } } - .transition(.scale(scale: 0.1, anchor: .bottomLeading)) .padding(8) - .frame(width: geom.size.width) - .fixedSize() - .matchedGeometryEffect(id: "background", in: namespace) + .matchedGeometryEffect(id: "background", in: namespace, properties: .position) + .transition( + .scale(scale: 0.2, anchor: .bottomLeading) + .combined(with: .opacity) + ) } else { Button("ALT") { showingAlt = true } - .fixedSize() - .buttonStyle(AltButtonStyle()) - .matchedGeometryEffect(id: "background", in: namespace) + .font(.caption.weight(.semibold)) + .padding(.horizontal, 8) + .padding(.vertical, 3) + .matchedGeometryEffect(id: "background", in: namespace, properties: .position) + .transition( + .scale(scale: 3, anchor: .trailing) + .combined(with: .opacity) + ) } } } @@ -50,7 +56,7 @@ struct MediaAltTextOverlay: View { .inset(by: -0.5) .stroke(lineWidth: 0.5) ) - .animation(.spring(response: 0.25), value: showingAlt) + .animation(.spring(response: 0.3), value: showingAlt) .frame(width: geom.size.width, height: geom.size.height, alignment: .bottomLeading) } .padding(.horizontal, 16) @@ -61,17 +67,6 @@ struct MediaAltTextOverlay: View { } } -@available(iOS 15.0, *) -private struct AltButtonStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label - .font(.caption.weight(.semibold)) - .padding(.horizontal, 8) - .padding(.vertical, 3) - .opacity(configuration.isPressed ? 0.5 : 1) - } -} - @available(iOS 15.0, *) struct MediaAltTextOverlay_Previews: PreviewProvider { static var previews: some View {