Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

LobbyScreen.js 9.6KB

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