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

VideoBackgroundButton.ts 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../app/types';
  3. import { translate } from '../../base/i18n/functions';
  4. import { IconImage } from '../../base/icons/svg';
  5. import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  6. import { openSettingsDialog } from '../../settings/actions';
  7. import { SETTINGS_TABS } from '../../settings/constants';
  8. import { checkBlurSupport } from '../functions';
  9. /**
  10. * The type of the React {@code Component} props of {@link VideoBackgroundButton}.
  11. */
  12. interface IProps extends AbstractButtonProps {
  13. /**
  14. * True if the video background is blurred or false if it is not.
  15. */
  16. _isBackgroundEnabled: boolean;
  17. }
  18. /**
  19. * An abstract implementation of a button that toggles the video background dialog.
  20. */
  21. class VideoBackgroundButton extends AbstractButton<IProps> {
  22. accessibilityLabel = 'toolbar.accessibilityLabel.selectBackground';
  23. icon = IconImage;
  24. label = 'toolbar.selectBackground';
  25. tooltip = 'toolbar.selectBackground';
  26. /**
  27. * Handles clicking / pressing the button, and toggles the virtual background dialog
  28. * state accordingly.
  29. *
  30. * @protected
  31. * @returns {void}
  32. */
  33. _handleClick() {
  34. const { dispatch } = this.props;
  35. dispatch(openSettingsDialog(SETTINGS_TABS.VIRTUAL_BACKGROUND));
  36. }
  37. /**
  38. * Returns {@code boolean} value indicating if the background effect is
  39. * enabled or not.
  40. *
  41. * @protected
  42. * @returns {boolean}
  43. */
  44. _isToggled() {
  45. return this.props._isBackgroundEnabled;
  46. }
  47. }
  48. /**
  49. * Maps (parts of) the redux state to the associated props for the
  50. * {@code VideoBackgroundButton} component.
  51. *
  52. * @param {Object} state - The Redux state.
  53. * @private
  54. * @returns {{
  55. * _isBackgroundEnabled: boolean
  56. * }}
  57. */
  58. function _mapStateToProps(state: IReduxState) {
  59. return {
  60. _isBackgroundEnabled: Boolean(state['features/virtual-background'].backgroundEffectEnabled),
  61. visible: checkBlurSupport()
  62. };
  63. }
  64. export default translate(connect(_mapStateToProps)(VideoBackgroundButton));