Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

OverflowMenu.tsx 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import React, { PureComponent } from 'react';
  2. import { ViewStyle } from 'react-native';
  3. import { Divider } from 'react-native-paper';
  4. import { connect } from 'react-redux';
  5. import { IReduxState, IStore } from '../../../app/types';
  6. import { hideSheet } from '../../../base/dialog/actions';
  7. import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
  8. import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
  9. import SettingsButton from '../../../base/settings/components/native/SettingsButton';
  10. import BreakoutRoomsButton
  11. from '../../../breakout-rooms/components/native/BreakoutRoomsButton';
  12. import SharedDocumentButton from '../../../etherpad/components/SharedDocumentButton.native';
  13. import ReactionMenu from '../../../reactions/components/native/ReactionMenu';
  14. import { shouldDisplayReactionsButtons } from '../../../reactions/functions.any';
  15. import LiveStreamButton from '../../../recording/components/LiveStream/native/LiveStreamButton';
  16. import RecordButton from '../../../recording/components/Recording/native/RecordButton';
  17. import SecurityDialogButton
  18. from '../../../security/components/security-dialog/native/SecurityDialogButton';
  19. import SharedVideoButton from '../../../shared-video/components/native/SharedVideoButton';
  20. import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
  21. import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
  22. import ClosedCaptionButton from '../../../subtitles/components/native/ClosedCaptionButton';
  23. import TileViewButton from '../../../video-layout/components/TileViewButton';
  24. import styles from '../../../video-menu/components/native/styles';
  25. import WhiteboardButton from '../../../whiteboard/components/native/WhiteboardButton';
  26. import { getMovableButtons } from '../../functions.native';
  27. import AudioOnlyButton from './AudioOnlyButton';
  28. import LinkToSalesforceButton from './LinkToSalesforceButton';
  29. import OpenCarmodeButton from './OpenCarmodeButton';
  30. import RaiseHandButton from './RaiseHandButton';
  31. import ScreenSharingButton from './ScreenSharingButton';
  32. /**
  33. * The type of the React {@code Component} props of {@link OverflowMenu}.
  34. */
  35. interface IProps {
  36. /**
  37. * True if breakout rooms feature is available, false otherwise.
  38. */
  39. _isBreakoutRoomsSupported?: boolean;
  40. /**
  41. * True if the overflow menu is currently visible, false otherwise.
  42. */
  43. _isOpen: boolean;
  44. /**
  45. * Whether or not speaker stats is disable.
  46. */
  47. _isSpeakerStatsDisabled?: boolean;
  48. /**
  49. * Whether the recoding button should be enabled or not.
  50. */
  51. _recordingEnabled: boolean;
  52. /**
  53. * Whether or not any reactions buttons should be displayed.
  54. */
  55. _shouldDisplayReactionsButtons: boolean;
  56. /**
  57. * The width of the screen.
  58. */
  59. _width: number;
  60. /**
  61. * Used for hiding the dialog when the selection was completed.
  62. */
  63. dispatch: IStore['dispatch'];
  64. }
  65. interface IState {
  66. /**
  67. * True if the bottom sheet is scrolled to the top.
  68. */
  69. scrolledToTop: boolean;
  70. }
  71. /**
  72. * Implements a React {@code Component} with some extra actions in addition to
  73. * those in the toolbar.
  74. */
  75. class OverflowMenu extends PureComponent<IProps, IState> {
  76. /**
  77. * Initializes a new {@code OverflowMenu} instance.
  78. *
  79. * @inheritdoc
  80. */
  81. constructor(props: IProps) {
  82. super(props);
  83. this.state = {
  84. scrolledToTop: true
  85. };
  86. // Bind event handlers so they are only bound once per instance.
  87. this._onCancel = this._onCancel.bind(this);
  88. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  89. }
  90. /**
  91. * Implements React's {@link Component#render()}.
  92. *
  93. * @inheritdoc
  94. * @returns {ReactElement}
  95. */
  96. render() {
  97. const {
  98. _isBreakoutRoomsSupported,
  99. _isSpeakerStatsDisabled,
  100. _shouldDisplayReactionsButtons,
  101. _width,
  102. dispatch
  103. } = this.props;
  104. const toolbarButtons = getMovableButtons(_width);
  105. const buttonProps = {
  106. afterClick: this._onCancel,
  107. showLabel: true,
  108. styles: bottomSheetStyles.buttons
  109. };
  110. const topButtonProps = {
  111. afterClick: this._onCancel,
  112. dispatch,
  113. showLabel: true,
  114. styles: {
  115. ...bottomSheetStyles.buttons,
  116. style: {
  117. ...bottomSheetStyles.buttons.style,
  118. borderTopLeftRadius: 16,
  119. borderTopRightRadius: 16
  120. }
  121. }
  122. };
  123. return (
  124. <BottomSheet
  125. renderFooter = { _shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  126. ? this._renderReactionMenu
  127. : undefined }>
  128. <OpenCarmodeButton { ...topButtonProps } />
  129. <AudioOnlyButton { ...buttonProps } />
  130. {
  131. !_shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  132. && <RaiseHandButton { ...buttonProps } />
  133. }
  134. {/* @ts-ignore */}
  135. <Divider style = { styles.divider as ViewStyle } />
  136. <SecurityDialogButton { ...buttonProps } />
  137. <RecordButton { ...buttonProps } />
  138. <LiveStreamButton { ...buttonProps } />
  139. <LinkToSalesforceButton { ...buttonProps } />
  140. <WhiteboardButton { ...buttonProps } />
  141. {/* @ts-ignore */}
  142. <Divider style = { styles.divider as ViewStyle } />
  143. <SharedVideoButton { ...buttonProps } />
  144. {!toolbarButtons.has('screensharing') && <ScreenSharingButton { ...buttonProps } />}
  145. {!_isSpeakerStatsDisabled && <SpeakerStatsButton { ...buttonProps } />}
  146. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  147. {_isBreakoutRoomsSupported && <BreakoutRoomsButton { ...buttonProps } />}
  148. {/* @ts-ignore */}
  149. <Divider style = { styles.divider as ViewStyle } />
  150. <ClosedCaptionButton { ...buttonProps } />
  151. <SharedDocumentButton { ...buttonProps } />
  152. <SettingsButton { ...buttonProps } />
  153. </BottomSheet>
  154. );
  155. }
  156. /**
  157. * Hides this {@code OverflowMenu}.
  158. *
  159. * @private
  160. * @returns {void}
  161. */
  162. _onCancel() {
  163. this.props.dispatch(hideSheet());
  164. }
  165. /**
  166. * Function to render the reaction menu as the footer of the bottom sheet.
  167. *
  168. * @returns {React$Element}
  169. */
  170. _renderReactionMenu() {
  171. return (
  172. <ReactionMenu
  173. onCancel = { this._onCancel }
  174. overflowMenu = { true } />
  175. );
  176. }
  177. }
  178. /**
  179. * Function that maps parts of Redux state tree into component props.
  180. *
  181. * @param {Object} state - Redux state.
  182. * @private
  183. * @returns {IProps}
  184. */
  185. function _mapStateToProps(state: IReduxState) {
  186. const { conference } = state['features/base/conference'];
  187. return {
  188. _isBreakoutRoomsSupported: conference?.getBreakoutRooms()?.isSupported(),
  189. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  190. _shouldDisplayReactionsButtons: shouldDisplayReactionsButtons(state),
  191. _width: state['features/base/responsive-ui'].clientWidth
  192. };
  193. }
  194. export default connect(_mapStateToProps)(OverflowMenu);