import React, { FunctionComponent } from 'react'; import { StyleSheet, TextStyle, View, ViewStyle, } from 'react-native'; import { CallState } from '../../../store/webrtc/types'; import { Logger } from '../../../utils/Log'; import { IStyledProps } from '../../common/types'; import { IConference } from '../../../store/conference/types'; import { LoudspeakerButton, MicButton, SwitchCameraButton } from '../CallActionButtons'; import { AnswerConfCallButton, HideConferenceCallViewButton, LockConfButton, AddVideoToConfButton } from './ConfCallActionButtons'; import { EndConferenceCallButton } from './ConfCallActionButtons/EndConfCallButton/EndConfCallButtonContainer'; import { useAppDispatch } from '../../../store/hooks'; const logger = new Logger('ConferenceCallActions'); export interface IConferenceActionsStyleProps { textStyle?: TextStyle; container?: ViewStyle; } interface IProps extends IStyledProps { call: IConference; renderIncomingConferenceActions?: (conferenceCall: IConference) => React.ReactNode; renderOutgoingConferenceActions?: (conferenceCall: IConference) => React.ReactNode; renderActiveConferenceActions?: (conferenceCall: IConference) => React.ReactNode; } export const ConferenceActionsView: FunctionComponent = ({ call, style, renderIncomingConferenceActions, renderOutgoingConferenceActions, renderActiveConferenceActions }) => { const mergedStyle = { ...defaultStyle, ...style }; const { callState, callPeer, isLocalVideoEnabled } = call; const dispatch = useAppDispatch(); const micButtonView = ; const loudspeakerButton = ; const answerAudioCallButton = const switchCameraButton = const lockConferenceButton = callPeer.isMyUserModerator && const hideConferenceCallViewButton = const addVideoButtonView = const endCallButton = const switchCameraButtonView = isLocalVideoEnabled && switchCameraButton; if (!call) { logger.error('Null call or null contact received'); return null; } const incomingConferenceActions = () => { if (callState === CallState.RINGING_INCOMING) { if (renderIncomingConferenceActions) { return renderIncomingConferenceActions(call); } else { return ( <> {answerAudioCallButton} {endCallButton} ); } } else { return null } } const outgoingConferenceActions = () => { if (callState === CallState.RINGING_OUTGOING) { if (renderOutgoingConferenceActions) { return renderOutgoingConferenceActions(call); } else { return ( <> {micButtonView} {loudspeakerButton} {endCallButton} ); } } else { return null } } const activeConferenceActions = () => { if (callState === CallState.ACTIVE) { if (renderActiveConferenceActions) { return renderActiveConferenceActions(call); } else { return ( <> {micButtonView} {switchCameraButtonView} {hideConferenceCallViewButton} {addVideoButtonView} {loudspeakerButton} {lockConferenceButton} {endCallButton} ); } } else { return null } } return ( {incomingConferenceActions()} {outgoingConferenceActions()} {activeConferenceActions()} ); }; const defaultStyle: IConferenceActionsStyleProps = StyleSheet.create({ container: { display:'flex', flexDirection: 'row', alignContent: 'center', justifyContent: 'space-between', }, textStyle: { position: 'absolute', top: 20, fontSize: 20, color: '#ffffff', alignSelf: 'center', marginLeft: 50, } });