您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LobbyScreen.js 9.1KB

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