Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

OverflowMenu.tsx 6.6KB

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