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 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 { 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. * 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. * Used for hiding the dialog when the selection was completed.
  40. */
  41. dispatch: Function
  42. };
  43. /**
  44. * The exported React {@code Component}. We need it to execute
  45. * {@link hideDialog}.
  46. *
  47. * XXX It does not break our coding style rule to not utilize globals for state,
  48. * because it is merely another name for {@code export}'s {@code default}.
  49. */
  50. let OverflowMenu_; // eslint-disable-line prefer-const
  51. /**
  52. * Implements a React {@code Component} with some extra actions in addition to
  53. * those in the toolbar.
  54. */
  55. class OverflowMenu extends Component<Props> {
  56. /**
  57. * Initializes a new {@code OverflowMenu} instance.
  58. *
  59. * @inheritdoc
  60. */
  61. constructor(props: Props) {
  62. super(props);
  63. // Bind event handlers so they are only bound once per instance.
  64. this._onCancel = this._onCancel.bind(this);
  65. }
  66. /**
  67. * Implements React's {@link Component#render()}.
  68. *
  69. * @inheritdoc
  70. * @returns {ReactElement}
  71. */
  72. render() {
  73. const buttonProps = {
  74. afterClick: this._onCancel,
  75. showLabel: true,
  76. styles: this.props._bottomSheetStyles
  77. };
  78. return (
  79. <BottomSheet onCancel = { this._onCancel }>
  80. <AudioRouteButton { ...buttonProps } />
  81. <ToggleCameraButton { ...buttonProps } />
  82. <AudioOnlyButton { ...buttonProps } />
  83. <RoomLockButton { ...buttonProps } />
  84. <ClosedCaptionButton { ...buttonProps } />
  85. {
  86. this.props._recordingEnabled
  87. && <RecordButton { ...buttonProps } />
  88. }
  89. <LiveStreamButton { ...buttonProps } />
  90. <TileViewButton { ...buttonProps } />
  91. <InviteButton { ...buttonProps } />
  92. {
  93. this.props._chatEnabled
  94. && <InfoDialogButton { ...buttonProps } />
  95. }
  96. <RaiseHandButton { ...buttonProps } />
  97. </BottomSheet>
  98. );
  99. }
  100. _onCancel: () => boolean;
  101. /**
  102. * Hides this {@code OverflowMenu}.
  103. *
  104. * @private
  105. * @returns {boolean}
  106. */
  107. _onCancel() {
  108. if (this.props._isOpen) {
  109. this.props.dispatch(hideDialog(OverflowMenu_));
  110. return true;
  111. }
  112. return false;
  113. }
  114. }
  115. /**
  116. * Function that maps parts of Redux state tree into component props.
  117. *
  118. * @param {Object} state - Redux state.
  119. * @private
  120. * @returns {Props}
  121. */
  122. function _mapStateToProps(state) {
  123. return {
  124. _bottomSheetStyles:
  125. ColorSchemeRegistry.get(state, 'BottomSheet'),
  126. _chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
  127. _isOpen: isDialogOpen(state, OverflowMenu_),
  128. _recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
  129. };
  130. }
  131. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  132. export default OverflowMenu_;