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

OverflowMenu.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Platform } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { BottomSheet, hideDialog } from '../../../base/dialog';
  6. import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
  7. import { connect } from '../../../base/redux';
  8. import { StyleType } from '../../../base/styles';
  9. import { InfoDialogButton, InviteButton } from '../../../invite';
  10. import { AudioRouteButton } from '../../../mobile/audio-mode';
  11. import { LiveStreamButton, RecordButton } from '../../../recording';
  12. import { RoomLockButton } from '../../../room-lock';
  13. import { ClosedCaptionButton } from '../../../subtitles';
  14. import { TileViewButton } from '../../../video-layout';
  15. import AudioOnlyButton from './AudioOnlyButton';
  16. import RaiseHandButton from './RaiseHandButton';
  17. import ToggleCameraButton from './ToggleCameraButton';
  18. /**
  19. * The type of the React {@code Component} props of {@link OverflowMenu}.
  20. */
  21. type Props = {
  22. /**
  23. * The color-schemed stylesheet of the dialog feature.
  24. */
  25. _bottomSheetStyles: StyleType,
  26. /**
  27. * Whether the chat feature has been enabled. The meeting info button will be displayed in its place when disabled.
  28. */
  29. _chatEnabled: boolean,
  30. /**
  31. * Whether the recoding button should be enabled or not.
  32. */
  33. _recordingEnabled: boolean,
  34. /**
  35. * Used for hiding the dialog when the selection was completed.
  36. */
  37. dispatch: Function
  38. };
  39. /**
  40. * The exported React {@code Component}. We need it to execute
  41. * {@link hideDialog}.
  42. *
  43. * XXX It does not break our coding style rule to not utilize globals for state,
  44. * because it is merely another name for {@code export}'s {@code default}.
  45. */
  46. let OverflowMenu_; // eslint-disable-line prefer-const
  47. /**
  48. * Implements a React {@code Component} with some extra actions in addition to
  49. * those in the toolbar.
  50. */
  51. class OverflowMenu extends Component<Props> {
  52. /**
  53. * Initializes a new {@code OverflowMenu} instance.
  54. *
  55. * @inheritdoc
  56. */
  57. constructor(props: Props) {
  58. super(props);
  59. // Bind event handlers so they are only bound once per instance.
  60. this._onCancel = this._onCancel.bind(this);
  61. }
  62. /**
  63. * Implements React's {@link Component#render()}.
  64. *
  65. * @inheritdoc
  66. * @returns {ReactElement}
  67. */
  68. render() {
  69. const buttonProps = {
  70. afterClick: this._onCancel,
  71. showLabel: true,
  72. styles: this.props._bottomSheetStyles
  73. };
  74. return (
  75. <BottomSheet onCancel = { this._onCancel }>
  76. <AudioRouteButton { ...buttonProps } />
  77. <ToggleCameraButton { ...buttonProps } />
  78. <AudioOnlyButton { ...buttonProps } />
  79. <RoomLockButton { ...buttonProps } />
  80. <ClosedCaptionButton { ...buttonProps } />
  81. {
  82. this.props._recordingEnabled
  83. && <RecordButton { ...buttonProps } />
  84. }
  85. <LiveStreamButton { ...buttonProps } />
  86. <TileViewButton { ...buttonProps } />
  87. <InviteButton { ...buttonProps } />
  88. {
  89. this.props._chatEnabled
  90. && <InfoDialogButton { ...buttonProps } />
  91. }
  92. <RaiseHandButton { ...buttonProps } />
  93. </BottomSheet>
  94. );
  95. }
  96. _onCancel: () => void;
  97. /**
  98. * Hides this {@code OverflowMenu}.
  99. *
  100. * @private
  101. * @returns {void}
  102. */
  103. _onCancel() {
  104. this.props.dispatch(hideDialog(OverflowMenu_));
  105. }
  106. }
  107. /**
  108. * Function that maps parts of Redux state tree into component props.
  109. *
  110. * @param {Object} state - Redux state.
  111. * @private
  112. * @returns {{
  113. * _bottomSheetStyles: StyleType,
  114. * _chatEnabled: boolean,
  115. * _recordingEnabled: boolean
  116. * }}
  117. */
  118. function _mapStateToProps(state) {
  119. return {
  120. _bottomSheetStyles:
  121. ColorSchemeRegistry.get(state, 'BottomSheet'),
  122. _chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
  123. _recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
  124. };
  125. }
  126. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  127. export default OverflowMenu_;