選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OverflowMenu.js 4.6KB

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