您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RaiseHandButton.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconRaisedHand } from '../../../base/icons';
  4. import { getLocalParticipant } from '../../../base/participants';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. type Props = AbstractButtonProps & {
  8. /**
  9. * Whether or not the local participant's hand is raised.
  10. */
  11. _raisedHand: boolean,
  12. };
  13. /**
  14. * Implementation of a button for toggling raise hand functionality.
  15. */
  16. class RaiseHandButton extends AbstractButton<Props, *> {
  17. accessibilityLabel = 'toolbar.accessibilityLabel.raiseHand';
  18. icon = IconRaisedHand
  19. label = 'toolbar.raiseYourHand';
  20. toggledLabel = 'toolbar.lowerYourHand'
  21. /**
  22. * Retrieves tooltip dynamically.
  23. */
  24. get tooltip() {
  25. return this.props._raisedHand ? 'toolbar.lowerYourHand' : 'toolbar.raiseYourHand';
  26. }
  27. /**
  28. * Required by linter due to AbstractButton overwritten prop being writable.
  29. *
  30. * @param {string} value - The value.
  31. */
  32. set tooltip(value) {
  33. return value;
  34. }
  35. /**
  36. * Handles clicking / pressing the button, and opens the appropriate dialog.
  37. *
  38. * @protected
  39. * @returns {void}
  40. */
  41. _handleClick() {
  42. const { handleClick } = this.props;
  43. if (handleClick) {
  44. handleClick();
  45. return;
  46. }
  47. }
  48. /**
  49. * Indicates whether this button is in toggled state or not.
  50. *
  51. * @override
  52. * @protected
  53. * @returns {boolean}
  54. */
  55. _isToggled() {
  56. return this.props._raisedHand;
  57. }
  58. }
  59. /**
  60. * Function that maps parts of Redux state tree into component props.
  61. *
  62. * @param {Object} state - Redux state.
  63. * @returns {Object}
  64. */
  65. const mapStateToProps = state => {
  66. const localParticipant = getLocalParticipant(state);
  67. return {
  68. _raisedHand: localParticipant.raisedHand
  69. };
  70. };
  71. export default translate(connect(mapStateToProps)(RaiseHandButton));