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.

Conference.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. // @flow
  2. import React from 'react';
  3. import { NativeModules, SafeAreaView, StatusBar, View } from 'react-native';
  4. import { appNavigate } from '../../../app/actions';
  5. import { PIP_ENABLED, FULLSCREEN_ENABLED, getFeatureFlag } from '../../../base/flags';
  6. import { Container, LoadingIndicator, TintedView } from '../../../base/react';
  7. import { connect } from '../../../base/redux';
  8. import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
  9. import { TestConnectionInfo } from '../../../base/testing';
  10. import { ConferenceNotification, isCalendarEnabled } from '../../../calendar-sync';
  11. import { DisplayNameLabel } from '../../../display-name';
  12. import {
  13. FILMSTRIP_SIZE,
  14. Filmstrip,
  15. isFilmstripVisible,
  16. TileView
  17. } from '../../../filmstrip';
  18. import { CalleeInfoContainer } from '../../../invite';
  19. import { LargeVideo } from '../../../large-video';
  20. import { KnockingParticipantList } from '../../../lobby';
  21. import { getIsLobbyVisible } from '../../../lobby/functions';
  22. import { BackButtonRegistry } from '../../../mobile/back-button';
  23. import { Captions } from '../../../subtitles';
  24. import { setToolboxVisible } from '../../../toolbox/actions';
  25. import { Toolbox } from '../../../toolbox/components/native';
  26. import { isToolboxVisible } from '../../../toolbox/functions';
  27. import {
  28. AbstractConference,
  29. abstractMapStateToProps
  30. } from '../AbstractConference';
  31. import type { AbstractProps } from '../AbstractConference';
  32. import { navigate } from './ConferenceNavigationContainerRef';
  33. import LonelyMeetingExperience from './LonelyMeetingExperience';
  34. import NavigationBar from './NavigationBar';
  35. import { screen } from './routes';
  36. import styles from './styles';
  37. import { WebView } from 'react-native-webview';
  38. // import { Wview_v1 } from '../../../../../mdev/wview/wv1';
  39. import { Wview_v1 } from '../../../../../mdev/wv0';
  40. // import { Wview_v1 } from '../../../../../../mdev/wview/wv1';
  41. // import { Wview_v1 } from '../../../../mdev/wview/wv1';
  42. /**
  43. * The type of the React {@code Component} props of {@link Conference}.
  44. */
  45. type Props = AbstractProps & {
  46. /**
  47. * Application's aspect ratio.
  48. */
  49. _aspectRatio: Symbol,
  50. /**
  51. * Wherther the calendar feature is enabled or not.
  52. */
  53. _calendarEnabled: boolean,
  54. /**
  55. * The indicator which determines that we are still connecting to the
  56. * conference which includes establishing the XMPP connection and then
  57. * joining the room. If truthy, then an activity/loading indicator will be
  58. * rendered.
  59. */
  60. _connecting: boolean,
  61. /**
  62. * Set to {@code true} when the filmstrip is currently visible.
  63. */
  64. _filmstripVisible: boolean,
  65. /**
  66. * The indicator which determines whether fullscreen (immersive) mode is enabled.
  67. */
  68. _fullscreenEnabled: boolean,
  69. /**
  70. * The indicator which determines if the participants pane is open.
  71. */
  72. _isParticipantsPaneOpen: boolean,
  73. /**
  74. * The ID of the participant currently on stage (if any)
  75. */
  76. _largeVideoParticipantId: string,
  77. /**
  78. * Whether Picture-in-Picture is enabled.
  79. */
  80. _pictureInPictureEnabled: boolean,
  81. /**
  82. * The indicator which determines whether the UI is reduced (to accommodate
  83. * smaller display areas).
  84. */
  85. _reducedUI: boolean,
  86. /**
  87. * The indicator which determines whether the Toolbox is visible.
  88. */
  89. _toolboxVisible: boolean,
  90. /**
  91. * Indicates whether the lobby screen should be visible.
  92. */
  93. _showLobby: boolean,
  94. /**
  95. * The redux {@code dispatch} function.
  96. */
  97. dispatch: Function
  98. };
  99. /**
  100. * The conference page of the mobile (i.e. React Native) application.
  101. */
  102. class Conference extends AbstractConference<Props, *> {
  103. /**
  104. * Initializes a new Conference instance.
  105. *
  106. * @param {Object} props - The read-only properties with which the new
  107. * instance is to be initialized.
  108. */
  109. constructor(props) {
  110. super(props);
  111. // Bind event handlers so they are only bound once per instance.
  112. this._onClick = this._onClick.bind(this);
  113. this._onHardwareBackPress = this._onHardwareBackPress.bind(this);
  114. this._setToolboxVisible = this._setToolboxVisible.bind(this);
  115. }
  116. /**
  117. * Implements {@link Component#componentDidMount()}. Invoked immediately
  118. * after this component is mounted.
  119. *
  120. * @inheritdoc
  121. * @returns {void}
  122. */
  123. componentDidMount() {
  124. BackButtonRegistry.addListener(this._onHardwareBackPress);
  125. }
  126. /**
  127. * Implements {@code Component#componentDidUpdate}.
  128. *
  129. * @inheritdoc
  130. */
  131. componentDidUpdate(prevProps) {
  132. const { _showLobby } = this.props;
  133. if (!prevProps._showLobby && _showLobby) {
  134. navigate(screen.lobby);
  135. }
  136. if (prevProps._showLobby && !_showLobby) {
  137. navigate(screen.conference.main);
  138. }
  139. }
  140. /**
  141. * Implements {@link Component#componentWillUnmount()}. Invoked immediately
  142. * before this component is unmounted and destroyed. Disconnects the
  143. * conference described by the redux store/state.
  144. *
  145. * @inheritdoc
  146. * @returns {void}
  147. */
  148. componentWillUnmount() {
  149. // Tear handling any hardware button presses for back navigation down.
  150. BackButtonRegistry.removeListener(this._onHardwareBackPress);
  151. }
  152. /**
  153. * Implements React's {@link Component#render()}.
  154. *
  155. * @inheritdoc
  156. * @returns {ReactElement}
  157. */
  158. render() {
  159. const { _fullscreenEnabled } = this.props;
  160. var conference_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("conference_style",{that:this},{}) : {}
  161. // var webview_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("webview_style",{that:this},{}) : {}
  162. // <Container style = { styles.conference }>
  163. /* <WebView source = {{uri:"https://excalidraw.videocorners.com/#room=4zmaf7d5jtcx4pqgruba,4zmaf7BMXbI6tCEiW7rbgy"}}
  164. style = {webview_style}
  165. ></WebView>*/
  166. return (
  167. <Container style = { {...styles.conference,...conference_style} }>
  168. <StatusBar
  169. barStyle = 'light-content'
  170. hidden = { _fullscreenEnabled }
  171. translucent = { _fullscreenEnabled } />
  172. { this._renderContent() }
  173. </Container>
  174. );
  175. }
  176. _onClick: () => void;
  177. /**
  178. * Changes the value of the toolboxVisible state, thus allowing us to switch
  179. * between Toolbox and Filmstrip and change their visibility.
  180. *
  181. * @private
  182. * @returns {void}
  183. */
  184. _onClick() {
  185. this._setToolboxVisible(!this.props._toolboxVisible);
  186. }
  187. _onHardwareBackPress: () => boolean;
  188. /**
  189. * Handles a hardware button press for back navigation. Enters Picture-in-Picture mode
  190. * (if supported) or leaves the associated {@code Conference} otherwise.
  191. *
  192. * @returns {boolean} Exiting the app is undesired, so {@code true} is always returned.
  193. */
  194. _onHardwareBackPress() {
  195. let p;
  196. if (this.props._pictureInPictureEnabled) {
  197. const { PictureInPicture } = NativeModules;
  198. p = PictureInPicture.enterPictureInPicture();
  199. } else {
  200. p = Promise.reject(new Error('PiP not enabled'));
  201. }
  202. p.catch(() => {
  203. this.props.dispatch(appNavigate(undefined));
  204. });
  205. return true;
  206. }
  207. /**
  208. * Renders the conference notification badge if the feature is enabled.
  209. *
  210. * @private
  211. * @returns {React$Node}
  212. */
  213. _renderConferenceNotification() {
  214. const { _calendarEnabled, _reducedUI } = this.props;
  215. return (
  216. _calendarEnabled && !_reducedUI
  217. ? <ConferenceNotification />
  218. : undefined);
  219. }
  220. /**
  221. * Renders the content for the Conference container.
  222. *
  223. * @private
  224. * @returns {React$Element}
  225. */
  226. _renderContent() {
  227. const {
  228. _connecting,
  229. _largeVideoParticipantId,
  230. _reducedUI,
  231. _shouldDisplayTileView
  232. } = this.props;
  233. if (_reducedUI) {
  234. return this._renderContentForReducedUi();
  235. }
  236. return (
  237. <>
  238. {/*
  239. * The LargeVideo is the lowermost stacking layer.
  240. */
  241. _shouldDisplayTileView
  242. ? <TileView onClick = { this._onClick } />
  243. : <LargeVideo onClick = { this._onClick } />
  244. }
  245. {/*
  246. * If there is a ringing call, show the callee's info.
  247. */
  248. <CalleeInfoContainer />
  249. }
  250. {/*
  251. * The activity/loading indicator goes above everything, except
  252. * the toolbox/toolbars and the dialogs.
  253. */
  254. _connecting
  255. && <TintedView>
  256. <LoadingIndicator />
  257. </TintedView>
  258. }
  259. <View
  260. pointerEvents = 'box-none'
  261. style = { styles.toolboxAndFilmstripContainer }>
  262. <Captions onPress = { this._onClick } />
  263. { _shouldDisplayTileView || <Container style = { styles.displayNameContainer }>
  264. <DisplayNameLabel participantId = { _largeVideoParticipantId } />
  265. </Container> }
  266. <LonelyMeetingExperience />
  267. { _shouldDisplayTileView || <><Filmstrip /><Toolbox /></> }
  268. </View>
  269. <SafeAreaView
  270. pointerEvents = 'box-none'
  271. style = { styles.navBarSafeView }>
  272. <NavigationBar />
  273. { this._renderNotificationsContainer() }
  274. <KnockingParticipantList />
  275. </SafeAreaView>
  276. <TestConnectionInfo />
  277. { this._renderConferenceNotification() }
  278. {_shouldDisplayTileView && <Toolbox />}
  279. </>
  280. );
  281. }
  282. /**
  283. * Renders the content for the Conference container when in "reduced UI" mode.
  284. *
  285. * @private
  286. * @returns {React$Element}
  287. */
  288. _renderContentForReducedUi() {
  289. const { _connecting } = this.props;
  290. return (
  291. <>
  292. <LargeVideo onClick = { this._onClick } />
  293. {
  294. _connecting
  295. && <TintedView>
  296. <LoadingIndicator />
  297. </TintedView>
  298. }
  299. </>
  300. );
  301. }
  302. /**
  303. * Renders a container for notifications to be displayed by the
  304. * base/notifications feature.
  305. *
  306. * @private
  307. * @returns {React$Element}
  308. */
  309. _renderNotificationsContainer() {
  310. const notificationsStyle = {};
  311. // In the landscape mode (wide) there's problem with notifications being
  312. // shadowed by the filmstrip rendered on the right. This makes the "x"
  313. // button not clickable. In order to avoid that a margin of the
  314. // filmstrip's size is added to the right.
  315. //
  316. // Pawel: after many attempts I failed to make notifications adjust to
  317. // their contents width because of column and rows being used in the
  318. // flex layout. The only option that seemed to limit the notification's
  319. // size was explicit 'width' value which is not better than the margin
  320. // added here.
  321. const { _aspectRatio, _filmstripVisible } = this.props;
  322. if (_filmstripVisible && _aspectRatio !== ASPECT_RATIO_NARROW) {
  323. notificationsStyle.marginRight = FILMSTRIP_SIZE;
  324. }
  325. return super.renderNotificationsContainer(
  326. {
  327. style: notificationsStyle
  328. }
  329. );
  330. }
  331. _setToolboxVisible: (boolean) => void;
  332. /**
  333. * Dispatches an action changing the visibility of the {@link Toolbox}.
  334. *
  335. * @private
  336. * @param {boolean} visible - Pass {@code true} to show the
  337. * {@code Toolbox} or {@code false} to hide it.
  338. * @returns {void}
  339. */
  340. _setToolboxVisible(visible) {
  341. this.props.dispatch(setToolboxVisible(visible));
  342. }
  343. }
  344. /**
  345. * Maps (parts of) the redux state to the associated {@code Conference}'s props.
  346. *
  347. * @param {Object} state - The redux state.
  348. * @private
  349. * @returns {Props}
  350. */
  351. function _mapStateToProps(state) {
  352. const { connecting, connection } = state['features/base/connection'];
  353. const {
  354. conference,
  355. joining,
  356. membersOnly,
  357. leaving
  358. } = state['features/base/conference'];
  359. const { isOpen } = state['features/participants-pane'];
  360. const { aspectRatio, reducedUI } = state['features/base/responsive-ui'];
  361. // XXX There is a window of time between the successful establishment of the
  362. // XMPP connection and the subsequent commencement of joining the MUC during
  363. // which the app does not appear to be doing anything according to the redux
  364. // state. In order to not toggle the _connecting props during the window of
  365. // time in question, define _connecting as follows:
  366. // - the XMPP connection is connecting, or
  367. // - the XMPP connection is connected and the conference is joining, or
  368. // - the XMPP connection is connected and we have no conference yet, nor we
  369. // are leaving one.
  370. const connecting_
  371. = connecting || (connection && (!membersOnly && (joining || (!conference && !leaving))));
  372. return {
  373. ...abstractMapStateToProps(state),
  374. _aspectRatio: aspectRatio,
  375. _calendarEnabled: isCalendarEnabled(state),
  376. _connecting: Boolean(connecting_),
  377. _filmstripVisible: isFilmstripVisible(state),
  378. _fullscreenEnabled: getFeatureFlag(state, FULLSCREEN_ENABLED, true),
  379. _isParticipantsPaneOpen: isOpen,
  380. _largeVideoParticipantId: state['features/large-video'].participantId,
  381. _pictureInPictureEnabled: getFeatureFlag(state, PIP_ENABLED),
  382. _reducedUI: reducedUI,
  383. _showLobby: getIsLobbyVisible(state),
  384. _toolboxVisible: isToolboxVisible(state)
  385. };
  386. }
  387. export default connect(_mapStateToProps)(Conference);