11import { ConnectionDetails , fetchToken } from '@/hooks/useConnectionDetails' ;
22import { useRouter } from 'expo-router' ;
3- import { useEffect , useRef , useState } from 'react' ;
4- import { StyleSheet , Button , View , Image , Text , TouchableOpacity , ActivityIndicator , useAnimatedValue , Animated , ViewStyle } 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' ;
512
613export default function StartScreen ( ) {
714 const router = useRouter ( ) ;
815
916 let [ isConnecting , setConnecting ] = useState ( false ) ;
10- let [ connectionDetails , setConnectionDetails ] = useState < ConnectionDetails | undefined > ( undefined )
17+ let [ connectionDetails , setConnectionDetails ] = useState <
18+ ConnectionDetails | undefined
19+ > ( undefined ) ;
1120
1221 // Fetch token when we're connecting.
1322 useEffect ( ( ) => {
14- if ( isConnecting ) {
15- fetchToken ( ) . then ( details => {
23+ if ( isConnecting ) {
24+ fetchToken ( ) . then ( ( details ) => {
1625 console . log ( details ) ;
1726 setConnectionDetails ( details ) ;
1827 if ( ! details ) {
@@ -24,19 +33,19 @@ export default function StartScreen() {
2433
2534 // Navigate to Assistant screen when we have the connection details.
2635 useEffect ( ( ) => {
27- if ( isConnecting && connectionDetails ) {
36+ if ( isConnecting && connectionDetails ) {
2837 setConnecting ( false ) ;
2938 setConnectionDetails ( undefined ) ;
3039 router . navigate ( '../assistant' ) ;
3140 }
32- } , [ connectionDetails ] ) ;
41+ } , [ isConnecting , router , connectionDetails ] ) ;
3342
3443 let connectText : string ;
3544
3645 if ( isConnecting ) {
37- connectText = " Connecting"
46+ connectText = ' Connecting' ;
3847 } else {
39- connectText = " Start Voice Assistant"
48+ connectText = ' Start Voice Assistant' ;
4049 }
4150
4251 return (
@@ -45,22 +54,25 @@ export default function StartScreen() {
4554 style = { styles . logo }
4655 source = { require ( '../../assets/images/start-logo.png' ) }
4756 />
48- < Text style = { styles . text } >
49- Chat live with your voice AI agent
50- </ Text >
51-
57+ < Text style = { styles . text } > Chat live with your voice AI agent</ Text >
58+
5259 < TouchableOpacity
53- onPress = { ( ) => { setConnecting ( true ) } }
60+ onPress = { ( ) => {
61+ setConnecting ( true ) ;
62+ } }
5463 style = { styles . button }
5564 activeOpacity = { 0.7 }
5665 disabled = { isConnecting } // Disable button while loading
5766 >
58- { isConnecting ?
59- < ActivityIndicator size = "small" color = "#ffffff" style = { styles . activityIndicator } /> :
60- undefined
61- }
62-
63- < Text style = { styles . buttonText } > { connectText } </ Text >
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 >
6476 </ TouchableOpacity >
6577 </ View >
6678 ) ;
0 commit comments