perf: gate idle pulse animations

This commit is contained in:
Peter Steinberger
2025-12-24 13:51:05 +01:00
parent e158bee95f
commit 88d20c5419
2 changed files with 27 additions and 9 deletions

View File

@@ -1357,6 +1357,8 @@ struct OnboardingView: View {
}
private struct GlowingClawdisIcon: View {
@Environment(\.scenePhase) private var scenePhase
let size: CGFloat
let glowIntensity: Double
let enableFloating: Bool
@@ -1398,11 +1400,21 @@ private struct GlowingClawdisIcon: View {
.frame(
width: glowCanvasSize + (glowBlurRadius * 2),
height: glowCanvasSize + (glowBlurRadius * 2))
.onAppear {
guard self.enableFloating else { return }
withAnimation(Animation.easeInOut(duration: 3.6).repeatForever(autoreverses: true)) {
self.breathe.toggle()
}
.onAppear { self.updateBreatheAnimation() }
.onDisappear { self.breathe = false }
.onChange(of: self.scenePhase) { _, _ in
self.updateBreatheAnimation()
}
}
private func updateBreatheAnimation() {
guard self.enableFloating, self.scenePhase == .active else {
self.breathe = false
return
}
guard !self.breathe else { return }
withAnimation(Animation.easeInOut(duration: 3.6).repeatForever(autoreverses: true)) {
self.breathe = true
}
}
}