1
- /**
2
- * Sample React Native App
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- */
7
- import Daily , {
8
- DailyEvent ,
9
- DailyCall ,
10
- DailyEventObject ,
11
- DailyEventObjectAppMessage ,
12
- } from '@daily-co/react-native-daily-js' ;
1
+ import React from 'react' ;
2
+ import { Button , SafeAreaView } from 'react-native' ;
13
3
14
- import React , { useEffect , useState } from 'react' ;
15
- import type { PropsWithChildren } from 'react' ;
16
- import {
17
- Button ,
18
- SafeAreaView ,
19
- ScrollView ,
20
- StatusBar ,
21
- StyleSheet ,
22
- Text ,
23
- useColorScheme ,
24
- View ,
25
- } from 'react-native' ;
26
-
27
- import {
28
- Colors ,
29
- DebugInstructions ,
30
- Header ,
31
- LearnMoreLinks ,
32
- ReloadInstructions ,
33
- } from 'react-native/Libraries/NewAppScreen' ;
34
- import { useVapi } from './useVapi' ;
35
-
36
- type SectionProps = PropsWithChildren < {
37
- title : string ;
38
- } > ;
39
-
40
- function Section ( { children, title} : SectionProps ) : React . JSX . Element {
41
- const isDarkMode = useColorScheme ( ) === 'dark' ;
42
- return (
43
- < View style = { styles . sectionContainer } >
44
- < Text
45
- style = { [
46
- styles . sectionTitle ,
47
- {
48
- color : isDarkMode ? Colors . white : Colors . black ,
49
- } ,
50
- ] } >
51
- { title }
52
- </ Text >
53
- < Text
54
- style = { [
55
- styles . sectionDescription ,
56
- {
57
- color : isDarkMode ? Colors . light : Colors . dark ,
58
- } ,
59
- ] } >
60
- { children }
61
- </ Text >
62
- </ View >
63
- ) ;
64
- }
65
-
66
- enum AppState {
67
- Idle ,
68
- Creating ,
69
- Joining ,
70
- Joined ,
71
- Leaving ,
72
- Error ,
73
- }
4
+ import { useVapi } from './useVapi' ;
74
5
75
6
function App ( ) : React . JSX . Element {
76
- const { toggleCall, joinCall} = useVapi ( ) ;
77
-
78
- // const [appState, setAppState] = useState(AppState.Idle);
79
- // const [roomUrl, setRoomUrl] = useState<string | undefined>(undefined);
80
- // const [roomCreateError, setRoomCreateError] = useState<boolean>(false);
81
- // const [callObject, setCallObject] = useState<DailyCall | null>(null);
82
- // const [roomUrlFieldValue, setRoomUrlFieldValue] = useState<
83
- // string | undefined
84
- // >(undefined);
85
-
86
- // useEffect(() => {
87
- // if (!callObject || !roomUrl) {
88
- // return;
89
- // }
90
- // callObject.join({url: roomUrl}).catch(_ => {
91
- // // Doing nothing here since we handle fatal join errors in another way,
92
- // // via our listener attached to the 'error' event
93
- // });
94
- // setAppState(AppState.Joining);
95
- // }, [callObject, roomUrl]);
96
-
97
- // /**
98
- // * Create the callObject as soon as we have a roomUrl.
99
- // * This will trigger the call starting.
100
- // */
101
- // useEffect(() => {
102
- // if (!roomUrl) {
103
- // return;
104
- // }
105
- // const newCallObject = Daily.createCallObject({
106
- // /*dailyConfig: {
107
- // // Point to a specific version of the call-machine bundle
108
- // // @ts -ignore
109
- // callObjectBundleUrlOverride: 'https://b.staging.daily.co/call-ui/0a8807ac0fc0147c996b6db8d8b4c17f640dcd47/static/call-machine-object-bundle.js'
110
- // }*/
111
- // });
112
- // setCallObject(newCallObject);
113
- // }, [roomUrl]);
7
+ const { toggleCall } = useVapi ( ) ;
114
8
115
9
return (
116
10
< SafeAreaView >
@@ -121,14 +15,6 @@ function App(): React.JSX.Element {
121
15
console . log ( 'toggling call' ) ;
122
16
} }
123
17
/>
124
- < Button
125
- title = "Join call"
126
- onPress = { ( ) => {
127
- joinCall ( ) . then ( ( ) => {
128
- console . log ( 'joined the call call' ) ;
129
- } ) ;
130
- } }
131
- />
132
18
</ SafeAreaView >
133
19
) ;
134
20
}
0 commit comments