Created
April 29, 2023 15:16
-
-
Save dueka/79be35fe2377b55d6ff413564259abf7 to your computer and use it in GitHub Desktop.
App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return ( | |
<SafeAreaView style={styles.main}> | |
<Text style={styles.head}> | |
Agora Interactive Live Streaming Quickstart | |
</Text> | |
<View style={styles.btnContainer}> | |
<Text onPress={join} style={styles.button}> | |
{isJoinLoading ? 'Joining...' : ' Join'} | |
</Text> | |
<Text onPress={leave} style={styles.button}> | |
{isLeaveLoading ? 'Leaving...' : ' Leave'} | |
</Text> | |
</View> | |
<View style={styles.btnContainer}> | |
<Text>Audience</Text> | |
<Switch | |
onValueChange={switchValue => { | |
setIsHost(switchValue); | |
if (isJoined) { | |
leave(); | |
} | |
}} | |
value={isHost} | |
/> | |
<Text>Host</Text> | |
</View> | |
<ScrollView | |
style={styles.scroll} | |
contentContainerStyle={styles.scrollContainer}> | |
{isJoined && isHost ? ( | |
<React.Fragment key={0}> | |
<RtcSurfaceView canvas={{uid: 0}} style={styles.videoView} /> | |
<Text>Local user uid: {uid}</Text> | |
</React.Fragment> | |
) : ( | |
<Text>{isHost ? 'Join a channel' : ''}</Text> | |
)} | |
{isJoined && !isHost && remoteUid !== 0 ? ( | |
<React.Fragment key={remoteUid}> | |
<RtcSurfaceView | |
canvas={{uid: remoteUid}} | |
style={styles.videoView} | |
/> | |
<Text>Remote user uid: {remoteUid}</Text> | |
</React.Fragment> | |
) : ( | |
<Text> | |
{isJoined && !isHost ? 'Waiting for a remote user to join' : ''} | |
</Text> | |
)} | |
<Text style={styles.info}>{message}</Text> | |
</ScrollView> | |
{isTranscribing && <ActivityIndicator size="large" color="#fff" />} | |
<View style={styles.transcription}> | |
<TranscribedOutput | |
transcribedText={transcribedData} | |
interimTranscribedText={interimTranscribedData} | |
/> | |
</View> | |
</SafeAreaView> | |
); | |
}; | |
const styles = StyleSheet.create({ | |
parent: { | |
flex: 1, | |
}, | |
container: { | |
padding: 16, | |
flex: 1, | |
}, | |
transcription: { | |
flex: 1, | |
flexDirection: 'row', | |
}, | |
fileHeader: { | |
color: '#fff', | |
fontSize: 30, | |
marginBottom: 10, | |
borderColor: '#ccc', | |
paddingBottom: 10, | |
borderBottomWidth: 1, | |
}, | |
list: { | |
marginVertical: 5, | |
paddingBottom: 12, | |
borderBottomWidth: 1, | |
borderColor: '#ccc', | |
}, | |
listName: { | |
fontSize: 16, | |
}, | |
buttonText: { | |
color: '#fff', | |
fontSize: 16, | |
textAlign: 'center', | |
paddingVertical: 10, | |
}, | |
button: { | |
paddingHorizontal: 25, | |
paddingVertical: 4, | |
fontWeight: 'bold', | |
color: '#ffffff', | |
backgroundColor: '#0055cc', | |
margin: 5, | |
}, | |
main: {flex: 1, alignItems: 'center'}, | |
scroll: {flex: 1, backgroundColor: '#ddeeff', width: '100%'}, | |
scrollContainer: {alignItems: 'center'}, | |
videoView: {width: '90%', height: 200}, | |
btnContainer: {flexDirection: 'row', justifyContent: 'center'}, | |
head: {fontSize: 20}, | |
info: {backgroundColor: '#ffffe0', paddingHorizontal: 8, color: '#0000ff'}, | |
}); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment