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.

VideoBackgroundButton.js 2.2KB

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