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.

ScreenSharingButton.js 1.9KB

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