Skip to content

Commit aaced3c

Browse files
authored
Merge pull request #7 from livekit-examples/dl/redesign
Redesign
2 parents e8a099c + 1da55a2 commit aaced3c

22 files changed

+2784
-3660
lines changed

app.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"orientation": "portrait",
77
"icon": "./assets/images/icon.png",
88
"scheme": "myapp",
9-
"userInterfaceStyle": "automatic",
9+
"userInterfaceStyle": "dark",
1010
"newArchEnabled": true,
1111
"ios": {
1212
"supportsTablet": true,
@@ -28,7 +28,8 @@
2828
"android.permission.SYSTEM_ALERT_WINDOW",
2929
"android.permission.WAKE_LOCK",
3030
"android.permission.BLUETOOTH"
31-
]
31+
],
32+
"softwareKeyboardLayoutMode": "pan"
3233
},
3334
"web": {
3435
"bundler": "metro",

app/(start)/index.tsx

Lines changed: 93 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,79 @@
1+
import { ConnectionDetails, fetchToken } from '@/hooks/useConnectionDetails';
12
import { useRouter } from 'expo-router';
2-
import { StyleSheet, Button, View } from 'react-native';
3+
import { useEffect, useState } from 'react';
4+
import {
5+
StyleSheet,
6+
View,
7+
Image,
8+
Text,
9+
TouchableOpacity,
10+
ActivityIndicator,
11+
} from 'react-native';
312

413
export default function StartScreen() {
514
const router = useRouter();
615

16+
let [isConnecting, setConnecting] = useState(false);
17+
let [connectionDetails, setConnectionDetails] = useState<
18+
ConnectionDetails | undefined
19+
>(undefined);
20+
21+
// Fetch token when we're connecting.
22+
useEffect(() => {
23+
if (isConnecting) {
24+
fetchToken().then((details) => {
25+
console.log(details);
26+
setConnectionDetails(details);
27+
if (!details) {
28+
setConnecting(false);
29+
}
30+
});
31+
}
32+
}, [isConnecting]);
33+
34+
// Navigate to Assistant screen when we have the connection details.
35+
useEffect(() => {
36+
if (isConnecting && connectionDetails) {
37+
setConnecting(false);
38+
setConnectionDetails(undefined);
39+
router.navigate('../assistant');
40+
}
41+
}, [isConnecting, router, connectionDetails]);
42+
43+
let connectText: string;
44+
45+
if (isConnecting) {
46+
connectText = 'Connecting';
47+
} else {
48+
connectText = 'Start Voice Assistant';
49+
}
50+
751
return (
852
<View style={styles.container}>
9-
<Button
10-
onPress={() => router.navigate('../assistant')}
11-
title="Start Voice Assistant"
53+
<Image
54+
style={styles.logo}
55+
source={require('../../assets/images/start-logo.png')}
1256
/>
57+
<Text style={styles.text}>Chat live with your voice AI agent</Text>
58+
59+
<TouchableOpacity
60+
onPress={() => {
61+
setConnecting(true);
62+
}}
63+
style={styles.button}
64+
activeOpacity={0.7}
65+
disabled={isConnecting} // Disable button while loading
66+
>
67+
{isConnecting ? (
68+
<ActivityIndicator
69+
size="small"
70+
color="#ffffff"
71+
style={styles.activityIndicator}
72+
/>
73+
) : undefined}
74+
75+
<Text style={styles.buttonText}>{connectText}</Text>
76+
</TouchableOpacity>
1377
</View>
1478
);
1579
}
@@ -20,4 +84,29 @@ const styles = StyleSheet.create({
2084
alignItems: 'center',
2185
justifyContent: 'center',
2286
},
87+
logo: {
88+
width: 59,
89+
height: 56,
90+
marginBottom: 16,
91+
},
92+
text: {
93+
color: '#ffffff',
94+
marginBottom: 24,
95+
},
96+
activityIndicator: {
97+
marginEnd: 8,
98+
},
99+
button: {
100+
flexDirection: 'row',
101+
backgroundColor: '#002CF2',
102+
paddingVertical: 12,
103+
paddingHorizontal: 12,
104+
borderRadius: 24,
105+
alignItems: 'center',
106+
justifyContent: 'center',
107+
minWidth: 200, // Ensure button has a minimum width when loading
108+
},
109+
buttonText: {
110+
color: '#ffffff',
111+
},
23112
});

0 commit comments

Comments
 (0)