Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 { isSharedVideoEnabled } from '../../../shared-video/functions';
  21. import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
  22. import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
  23. import ClosedCaptionButton from '../../../subtitles/components/native/ClosedCaptionButton';
  24. import TileViewButton from '../../../video-layout/components/TileViewButton';
  25. import styles from '../../../video-menu/components/native/styles';
  26. import WhiteboardButton from '../../../whiteboard/components/native/WhiteboardButton';
  27. import { customOverflowMenuButtonPressed } from '../../actions.native';
  28. import { getMovableButtons } from '../../functions.native';
  29. import AudioOnlyButton from './AudioOnlyButton';
  30. import CustomOptionButton from './CustomOptionButton';
  31. import LinkToSalesforceButton from './LinkToSalesforceButton';
  32. import OpenCarmodeButton from './OpenCarmodeButton';
  33. import RaiseHandButton from './RaiseHandButton';
  34. import ScreenSharingButton from './ScreenSharingButton';
  35. /**
  36. * The type of the React {@code Component} props of {@link OverflowMenu}.
  37. */
  38. interface IProps {
  39. /**
  40. * Custom Toolbar buttons.
  41. */
  42. _customToolbarButtons?: Array<{ backgroundColor?: string; icon: string; id: string; text: string; }>;
  43. /**
  44. * True if breakout rooms feature is available, false otherwise.
  45. */
  46. _isBreakoutRoomsSupported?: boolean;
  47. /**
  48. * True if the overflow menu is currently visible, false otherwise.
  49. */
  50. _isOpen: boolean;
  51. /**
  52. * Whether the shared video is enabled or not.
  53. */
  54. _isSharedVideoEnabled: boolean;
  55. /**
  56. * Whether or not speaker stats is disable.
  57. */
  58. _isSpeakerStatsDisabled?: boolean;
  59. /**
  60. * Whether the recoding button should be enabled or not.
  61. */
  62. _recordingEnabled: boolean;
  63. /**
  64. * Whether or not any reactions buttons should be displayed.
  65. */
  66. _shouldDisplayReactionsButtons: boolean;
  67. /**
  68. * The width of the screen.
  69. */
  70. _width: number;
  71. /**
  72. * Used for hiding the dialog when the selection was completed.
  73. */
  74. dispatch: IStore['dispatch'];
  75. }
  76. interface IState {
  77. /**
  78. * True if the bottom sheet is scrolled to the top.
  79. */
  80. scrolledToTop: boolean;
  81. }
  82. /**
  83. * Implements a React {@code Component} with some extra actions in addition to
  84. * those in the toolbar.
  85. */
  86. class OverflowMenu extends PureComponent<IProps, IState> {
  87. /**
  88. * Initializes a new {@code OverflowMenu} instance.
  89. *
  90. * @inheritdoc
  91. */
  92. constructor(props: IProps) {
  93. super(props);
  94. this.state = {
  95. scrolledToTop: true
  96. };
  97. // Bind event handlers so they are only bound once per instance.
  98. this._onCancel = this._onCancel.bind(this);
  99. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  100. }
  101. /**
  102. * Implements React's {@link Component#render()}.
  103. *
  104. * @inheritdoc
  105. * @returns {ReactElement}
  106. */
  107. render() {
  108. const {
  109. _isBreakoutRoomsSupported,
  110. _isSpeakerStatsDisabled,
  111. _isSharedVideoEnabled,
  112. _shouldDisplayReactionsButtons,
  113. _width,
  114. dispatch
  115. } = this.props;
  116. const toolbarButtons = getMovableButtons(_width);
  117. const buttonProps = {
  118. afterClick: this._onCancel,
  119. showLabel: true,
  120. styles: bottomSheetStyles.buttons
  121. };
  122. const topButtonProps = {
  123. afterClick: this._onCancel,
  124. dispatch,
  125. showLabel: true,
  126. styles: {
  127. ...bottomSheetStyles.buttons,
  128. style: {
  129. ...bottomSheetStyles.buttons.style,
  130. borderTopLeftRadius: 16,
  131. borderTopRightRadius: 16
  132. }
  133. }
  134. };
  135. return (
  136. <BottomSheet
  137. renderFooter = { _shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  138. ? this._renderReactionMenu
  139. : undefined }>
  140. { this._renderCustomOverflowMenuButtons(topButtonProps) }
  141. <OpenCarmodeButton { ...topButtonProps } />
  142. <AudioOnlyButton { ...buttonProps } />
  143. {
  144. !_shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  145. && <RaiseHandButton { ...buttonProps } />
  146. }
  147. {/* @ts-ignore */}
  148. <Divider style = { styles.divider as ViewStyle } />
  149. <SecurityDialogButton { ...buttonProps } />
  150. <RecordButton { ...buttonProps } />
  151. <LiveStreamButton { ...buttonProps } />
  152. <LinkToSalesforceButton { ...buttonProps } />
  153. <WhiteboardButton { ...buttonProps } />
  154. {/* @ts-ignore */}
  155. <Divider style = { styles.divider as ViewStyle } />
  156. {_isSharedVideoEnabled && <SharedVideoButton { ...buttonProps } />}
  157. {!toolbarButtons.has('screensharing') && <ScreenSharingButton { ...buttonProps } />}
  158. {!_isSpeakerStatsDisabled && <SpeakerStatsButton { ...buttonProps } />}
  159. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  160. {_isBreakoutRoomsSupported && <BreakoutRoomsButton { ...buttonProps } />}
  161. {/* @ts-ignore */}
  162. <Divider style = { styles.divider as ViewStyle } />
  163. <ClosedCaptionButton { ...buttonProps } />
  164. <SharedDocumentButton { ...buttonProps } />
  165. <SettingsButton { ...buttonProps } />
  166. </BottomSheet>
  167. );
  168. }
  169. /**
  170. * Hides this {@code OverflowMenu}.
  171. *
  172. * @private
  173. * @returns {void}
  174. */
  175. _onCancel() {
  176. this.props.dispatch(hideSheet());
  177. }
  178. /**
  179. * Function to render the reaction menu as the footer of the bottom sheet.
  180. *
  181. * @returns {React.ReactElement}
  182. */
  183. _renderReactionMenu() {
  184. return (
  185. <ReactionMenu
  186. onCancel = { this._onCancel }
  187. overflowMenu = { true } />
  188. );
  189. }
  190. /**
  191. * Function to render the custom buttons for the overflow menu.
  192. *
  193. * @param {Object} topButtonProps - Button properties.
  194. * @returns {React.ReactElement}
  195. */
  196. _renderCustomOverflowMenuButtons(topButtonProps: Object) {
  197. const { _customToolbarButtons, dispatch } = this.props;
  198. if (!_customToolbarButtons?.length) {
  199. return;
  200. }
  201. return (
  202. <>
  203. {
  204. _customToolbarButtons.map(({ id, text, icon, backgroundColor }) => (
  205. <CustomOptionButton
  206. { ...topButtonProps }
  207. backgroundColor = { backgroundColor }
  208. /* eslint-disable react/jsx-no-bind */
  209. handleClick = { () =>
  210. dispatch(customOverflowMenuButtonPressed(id, text))
  211. }
  212. icon = { icon }
  213. key = { id }
  214. text = { text } />
  215. ))
  216. }
  217. <Divider style = { styles.divider as ViewStyle } />
  218. </>
  219. );
  220. }
  221. }
  222. /**
  223. * Function that maps parts of Redux state tree into component props.
  224. *
  225. * @param {Object} state - Redux state.
  226. * @private
  227. * @returns {IProps}
  228. */
  229. function _mapStateToProps(state: IReduxState) {
  230. const { conference } = state['features/base/conference'];
  231. const { customToolbarButtons } = state['features/base/config'];
  232. return {
  233. _customToolbarButtons: customToolbarButtons,
  234. _isBreakoutRoomsSupported: conference?.getBreakoutRooms()?.isSupported(),
  235. _isSharedVideoEnabled: isSharedVideoEnabled(state),
  236. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  237. _shouldDisplayReactionsButtons: shouldDisplayReactionsButtons(state),
  238. _width: state['features/base/responsive-ui'].clientWidth
  239. };
  240. }
  241. export default connect(_mapStateToProps)(OverflowMenu);