您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

OverflowMenu.js 5.6KB

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