Skip to content

Commit 1cf2c03

Browse files
committed
clean up bar visualizer appearance
1 parent 50fae0e commit 1cf2c03

File tree

4 files changed

+78
-33
lines changed

4 files changed

+78
-33
lines changed
Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import { useVoiceAssistant } from "@livekit/components-react";
22
import { BarVisualizer, VideoTrack } from "@livekit/react-native";
3-
import { StyleProp, StyleSheet, View, ViewStyle } from "react-native";
3+
import React, { useCallback, useLayoutEffect, useState } from "react";
4+
import { LayoutChangeEvent, StyleProp, StyleSheet, View, ViewStyle } from "react-native";
45

56
type AgentVisualizationProps = {
67
style: StyleProp<ViewStyle>,
78
}
89

10+
const barSize = 0.20;
11+
912
export default function AgentVisualization({
1013
style
1114
}: AgentVisualizationProps) {
1215
const { state, audioTrack, videoTrack } = useVoiceAssistant();
13-
16+
const [barWidth, setBarWidth] = useState(0);
17+
const [barBorderRadius, setBarBorderRadius] = useState(0);
18+
const layoutCallback = useCallback((event: LayoutChangeEvent) => {
19+
const { x, y, width, height } = event.nativeEvent.layout
20+
console.log(x, y, width, height);
21+
setBarWidth(barSize * height);
22+
setBarBorderRadius(barSize * height);
23+
}, []);
1424
let videoView = ( videoTrack
1525
? <VideoTrack
1626
trackRef={videoTrack}
@@ -20,17 +30,20 @@ export default function AgentVisualization({
2030
)
2131
return (
2232
<View style={[style, styles.container]} >
23-
24-
<BarVisualizer
25-
state={state}
26-
barCount={5}
27-
options={{
28-
minHeight: 0.1,
29-
barWidth: 12,
30-
}}
31-
trackRef={audioTrack}
32-
style={styles.voiceAssistant}
33-
/>
33+
<View style={styles.barVisualizerContainer} onLayout={layoutCallback}>
34+
<BarVisualizer
35+
state={state}
36+
barCount={5}
37+
options={{
38+
minHeight: barSize,
39+
barWidth: barWidth,
40+
barColor: '#FFFFFF',
41+
barBorderRadius: barBorderRadius,
42+
}}
43+
trackRef={audioTrack}
44+
style={styles.barVisualizer}
45+
/>
46+
</View>
3447
{videoView}
3548
</View>
3649
);
@@ -48,9 +61,13 @@ const styles = StyleSheet.create({
4861
height: '100%',
4962
zIndex: 1,
5063
},
51-
voiceAssistant: {
64+
barVisualizerContainer: {
5265
width: '100%',
5366
height: '30%',
5467
zIndex: 0,
5568
},
69+
barVisualizer: {
70+
width: '100%',
71+
height: '100%',
72+
},
5673
});

app/assistant/ui/ChatLog.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,22 @@ const styles = StyleSheet.create({
8181
},
8282
userTranscription: {
8383
width: 'auto',
84-
fontSize: 18,
84+
fontSize: 17,
8585
alignSelf: 'flex-end',
8686
borderRadius: 6,
87-
padding: 8,
87+
paddingHorizontal: 12,
88+
paddingVertical: 6,
8889
margin: 16,
8990
},
9091
userTranscriptionLight: {
9192
backgroundColor: '#B0B0B0',
9293
},
9394
userTranscriptionDark: {
94-
backgroundColor: '#404040',
95+
backgroundColor: '#131313',
9596
},
9697

9798
agentTranscription: {
98-
fontSize: 20,
99+
fontSize: 17,
99100
textAlign: 'left',
100101
margin: 16,
101102
},

package-lock.json

Lines changed: 40 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"@config-plugins/react-native-webrtc": "12.0.0",
2121
"@expo/vector-icons": "^14.1.0",
2222
"@livekit/components-react": "^2.8.1",
23-
"@livekit/react-native": "^2.7.6",
23+
"@livekit/react-native": "^2.9.0",
2424
"@livekit/react-native-expo-plugin": "^1.0.1",
25-
"@livekit/react-native-webrtc": "^125.0.9",
25+
"@livekit/react-native-webrtc": "^137.0.0",
2626
"@react-navigation/bottom-tabs": "^7.2.0",
2727
"@react-navigation/native": "^7.0.14",
2828
"expo": "53.0.20",

0 commit comments

Comments
 (0)