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

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