import * as React from 'react'; import { useState } from 'react'; import Dialog from 'react-native-dialog'; import { StyleSheet, View, Pressable, Image, ViewStyle, StyleProp, Modal, } from 'react-native'; import { AudioOutputList } from './ui/AudioOutputList'; import type { SimulationScenario } from 'livekit-client'; import { SimulateScenarioList } from './ui/SimulateScenarioList'; export type Props = { micEnabled?: boolean; setMicEnabled: (enabled: boolean) => void; cameraEnabled?: boolean; setCameraEnabled: (enabled: boolean) => void; switchCamera: () => void; screenShareEnabled: boolean; setScreenShareEnabled: (enabled: boolean) => void; sendData: (message: string) => void; onSimulate: (scenario: SimulationScenario) => void; onDisconnectClick: () => void; style?: StyleProp; }; export const RoomControls = ({ micEnabled = false, setMicEnabled, cameraEnabled = false, setCameraEnabled, switchCamera, screenShareEnabled = false, setScreenShareEnabled, sendData, onSimulate, onDisconnectClick, style, }: Props) => { const [audioModalVisible, setAudioModalVisible] = useState(false); const [simulateModalVisible, setSimulateModalVisible] = useState(false); var micImage = micEnabled ? require('./icons/baseline_mic_white_24dp.png') : require('./icons/baseline_mic_off_white_24dp.png'); var cameraImage = cameraEnabled ? require('./icons/baseline_videocam_white_24dp.png') : require('./icons/baseline_videocam_off_white_24dp.png'); var screenShareImage = screenShareEnabled ? require('./icons/baseline_cast_connected_white_24dp.png') : require('./icons/baseline_cast_white_24dp.png'); let [message, setMessage] = useState(''); let [messageDialogVisible, setMessageDialogVisible] = useState(false); const handleOk = () => { sendData(message); setMessageDialogVisible(false); }; const handleCancel = () => { setMessageDialogVisible(false); }; return ( { setAudioModalVisible(!audioModalVisible); }} > { return setAudioModalVisible(false); }} /> { setSimulateModalVisible(!simulateModalVisible); }} > { onSimulate(simulate); return setSimulateModalVisible(false); }} /> { setMicEnabled(!micEnabled); }} > { setCameraEnabled(!cameraEnabled); }} > { switchCamera(); }} > { setScreenShareEnabled(!screenShareEnabled); }} > { setMessageDialogVisible(true); }} > { onDisconnectClick(); }} > { setAudioModalVisible(true); }} > { setSimulateModalVisible(true); }} > Send Message ); }; const styles = StyleSheet.create({ container: { width: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-evenly', marginVertical: 8, }, icon: { width: 32, height: 32, }, centeredView: { flex: 1, justifyContent: 'center', alignItems: 'center', marginTop: 22, }, modalView: { margin: 20, backgroundColor: 'black', borderRadius: 20, padding: 35, alignItems: 'center', shadowColor: '#000', shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 4, elevation: 5, }, dialogItemTextStyle: { color: 'black', fontSize: 12, }, });