2022-06-20 11:40:34 +00:00
|
|
|
import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2022-06-21 14:16:38 +00:00
|
|
|
import {
|
|
|
|
BackHandler,
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
TouchableOpacity,
|
|
|
|
TextInput,
|
|
|
|
Platform
|
|
|
|
} from 'react-native';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import { appNavigate } from '../../app/actions.native';
|
|
|
|
import { setAudioOnly } from '../../base/audio-only/actions';
|
|
|
|
import { connect } from '../../base/connection/actions.native';
|
|
|
|
import { IconClose } from '../../base/icons';
|
|
|
|
import JitsiScreen from '../../base/modal/components/JitsiScreen';
|
|
|
|
import { getLocalParticipant } from '../../base/participants';
|
|
|
|
import { getFieldValue } from '../../base/react';
|
|
|
|
import { ASPECT_RATIO_NARROW } from '../../base/responsive-ui';
|
|
|
|
import { updateSettings } from '../../base/settings';
|
2022-06-21 14:16:38 +00:00
|
|
|
import BaseTheme from '../../base/ui/components/BaseTheme.native';
|
2022-06-18 19:59:10 +00:00
|
|
|
import { BrandingImageBackground } from '../../dynamic-branding';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { LargeVideo } from '../../large-video/components';
|
|
|
|
import HeaderNavigationButton from '../../mobile/navigation/components/HeaderNavigationButton';
|
|
|
|
import { navigateRoot } from '../../mobile/navigation/rootNavigationContainerRef';
|
|
|
|
import { screen } from '../../mobile/navigation/routes';
|
|
|
|
import AudioMuteButton from '../../toolbox/components/AudioMuteButton';
|
|
|
|
import VideoMuteButton from '../../toolbox/components/VideoMuteButton';
|
2022-06-21 14:16:38 +00:00
|
|
|
import { isDisplayNameRequired } from '../functions';
|
2022-06-16 09:49:07 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
navigation: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Prejoin: ({ navigation }: Props) => JSX.Element = ({ navigation }: Props) => {
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const aspectRatio = useSelector(
|
|
|
|
(state: any) => state['features/base/responsive-ui']?.aspectRatio
|
|
|
|
);
|
|
|
|
const localParticipant = useSelector(state => getLocalParticipant(state));
|
2022-06-21 14:16:38 +00:00
|
|
|
const isDisplayNameMandatory = useSelector(state => isDisplayNameRequired(state));
|
2022-06-16 09:49:07 +00:00
|
|
|
const participantName = localParticipant?.name;
|
|
|
|
const [ displayName, setDisplayName ]
|
|
|
|
= useState(participantName || '');
|
|
|
|
const onChangeDisplayName = useCallback(event => {
|
|
|
|
const fieldValue = getFieldValue(event);
|
|
|
|
|
|
|
|
setDisplayName(fieldValue);
|
|
|
|
dispatch(updateSettings({
|
|
|
|
displayName: fieldValue
|
|
|
|
}));
|
|
|
|
}, [ displayName ]);
|
|
|
|
|
|
|
|
const onJoin = useCallback(() => {
|
|
|
|
dispatch(connect());
|
|
|
|
navigateRoot(screen.conference.root);
|
|
|
|
}, [ dispatch ]);
|
|
|
|
|
|
|
|
const onJoinLowBandwidth = useCallback(() => {
|
|
|
|
dispatch(setAudioOnly(true));
|
|
|
|
onJoin();
|
|
|
|
}, [ dispatch ]);
|
|
|
|
|
|
|
|
const goBack = useCallback(() => {
|
|
|
|
dispatch(appNavigate(undefined));
|
2022-06-21 14:16:38 +00:00
|
|
|
|
2022-06-20 11:40:34 +00:00
|
|
|
return true;
|
2022-06-16 09:49:07 +00:00
|
|
|
}, [ dispatch ]);
|
|
|
|
|
|
|
|
const headerLeft = useCallback(() => {
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
label = { t('dialog.close') }
|
|
|
|
onPress = { goBack } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
onPress = { goBack }
|
|
|
|
src = { IconClose } />
|
|
|
|
);
|
|
|
|
}, []);
|
|
|
|
|
2022-06-21 14:16:38 +00:00
|
|
|
const joinButtonDisabled = !displayName && isDisplayNameMandatory;
|
|
|
|
const joinButtonStyles = joinButtonDisabled
|
|
|
|
? styles.primaryButtonDisabled : styles.primaryButton;
|
|
|
|
|
2022-06-20 11:40:34 +00:00
|
|
|
useEffect(() => {
|
|
|
|
BackHandler.addEventListener('hardwareBackPress', goBack);
|
|
|
|
|
2022-06-21 14:16:38 +00:00
|
|
|
return () => BackHandler.removeEventListener('hardwareBackPress', goBack);
|
2022-06-20 11:40:34 +00:00
|
|
|
|
|
|
|
}, [ ]);
|
|
|
|
|
2022-06-16 09:49:07 +00:00
|
|
|
useLayoutEffect(() => {
|
|
|
|
navigation.setOptions({
|
|
|
|
headerLeft
|
|
|
|
});
|
|
|
|
}, [ navigation ]);
|
|
|
|
|
2022-06-21 14:16:38 +00:00
|
|
|
let contentWrapperStyles;
|
|
|
|
let contentContainerStyles;
|
|
|
|
let largeVideoContainerStyles;
|
|
|
|
let toolboxContainerStyles;
|
|
|
|
|
|
|
|
if (aspectRatio === ASPECT_RATIO_NARROW) {
|
|
|
|
contentWrapperStyles = styles.contentWrapper;
|
|
|
|
contentContainerStyles = styles.contentContainer;
|
|
|
|
largeVideoContainerStyles = styles.largeVideoContainer;
|
|
|
|
toolboxContainerStyles = styles.toolboxContainer;
|
|
|
|
} else {
|
|
|
|
contentWrapperStyles = styles.contentWrapperWide;
|
|
|
|
contentContainerStyles = styles.contentContainerWide;
|
|
|
|
largeVideoContainerStyles = styles.largeVideoContainerWide;
|
|
|
|
toolboxContainerStyles = styles.toolboxContainerWide;
|
|
|
|
}
|
|
|
|
|
2022-06-16 09:49:07 +00:00
|
|
|
return (
|
|
|
|
<JitsiScreen
|
2022-06-21 14:16:38 +00:00
|
|
|
safeAreaInsets = { [ 'left' ] }
|
2022-06-16 09:49:07 +00:00
|
|
|
style = { contentWrapperStyles }>
|
2022-06-18 19:59:10 +00:00
|
|
|
<BrandingImageBackground />
|
2022-06-16 09:49:07 +00:00
|
|
|
<View style = { largeVideoContainerStyles }>
|
|
|
|
<LargeVideo />
|
|
|
|
</View>
|
|
|
|
<View style = { contentContainerStyles }>
|
|
|
|
<View style = { styles.formWrapper }>
|
|
|
|
<TextInput
|
|
|
|
onChangeText = { onChangeDisplayName }
|
|
|
|
placeholder = { t('dialog.enterDisplayName') }
|
2022-06-21 14:16:38 +00:00
|
|
|
placeholderTextColor = { BaseTheme.palette.text03 }
|
2022-06-16 09:49:07 +00:00
|
|
|
style = { styles.field }
|
|
|
|
value = { displayName } />
|
|
|
|
<TouchableOpacity
|
2022-06-21 14:16:38 +00:00
|
|
|
disabled = { joinButtonDisabled }
|
2022-06-16 09:49:07 +00:00
|
|
|
onPress = { onJoin }
|
|
|
|
style = { [
|
|
|
|
styles.button,
|
2022-06-21 14:16:38 +00:00
|
|
|
joinButtonStyles
|
2022-06-16 09:49:07 +00:00
|
|
|
] }>
|
|
|
|
<Text style = { styles.primaryButtonText }>
|
|
|
|
{ t('prejoin.joinMeeting') }
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress = { onJoinLowBandwidth }
|
|
|
|
style = { [
|
|
|
|
styles.button,
|
|
|
|
styles.secondaryButton
|
|
|
|
] }>
|
|
|
|
<Text style = { styles.secondaryButtonText }>
|
|
|
|
{ t('prejoin.joinMeetingInLowBandwidthMode') }
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
<View style = { toolboxContainerStyles }>
|
|
|
|
<AudioMuteButton
|
|
|
|
styles = { styles.buttonStylesBorderless } />
|
|
|
|
<VideoMuteButton
|
|
|
|
styles = { styles.buttonStylesBorderless } />
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</JitsiScreen>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Prejoin;
|