Skip to content

Commit 9fa33d2

Browse files
committed
Remove wrappers
1 parent 049f3d6 commit 9fa33d2

File tree

12 files changed

+20
-18
lines changed

12 files changed

+20
-18
lines changed

VoiceAgent/App/AppView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import LiveKit
22
import SwiftUI
33

44
struct AppView: View {
5-
@LiveKitSession private var session
6-
@LiveKitLocalMedia private var localMedia
5+
@EnvironmentObject private var session: Session
6+
@EnvironmentObject private var localMedia: LocalMedia
77

88
@State private var chat: Bool = false
99
@FocusState private var keyboardFocus: Bool

VoiceAgent/Chat/ChatTextInputView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftUI
33

44
/// A multiplatform view that shows the chat input text field and send button.
55
struct ChatTextInputView: View {
6-
@LiveKitSession private var session
6+
@EnvironmentObject private var session: Session
77

88
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
99
@FocusState.Binding var keyboardFocus: Bool

VoiceAgent/ControlBar/AudioDeviceSelector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SwiftUI
44
#if os(macOS)
55
/// A platform-specific view that shows a list of available audio devices.
66
struct AudioDeviceSelector: View {
7-
@LiveKitLocalMedia private var localMedia
7+
@EnvironmentObject private var localMedia: LocalMedia
88

99
var body: some View {
1010
Menu {

VoiceAgent/ControlBar/ControlBar.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import LiveKitComponents
44
/// Available controls depend on the agent features and the track availability.
55
/// - SeeAlso: ``AgentFeatures``
66
struct ControlBar: View {
7-
@LiveKitSession private var session
8-
@LiveKitLocalMedia private var localMedia
7+
@EnvironmentObject private var session: Session
8+
@EnvironmentObject private var localMedia: LocalMedia
99

1010
@Binding var chat: Bool
1111
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@@ -126,7 +126,7 @@ struct ControlBar: View {
126126
Spacer()
127127
}
128128
.frame(width: Constants.buttonWidth)
129-
.disabled(!session.hasAgents)
129+
.disabled(!session.hasAgent)
130130
}
131131

132132
@ViewBuilder
@@ -146,7 +146,7 @@ struct ControlBar: View {
146146
borderColor: .separator1
147147
)
148148
)
149-
.disabled(!session.hasAgents)
149+
.disabled(!session.hasAgent)
150150
}
151151

152152
@ViewBuilder
@@ -166,7 +166,7 @@ struct ControlBar: View {
166166
borderColor: .separator1
167167
)
168168
)
169-
.disabled(!session.hasAgents)
169+
.disabled(!session.hasAgent)
170170
}
171171

172172
@ViewBuilder

VoiceAgent/ControlBar/VideoDeviceSelector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SwiftUI
55
#if os(macOS)
66
/// A platform-specific view that shows a list of available video devices.
77
struct VideoDeviceSelector: View {
8-
@LiveKitLocalMedia private var localMedia
8+
@EnvironmentObject private var localMedia: LocalMedia
99

1010
var body: some View {
1111
Menu {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import LiveKit
12
import SwiftUI
23

34
extension EnvironmentValues {
45
@Entry var namespace: Namespace.ID? // don't initialize outside View
6+
@Entry var agent: Agent?
57
}

VoiceAgent/Interactions/TextInteractionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import SwiftUI
1010
///
1111
/// Additionally, the view shows a complete chat view with text input capabilities.
1212
struct TextInteractionView: View {
13-
@LiveKitAgent private var agent
14-
@LiveKitLocalMedia private var localMedia
13+
@EnvironmentObject private var localMedia: LocalMedia
14+
@Environment(\.agent) private var agent
1515

1616
@FocusState.Binding var keyboardFocus: Bool
1717

VoiceAgent/Participant/AgentParticipantView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import LiveKitComponents
44
/// or the audio visualizer (if available).
55
/// - Note: If both are unavailable, the view will show a placeholder visualizer.
66
struct AgentParticipantView: View {
7-
@LiveKitSession private var session
8-
@LiveKitAgent private var agent
9-
7+
@EnvironmentObject private var session: Session
8+
@Environment(\.agent) private var agent
109
@Environment(\.namespace) private var namespace
1110
/// Reveals the avatar camera view when true.
1211
@SceneStorage("videoTransition") private var videoTransition = false

VoiceAgent/Participant/LocalParticipantView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import LiveKitComponents
22

33
/// A view that shows the local participant's camera view with flip control.
44
struct LocalParticipantView: View {
5-
@LiveKitLocalMedia private var localMedia
5+
@EnvironmentObject private var localMedia: LocalMedia
66

77
@Environment(\.namespace) private var namespace
88

VoiceAgent/Participant/ScreenShareView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import LiveKitComponents
22

33
/// A view that shows the screen share preview.
44
struct ScreenShareView: View {
5-
@LiveKitLocalMedia private var localMedia
5+
@EnvironmentObject private var localMedia: LocalMedia
66

77
@Environment(\.namespace) private var namespace
88

0 commit comments

Comments
 (0)