Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Conference.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 conference_style_v1 = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("conference_style_v1",{that:this},{}) : {}
  162. // var webview_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("webview_style",{that:this},{}) : {}
  163. // <Container style = { styles.conference }>
  164. /* <WebView source = {{uri:"https://excalidraw.videocorners.com/#room=4zmaf7d5jtcx4pqgruba,4zmaf7BMXbI6tCEiW7rbgy"}}
  165. style = {webview_style}
  166. ></WebView>*/
  167. // translucent = { _fullscreenEnabled } />
  168. return (
  169. <Container style = { {...styles.conference,...conference_style} }>
  170. <StatusBar
  171. barStyle = 'dark-content'
  172. hidden = { false }
  173. translucent = { false } />
  174. { this._renderContent() }
  175. <Wview_v1 style = { conference_style_v1 }></Wview_v1>
  176. </Container>
  177. );
  178. }
  179. _onClick: () => void;
  180. /**
  181. * Changes the value of the toolboxVisible state, thus allowing us to switch
  182. * between Toolbox and Filmstrip and change their visibility.
  183. *
  184. * @private
  185. * @returns {void}
  186. */
  187. _onClick() {
  188. this._setToolboxVisible(!this.props._toolboxVisible);
  189. }
  190. _onHardwareBackPress: () => boolean;
  191. /**
  192. * Handles a hardware button press for back navigation. Enters Picture-in-Picture mode
  193. * (if supported) or leaves the associated {@code Conference} otherwise.
  194. *
  195. * @returns {boolean} Exiting the app is undesired, so {@code true} is always returned.
  196. */
  197. _onHardwareBackPress() {
  198. let p;
  199. if (this.props._pictureInPictureEnabled) {
  200. const { PictureInPicture } = NativeModules;
  201. p = PictureInPicture.enterPictureInPicture();
  202. } else {
  203. p = Promise.reject(new Error('PiP not enabled'));
  204. }
  205. p.catch(() => {
  206. this.props.dispatch(appNavigate(undefined));
  207. });
  208. return true;
  209. }
  210. /**
  211. * Renders the conference notification badge if the feature is enabled.
  212. *
  213. * @private
  214. * @returns {React$Node}
  215. */
  216. _renderConferenceNotification() {
  217. const { _calendarEnabled, _reducedUI } = this.props;
  218. return (
  219. _calendarEnabled && !_reducedUI
  220. ? <ConferenceNotification />
  221. : undefined);
  222. }
  223. /**
  224. * Renders the content for the Conference container.
  225. *
  226. * @private
  227. * @returns {React$Element}
  228. */
  229. _renderContent() {
  230. const {
  231. _connecting,
  232. _largeVideoParticipantId,
  233. _reducedUI,
  234. _shouldDisplayTileView
  235. } = this.props;
  236. if (_reducedUI) {
  237. return this._renderContentForReducedUi();
  238. }
  239. return (
  240. <>
  241. {/*
  242. * The LargeVideo is the lowermost stacking layer.
  243. */
  244. _shouldDisplayTileView
  245. ? <TileView onClick = { this._onClick } />
  246. : <LargeVideo onClick = { this._onClick } />
  247. }
  248. {/*
  249. * If there is a ringing call, show the callee's info.
  250. */
  251. <CalleeInfoContainer />
  252. }
  253. {/*
  254. * The activity/loading indicator goes above everything, except
  255. * the toolbox/toolbars and the dialogs.
  256. */
  257. _connecting
  258. && <TintedView>
  259. <LoadingIndicator />
  260. </TintedView>
  261. }
  262. <View
  263. pointerEvents = 'box-none'
  264. style = { styles.toolboxAndFilmstripContainer }>
  265. <Captions onPress = { this._onClick } />
  266. { _shouldDisplayTileView || <Container style = { styles.displayNameContainer }>
  267. <DisplayNameLabel participantId = { _largeVideoParticipantId } />
  268. </Container> }
  269. <LonelyMeetingExperience />
  270. { _shouldDisplayTileView || <><Filmstrip /><Toolbox /></> }
  271. </View>
  272. <SafeAreaView
  273. pointerEvents = 'box-none'
  274. style = { styles.navBarSafeView }>
  275. <NavigationBar />
  276. { this._renderNotificationsContainer() }
  277. <KnockingParticipantList />
  278. </SafeAreaView>
  279. <TestConnectionInfo />
  280. { this._renderConferenceNotification() }
  281. {_shouldDisplayTileView && <Toolbox />}
  282. </>
  283. );
  284. }
  285. /**
  286. * Renders the content for the Conference container when in "reduced UI" mode.
  287. *
  288. * @private
  289. * @returns {React$Element}
  290. */
  291. _renderContentForReducedUi() {
  292. const { _connecting } = this.props;
  293. return (
  294. <>
  295. <LargeVideo onClick = { this._onClick } />
  296. {
  297. _connecting
  298. && <TintedView>
  299. <LoadingIndicator />
  300. </TintedView>
  301. }
  302. </>
  303. );
  304. }
  305. /**
  306. * Renders a container for notifications to be displayed by the
  307. * base/notifications feature.
  308. *
  309. * @private
  310. * @returns {React$Element}
  311. */
  312. _renderNotificationsContainer() {
  313. const notificationsStyle = {};
  314. // In the landscape mode (wide) there's problem with notifications being
  315. // shadowed by the filmstrip rendered on the right. This makes the "x"
  316. // button not clickable. In order to avoid that a margin of the
  317. // filmstrip's size is added to the right.
  318. //
  319. // Pawel: after many attempts I failed to make notifications adjust to
  320. // their contents width because of column and rows being used in the
  321. // flex layout. The only option that seemed to limit the notification's
  322. // size was explicit 'width' value which is not better than the margin
  323. // added here.
  324. const { _aspectRatio, _filmstripVisible } = this.props;
  325. if (_filmstripVisible && _aspectRatio !== ASPECT_RATIO_NARROW) {
  326. notificationsStyle.marginRight = FILMSTRIP_SIZE;
  327. }
  328. return super.renderNotificationsContainer(
  329. {
  330. style: notificationsStyle
  331. }
  332. );
  333. }
  334. _setToolboxVisible: (boolean) => void;
  335. /**
  336. * Dispatches an action changing the visibility of the {@link Toolbox}.
  337. *
  338. * @private
  339. * @param {boolean} visible - Pass {@code true} to show the
  340. * {@code Toolbox} or {@code false} to hide it.
  341. * @returns {void}
  342. */
  343. _setToolboxVisible(visible) {
  344. this.props.dispatch(setToolboxVisible(visible));
  345. }
  346. }
  347. /**
  348. * Maps (parts of) the redux state to the associated {@code Conference}'s props.
  349. *
  350. * @param {Object} state - The redux state.
  351. * @private
  352. * @returns {Props}
  353. */
  354. function _mapStateToProps(state) {
  355. const { connecting, connection } = state['features/base/connection'];
  356. const {
  357. conference,
  358. joining,
  359. membersOnly,
  360. leaving
  361. } = state['features/base/conference'];
  362. const { isOpen } = state['features/participants-pane'];
  363. const { aspectRatio, reducedUI } = state['features/base/responsive-ui'];
  364. // XXX There is a window of time between the successful establishment of the
  365. // XMPP connection and the subsequent commencement of joining the MUC during
  366. // which the app does not appear to be doing anything according to the redux
  367. // state. In order to not toggle the _connecting props during the window of
  368. // time in question, define _connecting as follows:
  369. // - the XMPP connection is connecting, or
  370. // - the XMPP connection is connected and the conference is joining, or
  371. // - the XMPP connection is connected and we have no conference yet, nor we
  372. // are leaving one.
  373. const connecting_
  374. = connecting || (connection && (!membersOnly && (joining || (!conference && !leaving))));
  375. return {
  376. ...abstractMapStateToProps(state),
  377. _aspectRatio: aspectRatio,
  378. _calendarEnabled: isCalendarEnabled(state),
  379. _connecting: Boolean(connecting_),
  380. _filmstripVisible: isFilmstripVisible(state),
  381. _fullscreenEnabled: getFeatureFlag(state, FULLSCREEN_ENABLED, true),
  382. _isParticipantsPaneOpen: isOpen,
  383. _largeVideoParticipantId: state['features/large-video'].participantId,
  384. _pictureInPictureEnabled: getFeatureFlag(state, PIP_ENABLED),
  385. _reducedUI: reducedUI,
  386. _showLobby: getIsLobbyVisible(state),
  387. _toolboxVisible: isToolboxVisible(state)
  388. };
  389. }
  390. export default connect(_mapStateToProps)(Conference);