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

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