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

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