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

OverflowMenu.js 6.8KB

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