2022-10-11 10:47:54 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState, IStore } from '../../../app/types';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconWhiteboard, IconWhiteboardHide } from '../../../base/icons/svg';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { connect } from '../../../base/redux/functions';
|
2022-09-30 14:50:45 +00:00
|
|
|
// @ts-ignore
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
|
|
|
// @ts-ignore
|
|
|
|
import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
|
|
|
|
import { setWhiteboardOpen } from '../../actions';
|
|
|
|
import { isWhiteboardVisible } from '../../functions';
|
|
|
|
|
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the button is toggled.
|
|
|
|
*/
|
|
|
|
_toggled: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
2022-10-11 10:47:54 +00:00
|
|
|
dispatch: IStore['dispatch'];
|
2022-09-30 14:50:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders a toolbar button for the whiteboard.
|
|
|
|
*/
|
|
|
|
class WhiteboardButton extends AbstractButton<Props, any, any> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.whiteboard';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconWhiteboard;
|
2022-09-30 14:50:45 +00:00
|
|
|
label = 'toolbar.showWhiteboard';
|
2022-11-08 10:24:32 +00:00
|
|
|
toggledIcon = IconWhiteboardHide;
|
2022-09-30 14:50:45 +00:00
|
|
|
toggledLabel = 'toolbar.hideWhiteboard';
|
|
|
|
toggledTooltip = 'toolbar.hideWhiteboard';
|
|
|
|
tooltip = 'toolbar.showWhiteboard';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens / closes the whiteboard view.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
const { dispatch, _toggled } = this.props;
|
|
|
|
|
|
|
|
dispatch(setWhiteboardOpen(!_toggled));
|
|
|
|
dispatch(setOverflowMenuVisible(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
// @ts-ignore
|
|
|
|
return this.props._toggled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
function _mapStateToProps(state: IReduxState) {
|
2022-09-30 14:50:45 +00:00
|
|
|
return {
|
|
|
|
_toggled: isWhiteboardVisible(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
export default translate(connect(_mapStateToProps)(WhiteboardButton));
|