Skip to content

Avatar view #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions VoiceAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -312,8 +312,8 @@
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
@@ -355,8 +355,8 @@
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/livekit/client-sdk-swift",
"state" : {
"revision" : "4fba03e8934ec538e226c362275dd78692991424",
"version" : "2.3.1"
"revision" : "4f9db591da71bfd7c556589e43963e1d777cf337",
"version" : "2.5.0"
}
},
{
@@ -69,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/livekit/webrtc-xcframework.git",
"state" : {
"revision" : "d1a5661a412668829a22e44f875eeef109526c65",
"version" : "125.6422.24"
"revision" : "70bbd9b51f2c46333a91469c8a8be8303b0797b7",
"version" : "125.6422.28"
}
}
],
27 changes: 27 additions & 0 deletions VoiceAssistant/Agent/AgentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import LiveKit
import LiveKitComponents
import SwiftUI

struct AgentView: View {
@EnvironmentObject private var room: Room

var body: some View {
ZStack {
if let agent = room.agentParticipant {
let micTrack = agent.firstAudioTrack
let cameraTrack = agent.firstCameraVideoTrack

if let cameraTrack, !cameraTrack.isMuted {
SwiftUIVideoView(cameraTrack)
.overlay(alignment: .topTrailing) {
AgentBarAudioVisualizer(audioTrack: micTrack, agentState: room.agentState, barColor: .primary, barCount: 5)
.frame(width: 100, height: 50)
.padding()
}
} else {
AgentBarAudioVisualizer(audioTrack: micTrack, agentState: room.agentState, barColor: .primary, barCount: 5)
}
}
}
}
}
17 changes: 0 additions & 17 deletions VoiceAssistant/Connect/StatusView.swift

This file was deleted.

36 changes: 23 additions & 13 deletions VoiceAssistant/ContentView.swift
Original file line number Diff line number Diff line change
@@ -28,20 +28,11 @@ struct ContentView: View {
if room.connectionState == .disconnected {
ControlBar()
} else {
VStack {
ChatView()
.environment(chatViewModel)
HStack(alignment: .center) {
StatusView()
.frame(width: 58)
Spacer()
.frame(maxWidth: .infinity)
ControlBar()
.layoutPriority(1)
}
.frame(height: 64)
VStack(spacing: 16) {
agent()
chat()
toolbar()
}
.overlay(content: tooltip)
}
}
.padding()
@@ -53,6 +44,25 @@ struct ContentView: View {
}
}

@ViewBuilder
private func chat() -> some View {
ChatView()
.environment(chatViewModel)
.overlay(content: tooltip)
}

@ViewBuilder
private func agent() -> some View {
AgentView()
.frame(maxWidth: 256, maxHeight: 256)
}

@ViewBuilder
private func toolbar() -> some View {
ControlBar()
.frame(height: 64)
}

@ViewBuilder
private func tooltip() -> some View {
if room.agentState == .listening, chatViewModel.messages.isEmpty {