2022-11-08 15:46:46 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
|
|
|
|
2022-08-30 15:56:05 +00:00
|
|
|
import { useIsFocused } from '@react-navigation/native';
|
2022-11-10 14:48:53 +00:00
|
|
|
// @ts-ignore
|
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,
|
2022-07-11 12:30:37 +00:00
|
|
|
Platform,
|
|
|
|
StyleProp,
|
2022-08-24 09:43:28 +00:00
|
|
|
Text,
|
2022-07-11 12:30:37 +00:00
|
|
|
TextStyle,
|
2022-08-24 09:43:28 +00:00
|
|
|
View,
|
2022-07-11 12:30:37 +00:00
|
|
|
ViewStyle
|
2022-06-21 14:16:38 +00:00
|
|
|
} from 'react-native';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
2022-10-28 10:07:58 +00:00
|
|
|
import { appNavigate } from '../../../app/actions.native';
|
|
|
|
import { IReduxState } from '../../../app/types';
|
|
|
|
import { setAudioOnly } from '../../../base/audio-only/actions';
|
|
|
|
import { getConferenceName } from '../../../base/conference/functions';
|
|
|
|
import { connect } from '../../../base/connection/actions.native';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconCloseLarge } from '../../../base/icons/svg';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
|
|
|
|
import { getLocalParticipant } from '../../../base/participants/functions';
|
2022-11-08 15:46:46 +00:00
|
|
|
import { getFieldValue } from '../../../base/react/functions';
|
2022-10-28 10:07:58 +00:00
|
|
|
import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
|
|
|
|
import { updateSettings } from '../../../base/settings/actions';
|
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
2022-11-08 15:46:46 +00:00
|
|
|
import Input from '../../../base/ui/components/native/Input';
|
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
|
2022-10-28 10:07:58 +00:00
|
|
|
import { BrandingImageBackground } from '../../../dynamic-branding/components/native';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-11-08 15:46:46 +00:00
|
|
|
import LargeVideo from '../../../large-video/components/LargeVideo.native';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import HeaderNavigationButton from '../../../mobile/navigation/components/HeaderNavigationButton';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import { navigateRoot } from '../../../mobile/navigation/rootNavigationContainerRef';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import { screen } from '../../../mobile/navigation/routes';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import AudioMuteButton from '../../../toolbox/components/AudioMuteButton';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import VideoMuteButton from '../../../toolbox/components/VideoMuteButton';
|
|
|
|
import { isDisplayNameRequired } from '../../functions';
|
|
|
|
import { IPrejoinProps } from '../../types';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-10-28 10:07:58 +00:00
|
|
|
import styles from '../styles';
|
2022-06-16 09:49:07 +00:00
|
|
|
|
|
|
|
|
2022-10-21 11:09:15 +00:00
|
|
|
const Prejoin: React.FC<IPrejoinProps> = ({ navigation }: IPrejoinProps) => {
|
2022-06-16 09:49:07 +00:00
|
|
|
const dispatch = useDispatch();
|
2022-08-30 15:56:05 +00:00
|
|
|
const isFocused = useIsFocused();
|
2022-06-16 09:49:07 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
const aspectRatio = useSelector(
|
2022-10-20 09:11:27 +00:00
|
|
|
(state: IReduxState) => state['features/base/responsive-ui']?.aspectRatio
|
2022-06-16 09:49:07 +00:00
|
|
|
);
|
2022-10-20 09:11:27 +00:00
|
|
|
const localParticipant = useSelector((state: IReduxState) => getLocalParticipant(state));
|
|
|
|
const isDisplayNameMandatory = useSelector((state: IReduxState) => isDisplayNameRequired(state));
|
|
|
|
const roomName = useSelector((state: IReduxState) => getConferenceName(state));
|
2022-06-16 09:49:07 +00:00
|
|
|
const participantName = localParticipant?.name;
|
|
|
|
const [ displayName, setDisplayName ]
|
|
|
|
= useState(participantName || '');
|
2022-10-06 10:33:26 +00:00
|
|
|
const [ isJoining, setIsJoining ]
|
|
|
|
= useState(false);
|
2022-06-16 09:49:07 +00:00
|
|
|
const onChangeDisplayName = useCallback(event => {
|
|
|
|
const fieldValue = getFieldValue(event);
|
|
|
|
|
|
|
|
setDisplayName(fieldValue);
|
|
|
|
dispatch(updateSettings({
|
|
|
|
displayName: fieldValue
|
|
|
|
}));
|
|
|
|
}, [ displayName ]);
|
|
|
|
|
|
|
|
const onJoin = useCallback(() => {
|
2022-10-06 10:33:26 +00:00
|
|
|
setIsJoining(true);
|
2022-06-16 09:49:07 +00:00
|
|
|
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 ]);
|
|
|
|
|
2022-11-08 17:14:29 +00:00
|
|
|
const headerLeft = () => {
|
2022-06-16 09:49:07 +00:00
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
label = { t('dialog.close') }
|
|
|
|
onPress = { goBack } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
onPress = { goBack }
|
2022-11-08 10:24:32 +00:00
|
|
|
src = { IconCloseLarge } />
|
2022-06-16 09:49:07 +00:00
|
|
|
);
|
2022-11-08 17:14:29 +00:00
|
|
|
};
|
2022-06-16 09:49:07 +00:00
|
|
|
|
2022-11-08 17:14:29 +00:00
|
|
|
const { PRIMARY, TERTIARY } = BUTTON_TYPES;
|
2022-11-21 14:07:27 +00:00
|
|
|
const joinButtonDisabled = !displayName && isDisplayNameMandatory;
|
2022-06-21 14:16:38 +00:00
|
|
|
|
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-07-11 12:30:37 +00:00
|
|
|
}, []);
|
2022-06-20 11:40:34 +00:00
|
|
|
|
2022-06-16 09:49:07 +00:00
|
|
|
useLayoutEffect(() => {
|
|
|
|
navigation.setOptions({
|
2022-10-12 12:43:11 +00:00
|
|
|
headerLeft,
|
|
|
|
headerTitle: t('prejoin.joinMeeting')
|
2022-06-16 09:49:07 +00:00
|
|
|
});
|
|
|
|
}, [ 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-11-10 14:48:53 +00:00
|
|
|
addBottomPadding = { false }
|
2022-11-22 16:13:36 +00:00
|
|
|
safeAreaInsets = { [ 'right' ] }
|
2022-06-16 09:49:07 +00:00
|
|
|
style = { contentWrapperStyles }>
|
2022-06-18 19:59:10 +00:00
|
|
|
<BrandingImageBackground />
|
2022-08-30 15:56:05 +00:00
|
|
|
{
|
|
|
|
isFocused
|
|
|
|
&& <View style = { largeVideoContainerStyles }>
|
2022-11-08 17:14:29 +00:00
|
|
|
<View style = { styles.displayRoomNameBackdrop as StyleProp<TextStyle> }>
|
2022-10-12 12:43:11 +00:00
|
|
|
<Text
|
|
|
|
numberOfLines = { 1 }
|
|
|
|
style = { styles.preJoinRoomName as StyleProp<TextStyle> }>
|
|
|
|
{ roomName }
|
|
|
|
</Text>
|
|
|
|
</View>
|
2022-11-21 14:07:27 +00:00
|
|
|
{/* @ts-ignore */}
|
2022-11-08 17:14:29 +00:00
|
|
|
<LargeVideo />
|
2022-08-30 15:56:05 +00:00
|
|
|
</View>
|
|
|
|
}
|
2022-06-16 09:49:07 +00:00
|
|
|
<View style = { contentContainerStyles }>
|
2022-11-08 17:14:29 +00:00
|
|
|
<View style = { toolboxContainerStyles }>
|
|
|
|
<AudioMuteButton
|
2022-11-10 14:48:53 +00:00
|
|
|
// @ts-ignore
|
2022-11-08 17:14:29 +00:00
|
|
|
styles = { styles.buttonStylesBorderless } />
|
|
|
|
<VideoMuteButton
|
2022-11-10 14:48:53 +00:00
|
|
|
// @ts-ignore
|
2022-11-08 17:14:29 +00:00
|
|
|
styles = { styles.buttonStylesBorderless } />
|
|
|
|
</View>
|
2022-07-11 12:30:37 +00:00
|
|
|
<View style = { styles.formWrapper as StyleProp<ViewStyle> }>
|
2022-11-08 15:46:46 +00:00
|
|
|
<Input
|
|
|
|
// @ts-ignore
|
|
|
|
customStyles = {{ input: styles.customInput }}
|
|
|
|
onChange = { onChangeDisplayName }
|
2022-06-16 09:49:07 +00:00
|
|
|
placeholder = { t('dialog.enterDisplayName') }
|
|
|
|
value = { displayName } />
|
2022-07-07 12:29:18 +00:00
|
|
|
<Button
|
|
|
|
accessibilityLabel = 'prejoin.joinMeeting'
|
2022-06-21 14:16:38 +00:00
|
|
|
disabled = { joinButtonDisabled }
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'prejoin.joinMeeting'
|
2022-11-21 14:07:27 +00:00
|
|
|
// @ts-ignore
|
|
|
|
onClick = { !isJoining && onJoin }
|
2022-10-12 12:43:11 +00:00
|
|
|
style = { styles.joinButton }
|
2022-07-07 12:29:18 +00:00
|
|
|
type = { PRIMARY } />
|
|
|
|
<Button
|
|
|
|
accessibilityLabel = 'prejoin.joinMeetingInLowBandwidthMode'
|
2022-10-06 10:33:26 +00:00
|
|
|
disabled = { joinButtonDisabled }
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'prejoin.joinMeetingInLowBandwidthMode'
|
|
|
|
onClick = { onJoinLowBandwidth }
|
2022-11-22 16:13:36 +00:00
|
|
|
style = { styles.joinButton }
|
2022-11-08 17:14:29 +00:00
|
|
|
type = { TERTIARY } />
|
2022-06-16 09:49:07 +00:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</JitsiScreen>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Prejoin;
|