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.4KB

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