Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

OverflowMenu.js 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Divider } from 'react-native-paper';
  4. import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
  5. import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
  6. import { connect } from '../../../base/redux';
  7. import { SharedDocumentButton } from '../../../etherpad';
  8. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  9. import { ReactionMenu } from '../../../reactions/components';
  10. import { isReactionsEnabled } from '../../../reactions/functions.any';
  11. import { LiveStreamButton, RecordButton } from '../../../recording';
  12. import SecurityDialogButton
  13. from '../../../security/components/security-dialog/native/SecurityDialogButton';
  14. import { SharedVideoButton } from '../../../shared-video/components';
  15. import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
  16. import { ClosedCaptionButton } from '../../../subtitles';
  17. import { TileViewButton } from '../../../video-layout';
  18. import styles from '../../../video-menu/components/native/styles';
  19. import { getMovableButtons } from '../../functions.native';
  20. import HelpButton from '../HelpButton';
  21. import AudioOnlyButton from './AudioOnlyButton';
  22. import LinkToSalesforceButton from './LinkToSalesforceButton';
  23. import OpenCarmodeButton from './OpenCarmodeButton';
  24. import RaiseHandButton from './RaiseHandButton';
  25. import ScreenSharingButton from './ScreenSharingButton';
  26. import ToggleCameraButton from './ToggleCameraButton';
  27. import ToggleSelfViewButton from './ToggleSelfViewButton';
  28. /**
  29. * The type of the React {@code Component} props of {@link OverflowMenu}.
  30. */
  31. type Props = {
  32. /**
  33. * True if the overflow menu is currently visible, false otherwise.
  34. */
  35. _isOpen: boolean,
  36. /**
  37. * Whether the recoding button should be enabled or not.
  38. */
  39. _recordingEnabled: boolean,
  40. /**
  41. * Whether or not the self view is hidden.
  42. */
  43. _selfViewHidden: boolean,
  44. /**
  45. * The width of the screen.
  46. */
  47. _width: number,
  48. /**
  49. * Whether or not the reactions feature is enabled.
  50. */
  51. _reactionsEnabled: boolean,
  52. /**
  53. * Used for hiding the dialog when the selection was completed.
  54. */
  55. dispatch: Function
  56. };
  57. type State = {
  58. /**
  59. * True if the bottom scheet is scrolled to the top.
  60. */
  61. scrolledToTop: boolean
  62. }
  63. /**
  64. * The exported React {@code Component}. We need it to execute
  65. * {@link hideDialog}.
  66. *
  67. * XXX It does not break our coding style rule to not utilize globals for state,
  68. * because it is merely another name for {@code export}'s {@code default}.
  69. */
  70. let OverflowMenu_; // eslint-disable-line prefer-const
  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<Props, State> {
  76. /**
  77. * Initializes a new {@code OverflowMenu} instance.
  78. *
  79. * @inheritdoc
  80. */
  81. constructor(props: Props) {
  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. _reactionsEnabled,
  99. _selfViewHidden,
  100. _width
  101. } = this.props;
  102. const toolbarButtons = getMovableButtons(_width);
  103. const buttonProps = {
  104. afterClick: this._onCancel,
  105. showLabel: true,
  106. styles: bottomSheetStyles.buttons
  107. };
  108. const topButtonProps = {
  109. afterClick: this._onCancel,
  110. showLabel: true,
  111. styles: {
  112. ...bottomSheetStyles.buttons,
  113. style: {
  114. ...bottomSheetStyles.buttons.style,
  115. borderTopLeftRadius: 16,
  116. borderTopRightRadius: 16
  117. }
  118. }
  119. };
  120. return (
  121. <BottomSheet
  122. onCancel = { this._onCancel }
  123. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  124. ? this._renderReactionMenu
  125. : null }>
  126. <ParticipantsPaneButton { ...topButtonProps } />
  127. {_selfViewHidden && <ToggleSelfViewButton { ...buttonProps } />}
  128. <OpenCarmodeButton { ...buttonProps } />
  129. <AudioOnlyButton { ...buttonProps } />
  130. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  131. <Divider style = { styles.divider } />
  132. <SecurityDialogButton { ...buttonProps } />
  133. <RecordButton { ...buttonProps } />
  134. <LiveStreamButton { ...buttonProps } />
  135. <LinkToSalesforceButton { ...buttonProps } />
  136. <Divider style = { styles.divider } />
  137. <SharedVideoButton { ...buttonProps } />
  138. <ScreenSharingButton { ...buttonProps } />
  139. <SpeakerStatsButton { ...buttonProps } />
  140. {!toolbarButtons.has('togglecamera') && <ToggleCameraButton { ...buttonProps } />}
  141. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  142. <Divider style = { styles.divider } />
  143. <ClosedCaptionButton { ...buttonProps } />
  144. <SharedDocumentButton { ...buttonProps } />
  145. <HelpButton { ...buttonProps } />
  146. </BottomSheet>
  147. );
  148. }
  149. _onCancel: () => boolean;
  150. /**
  151. * Hides this {@code OverflowMenu}.
  152. *
  153. * @private
  154. * @returns {boolean}
  155. */
  156. _onCancel() {
  157. if (this.props._isOpen) {
  158. this.props.dispatch(hideDialog(OverflowMenu_));
  159. return true;
  160. }
  161. return false;
  162. }
  163. _renderReactionMenu: () => React$Element<any>;
  164. /**
  165. * Functoin to render the reaction menu as the footer of the bottom sheet.
  166. *
  167. * @returns {React$Element}
  168. */
  169. _renderReactionMenu() {
  170. return (<ReactionMenu
  171. onCancel = { this._onCancel }
  172. overflowMenu = { true } />);
  173. }
  174. }
  175. /**
  176. * Function that maps parts of Redux state tree into component props.
  177. *
  178. * @param {Object} state - Redux state.
  179. * @private
  180. * @returns {Props}
  181. */
  182. function _mapStateToProps(state) {
  183. const { disableSelfView } = state['features/base/settings'];
  184. return {
  185. _isOpen: isDialogOpen(state, OverflowMenu_),
  186. _reactionsEnabled: isReactionsEnabled(state),
  187. _selfViewHidden: Boolean(disableSelfView),
  188. _width: state['features/base/responsive-ui'].clientWidth
  189. };
  190. }
  191. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  192. export default OverflowMenu_;