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.

OverflowMenu.tsx 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 { 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 the recoding button should be enabled or not.
  49. */
  50. _recordingEnabled: boolean;
  51. /**
  52. * Whether or not any reactions buttons should be displayed.
  53. */
  54. _shouldDisplayReactionsButtons: 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. _shouldDisplayReactionsButtons,
  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 = { _shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  125. ? this._renderReactionMenu
  126. : undefined }>
  127. <OpenCarmodeButton { ...topButtonProps } />
  128. <AudioOnlyButton { ...buttonProps } />
  129. {
  130. !_shouldDisplayReactionsButtons && !toolbarButtons.has('raisehand')
  131. && <RaiseHandButton { ...buttonProps } />
  132. }
  133. {/* @ts-ignore */}
  134. <Divider style = { styles.divider as ViewStyle } />
  135. <SecurityDialogButton { ...buttonProps } />
  136. <RecordButton { ...buttonProps } />
  137. <LiveStreamButton { ...buttonProps } />
  138. <LinkToSalesforceButton { ...buttonProps } />
  139. {/* @ts-ignore */}
  140. <Divider style = { styles.divider as ViewStyle } />
  141. <SharedVideoButton { ...buttonProps } />
  142. {!toolbarButtons.has('screensharing') && <ScreenSharingButton { ...buttonProps } />}
  143. {!_isSpeakerStatsDisabled && <SpeakerStatsButton { ...buttonProps } />}
  144. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  145. {_isBreakoutRoomsSupported && <BreakoutRoomsButton { ...buttonProps } />}
  146. {/* @ts-ignore */}
  147. <Divider style = { styles.divider as ViewStyle } />
  148. <ClosedCaptionButton { ...buttonProps } />
  149. <SharedDocumentButton { ...buttonProps } />
  150. <SettingsButton { ...buttonProps } />
  151. </BottomSheet>
  152. );
  153. }
  154. /**
  155. * Hides this {@code OverflowMenu}.
  156. *
  157. * @private
  158. * @returns {void}
  159. */
  160. _onCancel() {
  161. this.props.dispatch(hideSheet());
  162. }
  163. /**
  164. * Function to render the reaction menu as the footer of the bottom sheet.
  165. *
  166. * @returns {React$Element}
  167. */
  168. _renderReactionMenu() {
  169. return (
  170. <ReactionMenu
  171. onCancel = { this._onCancel }
  172. overflowMenu = { true } />
  173. );
  174. }
  175. }
  176. /**
  177. * Function that maps parts of Redux state tree into component props.
  178. *
  179. * @param {Object} state - Redux state.
  180. * @private
  181. * @returns {IProps}
  182. */
  183. function _mapStateToProps(state: IReduxState) {
  184. const { conference } = state['features/base/conference'];
  185. return {
  186. _isBreakoutRoomsSupported: conference?.getBreakoutRooms()?.isSupported(),
  187. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  188. _shouldDisplayReactionsButtons: shouldDisplayReactionsButtons(state),
  189. _width: state['features/base/responsive-ui'].clientWidth
  190. };
  191. }
  192. export default connect(_mapStateToProps)(OverflowMenu);