Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Prejoin.native.tsx 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { Text, View, TouchableOpacity, TextInput, Platform, BackHandler } from 'react-native';
  4. import { useDispatch, useSelector } from 'react-redux';
  5. import { appNavigate } from '../../app/actions.native';
  6. import { setAudioOnly } from '../../base/audio-only/actions';
  7. import { connect } from '../../base/connection/actions.native';
  8. import { IconClose } from '../../base/icons';
  9. import JitsiScreen from '../../base/modal/components/JitsiScreen';
  10. import { getLocalParticipant } from '../../base/participants';
  11. import { getFieldValue } from '../../base/react';
  12. import { ASPECT_RATIO_NARROW } from '../../base/responsive-ui';
  13. import { updateSettings } from '../../base/settings';
  14. import { BrandingImageBackground } from '../../dynamic-branding';
  15. import { LargeVideo } from '../../large-video/components';
  16. import HeaderNavigationButton from '../../mobile/navigation/components/HeaderNavigationButton';
  17. import { navigateRoot } from '../../mobile/navigation/rootNavigationContainerRef';
  18. import { screen } from '../../mobile/navigation/routes';
  19. import AudioMuteButton from '../../toolbox/components/AudioMuteButton';
  20. import VideoMuteButton from '../../toolbox/components/VideoMuteButton';
  21. import styles from './styles';
  22. interface Props {
  23. navigation: any;
  24. }
  25. const Prejoin: ({ navigation }: Props) => JSX.Element = ({ navigation }: Props) => {
  26. const dispatch = useDispatch();
  27. const { t } = useTranslation();
  28. const aspectRatio = useSelector(
  29. (state: any) => state['features/base/responsive-ui']?.aspectRatio
  30. );
  31. const localParticipant = useSelector(state => getLocalParticipant(state));
  32. const participantName = localParticipant?.name;
  33. const [ displayName, setDisplayName ]
  34. = useState(participantName || '');
  35. const onChangeDisplayName = useCallback(event => {
  36. const fieldValue = getFieldValue(event);
  37. setDisplayName(fieldValue);
  38. dispatch(updateSettings({
  39. displayName: fieldValue
  40. }));
  41. }, [ displayName ]);
  42. const onJoin = useCallback(() => {
  43. dispatch(connect());
  44. navigateRoot(screen.conference.root);
  45. }, [ dispatch ]);
  46. const onJoinLowBandwidth = useCallback(() => {
  47. dispatch(setAudioOnly(true));
  48. onJoin();
  49. }, [ dispatch ]);
  50. const goBack = useCallback(() => {
  51. dispatch(appNavigate(undefined));
  52. return true;
  53. }, [ dispatch ]);
  54. let contentWrapperStyles;
  55. let contentContainerStyles;
  56. let largeVideoContainerStyles;
  57. let toolboxContainerStyles;
  58. if (aspectRatio === ASPECT_RATIO_NARROW) {
  59. contentWrapperStyles = styles.contentWrapper;
  60. contentContainerStyles = styles.contentContainer;
  61. largeVideoContainerStyles = styles.largeVideoContainer;
  62. toolboxContainerStyles = styles.toolboxContainer;
  63. } else {
  64. contentWrapperStyles = styles.contentWrapperWide;
  65. contentContainerStyles = styles.contentContainerWide;
  66. largeVideoContainerStyles = styles.largeVideoContainerWide;
  67. toolboxContainerStyles = styles.toolboxContainerWide;
  68. }
  69. const headerLeft = useCallback(() => {
  70. if (Platform.OS === 'ios') {
  71. return (
  72. <HeaderNavigationButton
  73. label = { t('dialog.close') }
  74. onPress = { goBack } />
  75. );
  76. }
  77. return (
  78. <HeaderNavigationButton
  79. onPress = { goBack }
  80. src = { IconClose } />
  81. );
  82. }, []);
  83. useEffect(() => {
  84. BackHandler.addEventListener('hardwareBackPress', goBack);
  85. return () => BackHandler.removeEventListener('hardwareBackPress', goBack)
  86. }, [ ]);
  87. useLayoutEffect(() => {
  88. navigation.setOptions({
  89. headerLeft
  90. });
  91. }, [ navigation ]);
  92. return (
  93. <JitsiScreen
  94. safeAreaInsets = { [ 'right' ] }
  95. style = { contentWrapperStyles }>
  96. <BrandingImageBackground />
  97. <View style = { largeVideoContainerStyles }>
  98. <LargeVideo />
  99. </View>
  100. <View style = { contentContainerStyles }>
  101. <View style = { styles.formWrapper }>
  102. <TextInput
  103. onChangeText = { onChangeDisplayName }
  104. placeholder = { t('dialog.enterDisplayName') }
  105. style = { styles.field }
  106. value = { displayName } />
  107. <TouchableOpacity
  108. onPress = { onJoin }
  109. style = { [
  110. styles.button,
  111. styles.primaryButton
  112. ] }>
  113. <Text style = { styles.primaryButtonText }>
  114. { t('prejoin.joinMeeting') }
  115. </Text>
  116. </TouchableOpacity>
  117. <TouchableOpacity
  118. onPress = { onJoinLowBandwidth }
  119. style = { [
  120. styles.button,
  121. styles.secondaryButton
  122. ] }>
  123. <Text style = { styles.secondaryButtonText }>
  124. { t('prejoin.joinMeetingInLowBandwidthMode') }
  125. </Text>
  126. </TouchableOpacity>
  127. </View>
  128. <View style = { toolboxContainerStyles }>
  129. <AudioMuteButton
  130. styles = { styles.buttonStylesBorderless } />
  131. <VideoMuteButton
  132. styles = { styles.buttonStylesBorderless } />
  133. </View>
  134. </View>
  135. </JitsiScreen>
  136. );
  137. };
  138. export default Prejoin;