Skip to content

Commit 8f12f71

Browse files
committed
Initial redesign
1 parent 8e9fdaa commit 8f12f71

20 files changed

+880
-181
lines changed

app/(start)/index.tsx

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,67 @@
1+
import { ConnectionDetails, fetchToken } from '@/hooks/useConnectionDetails';
12
import { useRouter } from 'expo-router';
2-
import { StyleSheet, Button, View } from 'react-native';
3+
import { useEffect, useRef, useState } from 'react';
4+
import { StyleSheet, Button, View, Image, Text, TouchableOpacity, ActivityIndicator, useAnimatedValue, Animated, ViewStyle } from 'react-native';
35

46
export default function StartScreen() {
57
const router = useRouter();
68

9+
let [isConnecting, setConnecting] = useState(false);
10+
let [connectionDetails, setConnectionDetails] = useState<ConnectionDetails | undefined>(undefined)
11+
12+
// Fetch token when we're connecting.
13+
useEffect(() => {
14+
if(isConnecting) {
15+
fetchToken().then(details => {
16+
console.log(details);
17+
setConnectionDetails(details);
18+
if (!details) {
19+
setConnecting(false);
20+
}
21+
});
22+
}
23+
}, [isConnecting]);
24+
25+
// Navigate to Assistant screen when we have the connection details.
26+
useEffect(() => {
27+
if(isConnecting && connectionDetails) {
28+
setConnecting(false);
29+
setConnectionDetails(undefined);
30+
router.navigate('../assistant');
31+
}
32+
}, [connectionDetails]);
33+
34+
let connectText: string;
35+
36+
if (isConnecting) {
37+
connectText = "Connecting"
38+
} else {
39+
connectText = "Start Voice Assistant"
40+
}
41+
742
return (
843
<View style={styles.container}>
9-
<Button
10-
onPress={() => router.navigate('../assistant')}
11-
title="Start Voice Assistant"
44+
<Image
45+
style={styles.logo}
46+
source={require('../../assets/images/start-logo.png')}
1247
/>
48+
<Text style={styles.text}>
49+
Chat live with your voice AI agent
50+
</Text>
51+
52+
<TouchableOpacity
53+
onPress={() => { setConnecting(true) }}
54+
style={styles.button}
55+
activeOpacity={0.7}
56+
disabled={isConnecting} // Disable button while loading
57+
>
58+
{ isConnecting ?
59+
<ActivityIndicator size="small" color="#ffffff" style={styles.activityIndicator} /> :
60+
undefined
61+
}
62+
63+
<Text style={styles.buttonText}>{connectText}</Text>
64+
</TouchableOpacity>
1365
</View>
1466
);
1567
}
@@ -20,4 +72,29 @@ const styles = StyleSheet.create({
2072
alignItems: 'center',
2173
justifyContent: 'center',
2274
},
75+
logo: {
76+
width: 59,
77+
height: 56,
78+
marginBottom: 16,
79+
},
80+
text: {
81+
color: '#ffffff',
82+
marginBottom: 24,
83+
},
84+
activityIndicator: {
85+
marginEnd: 8,
86+
},
87+
button: {
88+
flexDirection: 'row',
89+
backgroundColor: '#002CF2',
90+
paddingVertical: 12,
91+
paddingHorizontal: 12,
92+
borderRadius: 24,
93+
alignItems: 'center',
94+
justifyContent: 'center',
95+
minWidth: 200, // Ensure button has a minimum width when loading
96+
},
97+
buttonText: {
98+
color: '#ffffff',
99+
},
23100
});

0 commit comments

Comments
 (0)