Skip to content

Commit 371c55b

Browse files
committed
Transition between agent states
1 parent aee4127 commit 371c55b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/LiveKitComponents/UI/Visualizer/AgentBarAudioVisualizer.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public struct AgentBarAudioVisualizer: View {
7575
public let barMinOpacity: Double
7676
public let isCentered: Bool
7777

78-
public let agentState: AgentState
78+
private let agentState: AgentState
7979

8080
@StateObject private var audioProcessor: AudioProcessor
8181

@@ -120,15 +120,16 @@ public struct AgentBarAudioVisualizer: View {
120120
animationTask = Task {
121121
while !Task.isCancelled {
122122
try? await Task.sleep(nanoseconds: UInt64(duration * Double(NSEC_PER_SEC)))
123-
withAnimation { animationPhase += 1 }
123+
withAnimation(.easeInOut) { animationPhase += 1 }
124124
}
125125
}
126126
}
127127
.onDisappear {
128128
animationTask?.cancel()
129129
}
130+
.animation(.easeOut, value: agentState)
130131
.onChange(of: agentState) { _ in
131-
withAnimation { animationPhase = 0 }
132+
animationPhase = 0
132133
}
133134
}
134135
}

0 commit comments

Comments
 (0)