Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

OverflowMenu.js 6.6KB

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 { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  10. import { ReactionMenu } from '../../../reactions/components';
  11. import { isReactionsEnabled } from '../../../reactions/functions.any';
  12. import { LiveStreamButton, RecordButton } from '../../../recording';
  13. import SecurityDialogButton
  14. from '../../../security/components/security-dialog/native/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 AudioOnlyButton from './AudioOnlyButton';
  23. import LinkToSalesforceButton from './LinkToSalesforceButton';
  24. import RaiseHandButton from './RaiseHandButton';
  25. import ScreenSharingButton from './ScreenSharingButton';
  26. import ToggleCameraButton from './ToggleCameraButton';
  27. /**
  28. * The type of the React {@code Component} props of {@link OverflowMenu}.
  29. */
  30. type Props = {
  31. /**
  32. * The color-schemed stylesheet of the dialog feature.
  33. */
  34. _bottomSheetStyles: StyleType,
  35. /**
  36. * True if the overflow menu is currently visible, false otherwise.
  37. */
  38. _isOpen: boolean,
  39. /**
  40. * Whether the recoding button should be enabled or not.
  41. */
  42. _recordingEnabled: boolean,
  43. /**
  44. * The width of the screen.
  45. */
  46. _width: number,
  47. /**
  48. * Whether or not the reactions feature is enabled.
  49. */
  50. _reactionsEnabled: boolean,
  51. /**
  52. * Used for hiding the dialog when the selection was completed.
  53. */
  54. dispatch: Function
  55. };
  56. type State = {
  57. /**
  58. * True if the bottom scheet is scrolled to the top.
  59. */
  60. scrolledToTop: boolean
  61. }
  62. /**
  63. * The exported React {@code Component}. We need it to execute
  64. * {@link hideDialog}.
  65. *
  66. * XXX It does not break our coding style rule to not utilize globals for state,
  67. * because it is merely another name for {@code export}'s {@code default}.
  68. */
  69. let OverflowMenu_; // eslint-disable-line prefer-const
  70. /**
  71. * Implements a React {@code Component} with some extra actions in addition to
  72. * those in the toolbar.
  73. */
  74. class OverflowMenu extends PureComponent<Props, State> {
  75. /**
  76. * Initializes a new {@code OverflowMenu} instance.
  77. *
  78. * @inheritdoc
  79. */
  80. constructor(props: Props) {
  81. super(props);
  82. this.state = {
  83. scrolledToTop: true
  84. };
  85. // Bind event handlers so they are only bound once per instance.
  86. this._onCancel = this._onCancel.bind(this);
  87. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  88. }
  89. /**
  90. * Implements React's {@link Component#render()}.
  91. *
  92. * @inheritdoc
  93. * @returns {ReactElement}
  94. */
  95. render() {
  96. const {
  97. _bottomSheetStyles,
  98. _width,
  99. _reactionsEnabled
  100. } = this.props;
  101. const toolbarButtons = getMovableButtons(_width);
  102. const buttonProps = {
  103. afterClick: this._onCancel,
  104. showLabel: true,
  105. styles: _bottomSheetStyles.buttons
  106. };
  107. const topButtonProps = {
  108. afterClick: this._onCancel,
  109. showLabel: true,
  110. styles: {
  111. ..._bottomSheetStyles.buttons,
  112. style: {
  113. ..._bottomSheetStyles.buttons.style,
  114. borderTopLeftRadius: 16,
  115. borderTopRightRadius: 16
  116. }
  117. }
  118. };
  119. return (
  120. <BottomSheet
  121. onCancel = { this._onCancel }
  122. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  123. ? this._renderReactionMenu
  124. : null }>
  125. <ParticipantsPaneButton { ...topButtonProps } />
  126. <AudioOnlyButton { ...buttonProps } />
  127. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  128. <Divider style = { styles.divider } />
  129. <SecurityDialogButton { ...buttonProps } />
  130. <RecordButton { ...buttonProps } />
  131. <LiveStreamButton { ...buttonProps } />
  132. <LinkToSalesforceButton { ...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_;