2021-07-08 13:42:07 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { IconExitFullScreen, IconFullScreen } from '../../../base/icons';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the app is currently in full screen.
|
|
|
|
*/
|
|
|
|
_fullScreen: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of a button for toggling fullscreen state.
|
|
|
|
*/
|
|
|
|
class FullscreenButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.fullScreen';
|
|
|
|
label = 'toolbar.enterFullScreen';
|
2021-11-04 21:10:43 +00:00
|
|
|
toggledLabel = 'toolbar.exitFullScreen';
|
2021-07-08 13:42:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves icon dynamically.
|
|
|
|
*/
|
|
|
|
get icon() {
|
|
|
|
if (this._isToggled()) {
|
|
|
|
return IconExitFullScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IconFullScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Required by linter due to AbstractButton overwritten prop being writable.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @param {string} _value - The value.
|
2021-07-08 13:42:07 +00:00
|
|
|
*/
|
2021-11-04 21:10:43 +00:00
|
|
|
set icon(_value) {
|
|
|
|
// Unused.
|
2021-07-08 13:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves icon dynamically.
|
|
|
|
*/
|
|
|
|
get tooltip() {
|
|
|
|
if (this._isToggled()) {
|
|
|
|
return 'toolbar.exitFullScreen';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'toolbar.enterFullScreen';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Required by linter due to AbstractButton overwritten prop being writable.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @param {string} _value - The value.
|
2021-07-08 13:42:07 +00:00
|
|
|
*/
|
2021-11-04 21:10:43 +00:00
|
|
|
set tooltip(_value) {
|
|
|
|
// Unused.
|
2021-07-08 13:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._fullScreen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
|
|
|
_fullScreen: state['features/toolbox'].fullScreen
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps)(FullscreenButton));
|