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.

FullscreenButton.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconEnterFullscreen, IconExitFullscreen } 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.enterFullScreen';
  17. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.exitFullScreen';
  18. label = 'toolbar.enterFullScreen';
  19. toggledLabel = 'toolbar.exitFullScreen';
  20. tooltip = 'toolbar.enterFullScreen';
  21. toggledTooltip = 'toolbar.exitFullScreen';
  22. /**
  23. * Retrieves icon dynamically.
  24. */
  25. get icon() {
  26. if (this._isToggled()) {
  27. return IconExitFullscreen;
  28. }
  29. return IconEnterFullscreen;
  30. }
  31. /**
  32. * Required by linter due to AbstractButton overwritten prop being writable.
  33. *
  34. * @param {string} _value - The value.
  35. */
  36. set icon(_value) {
  37. // Unused.
  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._fullScreen;
  48. }
  49. }
  50. /**
  51. * Function that maps parts of Redux state tree into component props.
  52. *
  53. * @param {Object} state - Redux state.
  54. * @returns {Object}
  55. */
  56. const mapStateToProps = state => {
  57. return {
  58. _fullScreen: state['features/toolbox'].fullScreen
  59. };
  60. };
  61. export default translate(connect(mapStateToProps)(FullscreenButton));