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 15KB

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