PulsingLogoAnimation.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // PulsingLogoAnimation.swift
  3. // Trio
  4. //
  5. // Created by Marvin Polscheit on 11.04.25.
  6. //
  7. import SwiftUI
  8. struct PulsingLogoAnimation: View {
  9. @State private var scale = 0.5
  10. @State private var opacity = 0.0
  11. @State private var rotation = 0.0
  12. @State private var isPulsing = false
  13. @Environment(\.accessibilityReduceMotion) var reduceMotion
  14. var body: some View {
  15. Image("trioCircledNoBackground")
  16. .resizable()
  17. .scaledToFit()
  18. .frame(height: 100)
  19. .scaleEffect(scale)
  20. .opacity(opacity)
  21. .rotationEffect(.degrees(rotation))
  22. .scaleEffect(isPulsing ? 1.1 : 1.0)
  23. .onAppear {
  24. if reduceMotion {
  25. scale = 1.0
  26. withAnimation(.easeInOut(duration: 1.0)) {
  27. opacity = 1.0
  28. }
  29. return
  30. }
  31. withAnimation(.easeInOut(duration: 1.0)) {
  32. scale = 1.0
  33. opacity = 1.0
  34. rotation = 360
  35. }
  36. withAnimation(.easeInOut(duration: 1.0).repeatForever()) {
  37. isPulsing.toggle()
  38. }
  39. DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
  40. withAnimation(.easeOut(duration: 1.0)) {
  41. isPulsing = false
  42. }
  43. }
  44. }
  45. }
  46. }