perf: gate idle pulse animations
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct StatusPill: View {
|
struct StatusPill: View {
|
||||||
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
enum BridgeState: Equatable {
|
enum BridgeState: Equatable {
|
||||||
case connected
|
case connected
|
||||||
case connecting
|
case connecting
|
||||||
@@ -72,14 +74,18 @@ struct StatusPill: View {
|
|||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.accessibilityLabel("Status")
|
.accessibilityLabel("Status")
|
||||||
.accessibilityValue("\(self.bridge.title), Voice Wake \(self.voiceWakeEnabled ? "enabled" : "disabled")")
|
.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
|
.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) {
|
private func updatePulse(for bridge: BridgeState, scenePhase: ScenePhase) {
|
||||||
guard bridge == .connecting else {
|
guard bridge == .connecting, scenePhase == .active else {
|
||||||
withAnimation(.easeOut(duration: 0.2)) { self.pulse = false }
|
withAnimation(.easeOut(duration: 0.2)) { self.pulse = false }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1357,6 +1357,8 @@ struct OnboardingView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private struct GlowingClawdisIcon: View {
|
private struct GlowingClawdisIcon: View {
|
||||||
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
let size: CGFloat
|
let size: CGFloat
|
||||||
let glowIntensity: Double
|
let glowIntensity: Double
|
||||||
let enableFloating: Bool
|
let enableFloating: Bool
|
||||||
@@ -1398,11 +1400,21 @@ private struct GlowingClawdisIcon: View {
|
|||||||
.frame(
|
.frame(
|
||||||
width: glowCanvasSize + (glowBlurRadius * 2),
|
width: glowCanvasSize + (glowBlurRadius * 2),
|
||||||
height: glowCanvasSize + (glowBlurRadius * 2))
|
height: glowCanvasSize + (glowBlurRadius * 2))
|
||||||
.onAppear {
|
.onAppear { self.updateBreatheAnimation() }
|
||||||
guard self.enableFloating else { return }
|
.onDisappear { self.breathe = false }
|
||||||
withAnimation(Animation.easeInOut(duration: 3.6).repeatForever(autoreverses: true)) {
|
.onChange(of: self.scenePhase) { _, _ in
|
||||||
self.breathe.toggle()
|
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