Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ScreenSharingAndroidButton.js 2.5KB

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