Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

OverflowMenu.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 { 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 { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
  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. /**
  27. * The type of the React {@code Component} props of {@link OverflowMenu}.
  28. */
  29. type Props = {
  30. /**
  31. * True if the overflow menu is currently visible, false otherwise.
  32. */
  33. _isOpen: boolean,
  34. /**
  35. * Whether the recoding button should be enabled or not.
  36. */
  37. _recordingEnabled: boolean,
  38. /**
  39. * The width of the screen.
  40. */
  41. _width: number,
  42. /**
  43. * Whether or not the reactions feature is enabled.
  44. */
  45. _reactionsEnabled: boolean,
  46. /**
  47. * Used for hiding the dialog when the selection was completed.
  48. */
  49. dispatch: Function,
  50. /**
  51. * Whether or not speaker stats is disable.
  52. */
  53. _isSpeakerStatsDisabled: boolean
  54. };
  55. type State = {
  56. /**
  57. * True if the bottom scheet is scrolled to the top.
  58. */
  59. scrolledToTop: boolean
  60. }
  61. /**
  62. * Implements a React {@code Component} with some extra actions in addition to
  63. * those in the toolbar.
  64. */
  65. class OverflowMenu extends PureComponent<Props, State> {
  66. /**
  67. * Initializes a new {@code OverflowMenu} instance.
  68. *
  69. * @inheritdoc
  70. */
  71. constructor(props: Props) {
  72. super(props);
  73. this.state = {
  74. scrolledToTop: true
  75. };
  76. // Bind event handlers so they are only bound once per instance.
  77. this._onCancel = this._onCancel.bind(this);
  78. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  79. }
  80. /**
  81. * Implements React's {@link Component#render()}.
  82. *
  83. * @inheritdoc
  84. * @returns {ReactElement}
  85. */
  86. render() {
  87. const {
  88. _isSpeakerStatsDisabled,
  89. _reactionsEnabled,
  90. _width
  91. } = this.props;
  92. const toolbarButtons = getMovableButtons(_width);
  93. const buttonProps = {
  94. afterClick: this._onCancel,
  95. showLabel: true,
  96. styles: bottomSheetStyles.buttons
  97. };
  98. const topButtonProps = {
  99. afterClick: this._onCancel,
  100. showLabel: true,
  101. styles: {
  102. ...bottomSheetStyles.buttons,
  103. style: {
  104. ...bottomSheetStyles.buttons.style,
  105. borderTopLeftRadius: 16,
  106. borderTopRightRadius: 16
  107. }
  108. }
  109. };
  110. return (
  111. <BottomSheet
  112. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  113. ? this._renderReactionMenu
  114. : null }>
  115. <OpenCarmodeButton { ...topButtonProps } />
  116. <AudioOnlyButton { ...buttonProps } />
  117. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  118. <Divider style = { styles.divider } />
  119. <SecurityDialogButton { ...buttonProps } />
  120. <RecordButton { ...buttonProps } />
  121. <LiveStreamButton { ...buttonProps } />
  122. <LinkToSalesforceButton { ...buttonProps } />
  123. <Divider style = { styles.divider } />
  124. <SharedVideoButton { ...buttonProps } />
  125. {!toolbarButtons.has('screensharing') && <ScreenSharingButton { ...buttonProps } />}
  126. {!_isSpeakerStatsDisabled && <SpeakerStatsButton { ...buttonProps } />}
  127. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  128. <Divider style = { styles.divider } />
  129. <ClosedCaptionButton { ...buttonProps } />
  130. <SharedDocumentButton { ...buttonProps } />
  131. <SettingsButton { ...buttonProps } />
  132. </BottomSheet>
  133. );
  134. }
  135. /**
  136. * Hides this {@code OverflowMenu}.
  137. *
  138. * @private
  139. * @returns {void}
  140. */
  141. _onCancel() {
  142. this.props.dispatch(hideSheet());
  143. }
  144. /**
  145. * Functoin to render the reaction menu as the footer of the bottom sheet.
  146. *
  147. * @returns {React$Element}
  148. */
  149. _renderReactionMenu() {
  150. return (<ReactionMenu
  151. onCancel = { this._onCancel }
  152. overflowMenu = { true } />);
  153. }
  154. }
  155. /**
  156. * Function that maps parts of Redux state tree into component props.
  157. *
  158. * @param {Object} state - Redux state.
  159. * @private
  160. * @returns {Props}
  161. */
  162. function _mapStateToProps(state) {
  163. return {
  164. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  165. _reactionsEnabled: isReactionsEnabled(state),
  166. _width: state['features/base/responsive-ui'].clientWidth
  167. };
  168. }
  169. export default connect(_mapStateToProps)(OverflowMenu);