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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Divider } from 'react-native-paper';
  4. import { BottomSheet, hideSheet } from '../../../base/dialog';
  5. import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
  6. import { connect } from '../../../base/redux';
  7. import { SharedDocumentButton } from '../../../etherpad';
  8. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  9. import { ReactionMenu } from '../../../reactions/components';
  10. import { isReactionsEnabled } from '../../../reactions/functions.any';
  11. import { LiveStreamButton, RecordButton } from '../../../recording';
  12. import SecurityDialogButton
  13. from '../../../security/components/security-dialog/native/SecurityDialogButton';
  14. import { SharedVideoButton } from '../../../shared-video/components';
  15. import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
  16. import { ClosedCaptionButton } from '../../../subtitles';
  17. import { TileViewButton } from '../../../video-layout';
  18. import styles from '../../../video-menu/components/native/styles';
  19. import { getMovableButtons } from '../../functions.native';
  20. import HelpButton from '../HelpButton';
  21. import AudioOnlyButton from './AudioOnlyButton';
  22. import LinkToSalesforceButton from './LinkToSalesforceButton';
  23. import OpenCarmodeButton from './OpenCarmodeButton';
  24. import RaiseHandButton from './RaiseHandButton';
  25. import ScreenSharingButton from './ScreenSharingButton';
  26. import ToggleCameraButton from './ToggleCameraButton';
  27. import ToggleSelfViewButton from './ToggleSelfViewButton';
  28. /**
  29. * The type of the React {@code Component} props of {@link OverflowMenu}.
  30. */
  31. type Props = {
  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. * Whether or not the self view is hidden.
  42. */
  43. _selfViewHidden: 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. * 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 {
  90. _reactionsEnabled,
  91. _selfViewHidden,
  92. _width
  93. } = this.props;
  94. const toolbarButtons = getMovableButtons(_width);
  95. const buttonProps = {
  96. afterClick: this._onCancel,
  97. showLabel: true,
  98. styles: bottomSheetStyles.buttons
  99. };
  100. const topButtonProps = {
  101. afterClick: this._onCancel,
  102. showLabel: true,
  103. styles: {
  104. ...bottomSheetStyles.buttons,
  105. style: {
  106. ...bottomSheetStyles.buttons.style,
  107. borderTopLeftRadius: 16,
  108. borderTopRightRadius: 16
  109. }
  110. }
  111. };
  112. return (
  113. <BottomSheet
  114. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  115. ? this._renderReactionMenu
  116. : null }>
  117. <ParticipantsPaneButton { ...topButtonProps } />
  118. {_selfViewHidden && <ToggleSelfViewButton { ...buttonProps } />}
  119. <OpenCarmodeButton { ...buttonProps } />
  120. <AudioOnlyButton { ...buttonProps } />
  121. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  122. <Divider style = { styles.divider } />
  123. <SecurityDialogButton { ...buttonProps } />
  124. <RecordButton { ...buttonProps } />
  125. <LiveStreamButton { ...buttonProps } />
  126. <LinkToSalesforceButton { ...buttonProps } />
  127. <Divider style = { styles.divider } />
  128. <SharedVideoButton { ...buttonProps } />
  129. <ScreenSharingButton { ...buttonProps } />
  130. <SpeakerStatsButton { ...buttonProps } />
  131. {!toolbarButtons.has('togglecamera') && <ToggleCameraButton { ...buttonProps } />}
  132. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  133. <Divider style = { styles.divider } />
  134. <ClosedCaptionButton { ...buttonProps } />
  135. <SharedDocumentButton { ...buttonProps } />
  136. <HelpButton { ...buttonProps } />
  137. </BottomSheet>
  138. );
  139. }
  140. /**
  141. * Hides this {@code OverflowMenu}.
  142. *
  143. * @private
  144. * @returns {void}
  145. */
  146. _onCancel() {
  147. this.props.dispatch(hideSheet());
  148. }
  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. const { disableSelfView } = state['features/base/settings'];
  169. return {
  170. _reactionsEnabled: isReactionsEnabled(state),
  171. _selfViewHidden: Boolean(disableSelfView),
  172. _width: state['features/base/responsive-ui'].clientWidth
  173. };
  174. }
  175. export default connect(_mapStateToProps)(OverflowMenu);