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

Prejoin.native.tsx 5.4KB

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