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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 SettingsButton from '../../../base/settings/components/native/SettingsButton';
  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 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 ToggleSelfViewButton from './ToggleSelfViewButton';
  27. /**
  28. * The type of the React {@code Component} props of {@link OverflowMenu}.
  29. */
  30. type Props = {
  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. * Whether or not the self view is hidden.
  41. */
  42. _selfViewHidden: 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. * 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 {
  89. _reactionsEnabled,
  90. _selfViewHidden,
  91. _width
  92. } = this.props;
  93. const toolbarButtons = getMovableButtons(_width);
  94. const buttonProps = {
  95. afterClick: this._onCancel,
  96. showLabel: true,
  97. styles: bottomSheetStyles.buttons
  98. };
  99. const topButtonProps = {
  100. afterClick: this._onCancel,
  101. showLabel: true,
  102. styles: {
  103. ...bottomSheetStyles.buttons,
  104. style: {
  105. ...bottomSheetStyles.buttons.style,
  106. borderTopLeftRadius: 16,
  107. borderTopRightRadius: 16
  108. }
  109. }
  110. };
  111. const firstMenuButtonProps
  112. = toolbarButtons.has('participantspane') ? topButtonProps : buttonProps;
  113. return (
  114. <BottomSheet
  115. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  116. ? this._renderReactionMenu
  117. : null }>
  118. {!toolbarButtons.has('participantspane') && <ParticipantsPaneButton { ...topButtonProps } />}
  119. <OpenCarmodeButton { ...firstMenuButtonProps } />
  120. <AudioOnlyButton { ...buttonProps } />
  121. {_selfViewHidden && <ToggleSelfViewButton { ...buttonProps } />}
  122. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  123. <Divider style = { styles.divider } />
  124. <SecurityDialogButton { ...buttonProps } />
  125. <RecordButton { ...buttonProps } />
  126. <LiveStreamButton { ...buttonProps } />
  127. <LinkToSalesforceButton { ...buttonProps } />
  128. <Divider style = { styles.divider } />
  129. <SharedVideoButton { ...buttonProps } />
  130. <ScreenSharingButton { ...buttonProps } />
  131. <SpeakerStatsButton { ...buttonProps } />
  132. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  133. <Divider style = { styles.divider } />
  134. <ClosedCaptionButton { ...buttonProps } />
  135. <SharedDocumentButton { ...buttonProps } />
  136. <SettingsButton { ...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);