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.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  4. import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
  5. import { connect } from '../../../base/redux';
  6. import { StyleType } from '../../../base/styles';
  7. import { SharedDocumentButton } from '../../../etherpad';
  8. import { InviteButton } from '../../../invite';
  9. import { AudioRouteButton } from '../../../mobile/audio-mode';
  10. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  11. import { ReactionMenu } from '../../../reactions/components';
  12. import { LiveStreamButton, RecordButton } from '../../../recording';
  13. import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
  14. import { SharedVideoButton } from '../../../shared-video/components';
  15. import { ClosedCaptionButton } from '../../../subtitles';
  16. import { TileViewButton } from '../../../video-layout';
  17. import { getMovableButtons } from '../../functions.native';
  18. import HelpButton from '../HelpButton';
  19. import MuteEveryoneButton from '../MuteEveryoneButton';
  20. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  21. import AudioOnlyButton from './AudioOnlyButton';
  22. import ScreenSharingButton from './ScreenSharingButton.js';
  23. import ToggleCameraButton from './ToggleCameraButton';
  24. /**
  25. * The type of the React {@code Component} props of {@link OverflowMenu}.
  26. */
  27. type Props = {
  28. /**
  29. * The color-schemed stylesheet of the dialog feature.
  30. */
  31. _bottomSheetStyles: StyleType,
  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. * The width of the screen.
  42. */
  43. _width: number,
  44. /**
  45. * Used for hiding the dialog when the selection was completed.
  46. */
  47. dispatch: Function
  48. };
  49. type State = {
  50. /**
  51. * True if the bottom scheet is scrolled to the top.
  52. */
  53. scrolledToTop: boolean
  54. }
  55. /**
  56. * The exported React {@code Component}. We need it to execute
  57. * {@link hideDialog}.
  58. *
  59. * XXX It does not break our coding style rule to not utilize globals for state,
  60. * because it is merely another name for {@code export}'s {@code default}.
  61. */
  62. let OverflowMenu_; // eslint-disable-line prefer-const
  63. /**
  64. * Implements a React {@code Component} with some extra actions in addition to
  65. * those in the toolbar.
  66. */
  67. class OverflowMenu extends PureComponent<Props, State> {
  68. /**
  69. * Initializes a new {@code OverflowMenu} instance.
  70. *
  71. * @inheritdoc
  72. */
  73. constructor(props: Props) {
  74. super(props);
  75. this.state = {
  76. scrolledToTop: true
  77. };
  78. // Bind event handlers so they are only bound once per instance.
  79. this._onCancel = this._onCancel.bind(this);
  80. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  81. }
  82. /**
  83. * Implements React's {@link Component#render()}.
  84. *
  85. * @inheritdoc
  86. * @returns {ReactElement}
  87. */
  88. render() {
  89. const { _bottomSheetStyles, _width } = this.props;
  90. const toolbarButtons = getMovableButtons(_width);
  91. const buttonProps = {
  92. afterClick: this._onCancel,
  93. showLabel: true,
  94. styles: _bottomSheetStyles.buttons
  95. };
  96. const topButtonProps = {
  97. afterClick: this._onCancel,
  98. showLabel: true,
  99. styles: {
  100. ..._bottomSheetStyles.buttons,
  101. style: {
  102. ..._bottomSheetStyles.buttons.style,
  103. borderTopLeftRadius: 16,
  104. borderTopRightRadius: 16,
  105. paddingTop: 16
  106. }
  107. }
  108. };
  109. return (
  110. <BottomSheet
  111. onCancel = { this._onCancel }
  112. renderFooter = { toolbarButtons.has('raisehand')
  113. ? null
  114. : this._renderReactionMenu }>
  115. <AudioRouteButton { ...topButtonProps } />
  116. <ParticipantsPaneButton { ...buttonProps } />
  117. {!toolbarButtons.has('invite') && <InviteButton { ...buttonProps } />}
  118. <AudioOnlyButton { ...buttonProps } />
  119. <SecurityDialogButton { ...buttonProps } />
  120. <ScreenSharingButton { ...buttonProps } />
  121. {!toolbarButtons.has('togglecamera') && <ToggleCameraButton { ...buttonProps } />}
  122. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  123. <RecordButton { ...buttonProps } />
  124. <LiveStreamButton { ...buttonProps } />
  125. <SharedVideoButton { ...buttonProps } />
  126. <ClosedCaptionButton { ...buttonProps } />
  127. <SharedDocumentButton { ...buttonProps } />
  128. <MuteEveryoneButton { ...buttonProps } />
  129. <MuteEveryonesVideoButton { ...buttonProps } />
  130. <HelpButton { ...buttonProps } />
  131. </BottomSheet>
  132. );
  133. }
  134. _onCancel: () => boolean;
  135. /**
  136. * Hides this {@code OverflowMenu}.
  137. *
  138. * @private
  139. * @returns {boolean}
  140. */
  141. _onCancel() {
  142. if (this.props._isOpen) {
  143. this.props.dispatch(hideDialog(OverflowMenu_));
  144. return true;
  145. }
  146. return false;
  147. }
  148. _renderReactionMenu: () => React$Element<any>;
  149. /**
  150. * Functoin to render the reaction menu as the footer of the bottom sheet.
  151. *
  152. * @returns {React$Element}
  153. */
  154. _renderReactionMenu() {
  155. return (<ReactionMenu
  156. onCancel = { this._onCancel }
  157. overflowMenu = { true } />);
  158. }
  159. }
  160. /**
  161. * Function that maps parts of Redux state tree into component props.
  162. *
  163. * @param {Object} state - Redux state.
  164. * @private
  165. * @returns {Props}
  166. */
  167. function _mapStateToProps(state) {
  168. return {
  169. _bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
  170. _isOpen: isDialogOpen(state, OverflowMenu_),
  171. _width: state['features/base/responsive-ui'].clientWidth
  172. };
  173. }
  174. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  175. export default OverflowMenu_;