-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
116 lines (110 loc) · 3.12 KB
/
Copy pathApp.js
File metadata and controls
116 lines (110 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import React, { useState, useEffect } from "react";
import { SafeAreaView, TouchableOpacity, Text, TextInput } from "react-native";
import { MeetingProvider } from "@videosdk.live/react-native-sdk";
import MeetingContainer from "./src/MeetingContainer";
import { getToken, createMeeting, validateMeeting } from "./src/api";
import { notifyMessage } from "./src/utils";
export default function App() {
const [token, setToken] = useState("");
const [idValue, setIdValue] = useState("");
const [meetingId, setMeetingId] = useState("");
const resetMeeting = () => {
setToken("");
setMeetingId("");
setIdValue("");
};
const getTokenAndMeetingId = async () => {
const token = await getToken();
const meetingId = await createMeeting({ token });
setToken(token);
setMeetingId(meetingId);
if (!token || !meetingId) {
notifyMessage("Token or Meeting Id is not generated");
}
};
const validateMeetingId = async () => {
if (idValue) {
const token = await getToken();
const meetingId = await validateMeeting({ meetingId: idValue, token });
setToken(token);
setMeetingId(meetingId);
if (!token || !meetingId) {
notifyMessage("Token or Meeting Id is invalid");
}
} else {
notifyMessage("Please provide meetingId in textinput");
}
};
return token && meetingId ? (
<SafeAreaView style={{ flex: 1, backgroundColor: "#F6F6FF" }}>
<MeetingProvider
config={{
meetingId,
micEnabled: false,
webcamEnabled: true,
name: "Test User",
notification: {
title: "Code Sample",
message: "Meeting is running.",
},
}}
token={token}
>
<MeetingContainer resetMeeting={resetMeeting} />
</MeetingProvider>
</SafeAreaView>
) : (
<SafeAreaView
style={{
flex: 1,
backgroundColor: "#F6F6FF",
justifyContent: "center",
paddingHorizontal: 6 * 10,
}}
>
<TouchableOpacity
onPress={getTokenAndMeetingId}
style={{ backgroundColor: "#1178F8", padding: 12, borderRadius: 6 }}
>
<Text style={{ color: "white", alignSelf: "center", fontSize: 18 }}>
Create Meeting
</Text>
</TouchableOpacity>
<Text
style={{
alignSelf: "center",
fontSize: 22,
marginVertical: 16,
fontStyle: "italic",
color: "grey",
}}
>
---------- OR ----------
</Text>
<TextInput
value={idValue}
onChangeText={setIdValue}
placeholder={"XXXX-XXXX-XXXX"}
style={{
padding: 12,
borderWidth: 1,
borderRadius: 6,
fontStyle: "italic",
}}
/>
<TouchableOpacity
style={{
backgroundColor: "#1178F8",
padding: 12,
marginTop: 14,
borderRadius: 6,
}}
onPress={validateMeetingId}
>
<Text style={{ color: "white", alignSelf: "center", fontSize: 18 }}>
Join Meeting
</Text>
</TouchableOpacity>
</SafeAreaView>
);
}