You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LobbyScreen.js 9.6KB

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