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

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