Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

OverflowMenu.js 2.7KB

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