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.0KB

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