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

FullscreenButton.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconExitFullScreen, IconFullScreen } from '../../../base/icons';
  4. import { connect } from '../../../base/redux';
  5. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  6. type Props = AbstractButtonProps & {
  7. /**
  8. * Whether or not the app is currently in full screen.
  9. */
  10. _fullScreen: boolean,
  11. };
  12. /**
  13. * Implementation of a button for toggling fullscreen state.
  14. */
  15. class FullscreenButton extends AbstractButton<Props, *> {
  16. accessibilityLabel = 'toolbar.accessibilityLabel.fullScreen';
  17. label = 'toolbar.enterFullScreen';
  18. toggledLabel = 'toolbar.exitFullScreen'
  19. /**
  20. * Retrieves icon dynamically.
  21. */
  22. get icon() {
  23. if (this._isToggled()) {
  24. return IconExitFullScreen;
  25. }
  26. return IconFullScreen;
  27. }
  28. /**
  29. * Required by linter due to AbstractButton overwritten prop being writable.
  30. *
  31. * @param {string} value - The value.
  32. */
  33. set icon(value) {
  34. return value;
  35. }
  36. /**
  37. * Retrieves icon dynamically.
  38. */
  39. get tooltip() {
  40. if (this._isToggled()) {
  41. return 'toolbar.exitFullScreen';
  42. }
  43. return 'toolbar.enterFullScreen';
  44. }
  45. /**
  46. * Required by linter due to AbstractButton overwritten prop being writable.
  47. *
  48. * @param {string} value - The value.
  49. */
  50. set tooltip(value) {
  51. return value;
  52. }
  53. /**
  54. * Handles clicking / pressing the button, and opens the appropriate dialog.
  55. *
  56. * @protected
  57. * @returns {void}
  58. */
  59. _handleClick() {
  60. const { handleClick } = this.props;
  61. if (handleClick) {
  62. handleClick();
  63. return;
  64. }
  65. }
  66. /**
  67. * Indicates whether this button is in toggled state or not.
  68. *
  69. * @override
  70. * @protected
  71. * @returns {boolean}
  72. */
  73. _isToggled() {
  74. return this.props._fullScreen;
  75. }
  76. }
  77. /**
  78. * Function that maps parts of Redux state tree into component props.
  79. *
  80. * @param {Object} state - Redux state.
  81. * @returns {Object}
  82. */
  83. const mapStateToProps = state => {
  84. return {
  85. _fullScreen: state['features/toolbox'].fullScreen
  86. };
  87. };
  88. export default translate(connect(mapStateToProps)(FullscreenButton));