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.

OverflowMenu.tsx 7.1KB

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