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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Platform } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import {
  6. BottomSheet,
  7. hideDialog
  8. } from '../../../base/dialog';
  9. import { connect } from '../../../base/redux';
  10. import { StyleType } from '../../../base/styles';
  11. import { InfoDialogButton, InviteButton } from '../../../invite';
  12. import { AudioRouteButton } from '../../../mobile/audio-mode';
  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 RaiseHandButton from './RaiseHandButton';
  19. import ToggleCameraButton from './ToggleCameraButton';
  20. declare var __DEV__;
  21. /**
  22. * The type of the React {@code Component} props of {@link OverflowMenu}.
  23. */
  24. type Props = {
  25. /**
  26. * The color-schemed stylesheet of the dialog feature.
  27. */
  28. _bottomSheetStyles: StyleType,
  29. /**
  30. * Used for hiding the dialog when the selection was completed.
  31. */
  32. dispatch: Function
  33. };
  34. /**
  35. * The exported React {@code Component}. We need it to execute
  36. * {@link hideDialog}.
  37. *
  38. * XXX It does not break our coding style rule to not utilize globals for state,
  39. * because it is merely another name for {@code export}'s {@code default}.
  40. */
  41. let OverflowMenu_; // eslint-disable-line prefer-const
  42. /**
  43. * Implements a React {@code Component} with some extra actions in addition to
  44. * those in the toolbar.
  45. */
  46. class OverflowMenu extends Component<Props> {
  47. /**
  48. * Initializes a new {@code OverflowMenu} instance.
  49. *
  50. * @inheritdoc
  51. */
  52. constructor(props: Props) {
  53. super(props);
  54. // Bind event handlers so they are only bound once per instance.
  55. this._onCancel = this._onCancel.bind(this);
  56. }
  57. /**
  58. * Implements React's {@link Component#render()}.
  59. *
  60. * @inheritdoc
  61. * @returns {ReactElement}
  62. */
  63. render() {
  64. const buttonProps = {
  65. afterClick: this._onCancel,
  66. showLabel: true,
  67. styles: this.props._bottomSheetStyles
  68. };
  69. return (
  70. <BottomSheet onCancel = { this._onCancel }>
  71. <AudioRouteButton { ...buttonProps } />
  72. <ToggleCameraButton { ...buttonProps } />
  73. <AudioOnlyButton { ...buttonProps } />
  74. <RoomLockButton { ...buttonProps } />
  75. <ClosedCaptionButton { ...buttonProps } />
  76. {
  77. // Apple rejected our app because they claim requiring a
  78. // Dropbox account for recording is not acceptable.
  79. // Ddisable it until we can find a way around it.
  80. (__DEV__ || Platform.OS !== 'ios')
  81. && <RecordButton { ...buttonProps } />
  82. }
  83. <LiveStreamButton { ...buttonProps } />
  84. <TileViewButton { ...buttonProps } />
  85. <InviteButton { ...buttonProps } />
  86. <InfoDialogButton { ...buttonProps } />
  87. <RaiseHandButton { ...buttonProps } />
  88. </BottomSheet>
  89. );
  90. }
  91. _onCancel: () => void;
  92. /**
  93. * Hides this {@code OverflowMenu}.
  94. *
  95. * @private
  96. * @returns {void}
  97. */
  98. _onCancel() {
  99. this.props.dispatch(hideDialog(OverflowMenu_));
  100. }
  101. }
  102. /**
  103. * Function that maps parts of Redux state tree into component props.
  104. *
  105. * @param {Object} state - Redux state.
  106. * @private
  107. * @returns {{
  108. * _bottomSheetStyles: StyleType
  109. * }}
  110. */
  111. function _mapStateToProps(state) {
  112. return {
  113. _bottomSheetStyles:
  114. ColorSchemeRegistry.get(state, 'BottomSheet')
  115. };
  116. }
  117. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  118. export default OverflowMenu_;