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

OverflowMenu.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Divider } from 'react-native-paper';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
  6. import { connect } from '../../../base/redux';
  7. import { StyleType } from '../../../base/styles';
  8. import { SharedDocumentButton } from '../../../etherpad';
  9. import { AudioRouteButton } from '../../../mobile/audio-mode';
  10. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  11. import { ReactionMenu } from '../../../reactions/components';
  12. import { isReactionsEnabled } from '../../../reactions/functions.any';
  13. import { LiveStreamButton, RecordButton } from '../../../recording';
  14. import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
  15. import { SharedVideoButton } from '../../../shared-video/components';
  16. import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
  17. import { ClosedCaptionButton } from '../../../subtitles';
  18. import { TileViewButton } from '../../../video-layout';
  19. import styles from '../../../video-menu/components/native/styles';
  20. import { getMovableButtons } from '../../functions.native';
  21. import HelpButton from '../HelpButton';
  22. import MuteEveryoneButton from '../MuteEveryoneButton';
  23. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  24. import AudioOnlyButton from './AudioOnlyButton';
  25. import RaiseHandButton from './RaiseHandButton';
  26. import ScreenSharingButton from './ScreenSharingButton.js';
  27. import ToggleCameraButton from './ToggleCameraButton';
  28. /**
  29. * The type of the React {@code Component} props of {@link OverflowMenu}.
  30. */
  31. type Props = {
  32. /**
  33. * The color-schemed stylesheet of the dialog feature.
  34. */
  35. _bottomSheetStyles: StyleType,
  36. /**
  37. * True if the overflow menu is currently visible, false otherwise.
  38. */
  39. _isOpen: boolean,
  40. /**
  41. * Whether the recoding button should be enabled or not.
  42. */
  43. _recordingEnabled: 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 { _bottomSheetStyles, _width, _reactionsEnabled } = this.props;
  98. const toolbarButtons = getMovableButtons(_width);
  99. const buttonProps = {
  100. afterClick: this._onCancel,
  101. showLabel: true,
  102. styles: _bottomSheetStyles.buttons
  103. };
  104. const topButtonProps = {
  105. afterClick: this._onCancel,
  106. showLabel: true,
  107. styles: {
  108. ..._bottomSheetStyles.buttons,
  109. style: {
  110. ..._bottomSheetStyles.buttons.style,
  111. borderTopLeftRadius: 16,
  112. borderTopRightRadius: 16
  113. }
  114. }
  115. };
  116. return (
  117. <BottomSheet
  118. onCancel = { this._onCancel }
  119. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  120. ? this._renderReactionMenu
  121. : null }>
  122. <AudioRouteButton { ...topButtonProps } />
  123. <ParticipantsPaneButton { ...buttonProps } />
  124. <AudioOnlyButton { ...buttonProps } />
  125. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  126. <Divider style = { styles.divider } />
  127. <SecurityDialogButton { ...buttonProps } />
  128. <RecordButton { ...buttonProps } />
  129. <LiveStreamButton { ...buttonProps } />
  130. <MuteEveryoneButton { ...buttonProps } />
  131. <MuteEveryonesVideoButton { ...buttonProps } />
  132. <Divider style = { styles.divider } />
  133. <SharedVideoButton { ...buttonProps } />
  134. <ScreenSharingButton { ...buttonProps } />
  135. <SpeakerStatsButton { ...buttonProps } />
  136. {!toolbarButtons.has('togglecamera') && <ToggleCameraButton { ...buttonProps } />}
  137. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  138. <Divider style = { styles.divider } />
  139. <ClosedCaptionButton { ...buttonProps } />
  140. <SharedDocumentButton { ...buttonProps } />
  141. <HelpButton { ...buttonProps } />
  142. </BottomSheet>
  143. );
  144. }
  145. _onCancel: () => boolean;
  146. /**
  147. * Hides this {@code OverflowMenu}.
  148. *
  149. * @private
  150. * @returns {boolean}
  151. */
  152. _onCancel() {
  153. if (this.props._isOpen) {
  154. this.props.dispatch(hideDialog(OverflowMenu_));
  155. return true;
  156. }
  157. return false;
  158. }
  159. _renderReactionMenu: () => React$Element<any>;
  160. /**
  161. * Functoin to render the reaction menu as the footer of the bottom sheet.
  162. *
  163. * @returns {React$Element}
  164. */
  165. _renderReactionMenu() {
  166. return (<ReactionMenu
  167. onCancel = { this._onCancel }
  168. overflowMenu = { true } />);
  169. }
  170. }
  171. /**
  172. * Function that maps parts of Redux state tree into component props.
  173. *
  174. * @param {Object} state - Redux state.
  175. * @private
  176. * @returns {Props}
  177. */
  178. function _mapStateToProps(state) {
  179. return {
  180. _bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
  181. _isOpen: isDialogOpen(state, OverflowMenu_),
  182. _width: state['features/base/responsive-ui'].clientWidth,
  183. _reactionsEnabled: isReactionsEnabled(state)
  184. };
  185. }
  186. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  187. export default OverflowMenu_;