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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { BottomSheet, hideDialog } from '../../../base/dialog';
  5. import { AudioRouteButton } from '../../../mobile/audio-mode';
  6. import { PictureInPictureButton } from '../../../mobile/picture-in-picture';
  7. import { LiveStreamButton, RecordButton } from '../../../recording';
  8. import { RoomLockButton } from '../../../room-lock';
  9. import AudioOnlyButton from './AudioOnlyButton';
  10. import { overflowMenuItemStyles } from './styles';
  11. import ToggleCameraButton from './ToggleCameraButton';
  12. /**
  13. * The type of the React {@code Component} props of {@link OverflowMenu}.
  14. */
  15. type Props = {
  16. /**
  17. * Used for hiding the dialog when the selection was completed.
  18. */
  19. dispatch: Function,
  20. };
  21. /**
  22. * The exported React {@code Component}. We need it to execute
  23. * {@link hideDialog}.
  24. *
  25. * XXX It does not break our coding style rule to not utilize globals for state,
  26. * because it is merely another name for {@code export}'s {@code default}.
  27. */
  28. let OverflowMenu_; // eslint-disable-line prefer-const
  29. /**
  30. * Implements a React {@code Component} with some extra actions in addition to
  31. * those in the toolbar.
  32. */
  33. class OverflowMenu extends Component<Props> {
  34. /**
  35. * Initializes a new {@code OverflowMenu} instance.
  36. *
  37. * @inheritdoc
  38. */
  39. constructor(props: Props) {
  40. super(props);
  41. // Bind event handlers so they are only bound once per instance.
  42. this._onCancel = this._onCancel.bind(this);
  43. }
  44. /**
  45. * Implements React's {@link Component#render()}.
  46. *
  47. * @inheritdoc
  48. * @returns {ReactElement}
  49. */
  50. render() {
  51. const buttonProps = {
  52. afterClick: this._onCancel,
  53. showLabel: true,
  54. styles: overflowMenuItemStyles
  55. };
  56. return (
  57. <BottomSheet onCancel = { this._onCancel }>
  58. <AudioRouteButton { ...buttonProps } />
  59. <ToggleCameraButton { ...buttonProps } />
  60. <AudioOnlyButton { ...buttonProps } />
  61. <RoomLockButton { ...buttonProps } />
  62. <RecordButton { ...buttonProps } />
  63. <LiveStreamButton { ...buttonProps } />
  64. <PictureInPictureButton { ...buttonProps } />
  65. </BottomSheet>
  66. );
  67. }
  68. _onCancel: () => void;
  69. /**
  70. * Hides this {@code OverflowMenu}.
  71. *
  72. * @private
  73. * @returns {void}
  74. */
  75. _onCancel() {
  76. this.props.dispatch(hideDialog(OverflowMenu_));
  77. }
  78. }
  79. OverflowMenu_ = connect()(OverflowMenu);
  80. export default OverflowMenu_;