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

LobbyScreen.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. // @flow
  2. import React from 'react';
  3. import { Text, View, TouchableOpacity, TextInput } from 'react-native';
  4. import { translate } from '../../../base/i18n';
  5. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  6. import { LoadingIndicator } from '../../../base/react';
  7. import { connect } from '../../../base/redux';
  8. import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui';
  9. import BaseTheme from '../../../base/ui/components/BaseTheme';
  10. import { LargeVideo } from '../../../large-video/components';
  11. import { navigate }
  12. from '../../../mobile/navigation/components/lobby/LobbyNavigationContainerRef';
  13. import { screen } from '../../../mobile/navigation/routes';
  14. import AudioMuteButton from '../../../toolbox/components/AudioMuteButton';
  15. import VideoMuteButton from '../../../toolbox/components/VideoMuteButton';
  16. import AbstractLobbyScreen, {
  17. Props as AbstractProps,
  18. _mapStateToProps as abstractMapStateToProps } from '../AbstractLobbyScreen';
  19. import styles from './styles';
  20. type Props = AbstractProps & {
  21. /**
  22. * The current aspect ratio of the screen.
  23. */
  24. _aspectRatio: Symbol
  25. }
  26. /**
  27. * Implements a waiting screen that represents the participant being in the lobby.
  28. */
  29. class LobbyScreen extends AbstractLobbyScreen<Props> {
  30. /**
  31. * Implements {@code PureComponent#render}.
  32. *
  33. * @inheritdoc
  34. */
  35. render() {
  36. const { _aspectRatio } = this.props;
  37. let contentWrapperStyles;
  38. let contentContainerStyles;
  39. let largeVideoContainerStyles;
  40. if (_aspectRatio === ASPECT_RATIO_NARROW) {
  41. contentWrapperStyles = styles.contentWrapper;
  42. largeVideoContainerStyles = styles.largeVideoContainer;
  43. contentContainerStyles = styles.contentContainer;
  44. } else {
  45. contentWrapperStyles = styles.contentWrapperWide;
  46. largeVideoContainerStyles = styles.largeVideoContainerWide;
  47. contentContainerStyles = styles.contentContainerWide;
  48. }
  49. return (
  50. <JitsiScreen
  51. style = { contentWrapperStyles }>
  52. <View style = { largeVideoContainerStyles }>
  53. <LargeVideo />
  54. </View>
  55. <View style = { contentContainerStyles }>
  56. { this._renderContent() }
  57. { this._renderToolbarButtons() }
  58. </View>
  59. </JitsiScreen>
  60. );
  61. }
  62. _getScreenTitleKey: () => string;
  63. _onAskToJoin: () => void;
  64. _onCancel: () => boolean;
  65. _onChangeDisplayName: Object => void;
  66. _onChangeEmail: Object => void;
  67. _onChangePassword: Object => void;
  68. _onEnableEdit: () => void;
  69. _onJoinWithPassword: () => void;
  70. _onSwitchToKnockMode: () => void;
  71. _onSwitchToPasswordMode: () => void;
  72. _renderContent: () => React$Element<*>;
  73. _renderToolbarButtons: () => React$Element<*>;
  74. _onNavigateToLobbyChat: () => void;
  75. /**
  76. * Navigates to the lobby chat screen.
  77. *
  78. * @private
  79. * @returns {void}
  80. */
  81. _onNavigateToLobbyChat() {
  82. navigate(screen.lobby.chat);
  83. }
  84. /**
  85. * Renders the joining (waiting) fragment of the screen.
  86. *
  87. * @inheritdoc
  88. */
  89. _renderJoining() {
  90. return (
  91. <View>
  92. <LoadingIndicator
  93. color = { BaseTheme.palette.icon01 }
  94. style = { styles.loadingIndicator } />
  95. <Text style = { styles.joiningMessage }>
  96. { this.props.t('lobby.joiningMessage') }
  97. </Text>
  98. { this._renderStandardButtons() }
  99. </View>
  100. );
  101. }
  102. /**
  103. * Renders the participant form to let the knocking participant enter its details.
  104. *
  105. * @inheritdoc
  106. */
  107. _renderParticipantForm() {
  108. const { t } = this.props;
  109. const { displayName } = this.state;
  110. return (
  111. <TextInput
  112. onChangeText = { this._onChangeDisplayName }
  113. placeholder = { t('lobby.nameField') }
  114. style = { styles.field }
  115. value = { displayName } />
  116. );
  117. }
  118. /**
  119. * Renders the participant info fragment when we have all the required details of the user.
  120. *
  121. * @inheritdoc
  122. */
  123. _renderParticipantInfo() {
  124. return this._renderParticipantForm();
  125. }
  126. /**
  127. * Renders the password form to let the participant join by using a password instead of knocking.
  128. *
  129. * @inheritdoc
  130. */
  131. _renderPasswordForm() {
  132. const { _passwordJoinFailed, t } = this.props;
  133. return (
  134. <View style = { styles.formWrapper }>
  135. <TextInput
  136. autoCapitalize = 'none'
  137. autoCompleteType = 'off'
  138. onChangeText = { this._onChangePassword }
  139. placeholder = { t('lobby.passwordField') }
  140. secureTextEntry = { true }
  141. style = { styles.field }
  142. value = { this.state.password } />
  143. { _passwordJoinFailed && <Text style = { styles.fieldError }>
  144. { t('lobby.invalidPassword') }
  145. </Text> }
  146. </View>
  147. );
  148. }
  149. /**
  150. * Renders the password join button (set).
  151. *
  152. * @inheritdoc
  153. */
  154. _renderPasswordJoinButtons() {
  155. const { t } = this.props;
  156. return (
  157. <View style = { styles.passwordJoinButtonsWrapper }>
  158. <TouchableOpacity
  159. onPress = { this._onSwitchToKnockMode }
  160. style = { [
  161. styles.button,
  162. styles.primaryButton
  163. ] }>
  164. <Text style = { styles.primaryButtonText }>
  165. { t('lobby.backToKnockModeButton') }
  166. </Text>
  167. </TouchableOpacity>
  168. <TouchableOpacity
  169. disabled = { !this.state.password }
  170. onPress = { this._onJoinWithPassword }
  171. style = { [
  172. styles.button,
  173. styles.primaryButton
  174. ] }>
  175. <Text style = { styles.primaryButtonText }>
  176. { t('lobby.passwordJoinButton') }
  177. </Text>
  178. </TouchableOpacity>
  179. </View>
  180. );
  181. }
  182. /**
  183. * Renders the toolbar buttons menu.
  184. *
  185. * @inheritdoc
  186. */
  187. _renderToolbarButtons() {
  188. const { _aspectRatio } = this.props;
  189. let toolboxContainerStyles;
  190. if (_aspectRatio === ASPECT_RATIO_NARROW) {
  191. toolboxContainerStyles = styles.toolboxContainer;
  192. } else {
  193. toolboxContainerStyles = styles.toolboxContainerWide;
  194. }
  195. return (
  196. <View style = { toolboxContainerStyles }>
  197. <AudioMuteButton
  198. styles = { styles.buttonStylesBorderless } />
  199. <VideoMuteButton
  200. styles = { styles.buttonStylesBorderless } />
  201. </View>
  202. );
  203. }
  204. /**
  205. * Renders the standard button set.
  206. *
  207. * @inheritdoc
  208. */
  209. _renderStandardButtons() {
  210. const { _knocking, _renderPassword, _isLobbyChatActive, t } = this.props;
  211. const { displayName } = this.state;
  212. const askToJoinButtonStyles
  213. = displayName ? styles.primaryButton : styles.primaryButtonDisabled;
  214. return (
  215. <View style = { styles.standardButtonWrapper }>
  216. { _knocking && _isLobbyChatActive && <TouchableOpacity
  217. onPress = { this._onNavigateToLobbyChat }
  218. style = { [
  219. styles.button,
  220. styles.primaryButton
  221. ] }>
  222. <Text style = { styles.primaryButtonText }>
  223. { t('toolbar.openChat') }
  224. </Text>
  225. </TouchableOpacity>}
  226. { _knocking || <TouchableOpacity
  227. disabled = { !displayName }
  228. onPress = { this._onAskToJoin }
  229. style = { [
  230. styles.button,
  231. askToJoinButtonStyles
  232. ] }>
  233. <Text style = { styles.primaryButtonText }>
  234. { t('lobby.knockButton') }
  235. </Text>
  236. </TouchableOpacity> }
  237. { _renderPassword && <TouchableOpacity
  238. onPress = { this._onSwitchToPasswordMode }
  239. style = { [
  240. styles.button,
  241. styles.primaryButton
  242. ] }>
  243. <Text style = { styles.primaryButtonText }>
  244. { t('lobby.enterPasswordButton') }
  245. </Text>
  246. </TouchableOpacity> }
  247. </View>
  248. );
  249. }
  250. }
  251. /**
  252. * Maps part of the Redux state to the props of this component.
  253. *
  254. * @param {Object} state - The Redux state.
  255. * @param {Props} ownProps - The own props of the component.
  256. * @returns {{
  257. * _aspectRatio: Symbol
  258. * }}
  259. */
  260. function _mapStateToProps(state: Object, ownProps: Props) {
  261. return {
  262. ...abstractMapStateToProps(state, ownProps),
  263. _aspectRatio: state['features/base/responsive-ui'].aspectRatio
  264. };
  265. }
  266. export default translate(connect(_mapStateToProps)(LobbyScreen));