perf: gate idle pulse animations
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct StatusPill: View {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
enum BridgeState: Equatable {
|
||||
case connected
|
||||
case connecting
|
||||
@@ -72,14 +74,18 @@ struct StatusPill: View {
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel("Status")
|
||||
.accessibilityValue("\(self.bridge.title), Voice Wake \(self.voiceWakeEnabled ? "enabled" : "disabled")")
|
||||
.onAppear { self.updatePulse(for: self.bridge) }
|
||||
.onAppear { self.updatePulse(for: self.bridge, scenePhase: self.scenePhase) }
|
||||
.onDisappear { self.pulse = false }
|
||||
.onChange(of: self.bridge) { _, newValue in
|
||||
self.updatePulse(for: newValue)
|
||||
self.updatePulse(for: newValue, scenePhase: self.scenePhase)
|
||||
}
|
||||
.onChange(of: self.scenePhase) { _, newValue in
|
||||
self.updatePulse(for: self.bridge, scenePhase: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
private func updatePulse(for bridge: BridgeState) {
|
||||
guard bridge == .connecting else {
|
||||
private func updatePulse(for bridge: BridgeState, scenePhase: ScenePhase) {
|
||||
guard bridge == .connecting, scenePhase == .active else {
|
||||
withAnimation(.easeOut(duration: 0.2)) { self.pulse = false }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user