Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ScreenSharingAndroidButton.ts 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  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. interface IProps extends 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. /**
  24. * An implementation of a button for toggling screen sharing.
  25. */
  26. class ScreenSharingAndroidButton extends AbstractButton<IProps> {
  27. accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
  28. icon = IconScreenshare;
  29. label = 'toolbar.startScreenSharing';
  30. toggledLabel = 'toolbar.stopScreenSharing';
  31. /**
  32. * Handles clicking / pressing the button.
  33. *
  34. * @override
  35. * @protected
  36. * @returns {void}
  37. */
  38. _handleClick() {
  39. const enable = !this._isToggled();
  40. this.props.dispatch(toggleScreensharing(enable));
  41. }
  42. /**
  43. * Returns a boolean value indicating if this button is disabled or not.
  44. *
  45. * @protected
  46. * @returns {boolean}
  47. */
  48. _isDisabled() {
  49. return this.props._disabled;
  50. }
  51. /**
  52. * Indicates whether this button is in toggled state or not.
  53. *
  54. * @override
  55. * @protected
  56. * @returns {boolean}
  57. */
  58. _isToggled() {
  59. return this.props._screensharing;
  60. }
  61. }
  62. /**
  63. * Maps (parts of) the redux state to the associated props for the
  64. * {@code ToggleCameraButton} component.
  65. *
  66. * @param {Object} state - The Redux state.
  67. * @private
  68. * @returns {{
  69. * _screensharing: boolean
  70. * }}
  71. */
  72. function _mapStateToProps(state: IReduxState) {
  73. const enabled = getFeatureFlag(state, ANDROID_SCREENSHARING_ENABLED, true);
  74. return {
  75. _screensharing: isLocalVideoTrackDesktop(state),
  76. visible: enabled
  77. };
  78. }
  79. export default translate(connect(_mapStateToProps)(ScreenSharingAndroidButton));