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.

ScreenSharingAndroidButton.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @flow
  2. import {
  3. ANDROID_SCREENSHARING_ENABLED,
  4. getFeatureFlag
  5. } from '../../../base/flags';
  6. import { translate } from '../../../base/i18n';
  7. import { IconShareDesktop } from '../../../base/icons';
  8. import { connect } from '../../../base/redux';
  9. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  10. import { toggleScreensharing, isLocalVideoTrackDesktop } from '../../../base/tracks';
  11. /**
  12. * The type of the React {@code Component} props of {@link ScreenSharingAndroidButton}.
  13. */
  14. type Props = AbstractButtonProps & {
  15. /**
  16. * True if the button needs to be disabled.
  17. */
  18. _disabled: boolean,
  19. /**
  20. * Whether video is currently muted or not.
  21. */
  22. _screensharing: boolean,
  23. /**
  24. * The redux {@code dispatch} function.
  25. */
  26. dispatch: Function
  27. };
  28. /**
  29. * An implementation of a button for toggling screen sharing.
  30. */
  31. class ScreenSharingAndroidButton extends AbstractButton<Props, *> {
  32. accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
  33. icon = IconShareDesktop;
  34. label = 'toolbar.startScreenSharing';
  35. toggledLabel = 'toolbar.stopScreenSharing';
  36. /**
  37. * Handles clicking / pressing the button.
  38. *
  39. * @override
  40. * @protected
  41. * @returns {void}
  42. */
  43. _handleClick() {
  44. const enable = !this._isToggled();
  45. this.props.dispatch(toggleScreensharing(enable));
  46. }
  47. /**
  48. * Returns a boolean value indicating if this button is disabled or not.
  49. *
  50. * @protected
  51. * @returns {boolean}
  52. */
  53. _isDisabled() {
  54. return this.props._disabled;
  55. }
  56. /**
  57. * Indicates whether this button is in toggled state or not.
  58. *
  59. * @override
  60. * @protected
  61. * @returns {boolean}
  62. */
  63. _isToggled() {
  64. return this.props._screensharing;
  65. }
  66. }
  67. /**
  68. * Maps (parts of) the redux state to the associated props for the
  69. * {@code ToggleCameraButton} component.
  70. *
  71. * @param {Object} state - The Redux state.
  72. * @private
  73. * @returns {{
  74. * _screensharing: boolean
  75. * }}
  76. */
  77. function _mapStateToProps(state): Object {
  78. const enabled = getFeatureFlag(state, ANDROID_SCREENSHARING_ENABLED, true);
  79. return {
  80. _screensharing: isLocalVideoTrackDesktop(state),
  81. visible: enabled
  82. };
  83. }
  84. export default translate(connect(_mapStateToProps)(ScreenSharingAndroidButton));