63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
// @flow
|
|
|
|
import { IconMic, IconMicSlash } from '../../icons';
|
|
|
|
import AbstractButton from './AbstractButton';
|
|
import type { Props } from './AbstractButton';
|
|
|
|
/**
|
|
* An abstract implementation of a button for toggling audio mute.
|
|
*/
|
|
export default class AbstractAudioMuteButton<P: Props, S: *>
|
|
extends AbstractButton<P, S> {
|
|
|
|
icon = IconMic;
|
|
toggledIcon = IconMicSlash;
|
|
|
|
/**
|
|
* Handles clicking / pressing the button, and toggles the audio mute state
|
|
* accordingly.
|
|
*
|
|
* @override
|
|
* @protected
|
|
* @returns {void}
|
|
*/
|
|
_handleClick() {
|
|
this._setAudioMuted(!this._isAudioMuted());
|
|
}
|
|
|
|
/**
|
|
* Helper function to be implemented by subclasses, which must return a
|
|
* boolean value indicating if audio is muted or not.
|
|
*
|
|
* @protected
|
|
* @returns {boolean}
|
|
*/
|
|
_isAudioMuted() {
|
|
// To be implemented by subclass.
|
|
}
|
|
|
|
/**
|
|
* Indicates whether this button is in toggled state or not.
|
|
*
|
|
* @override
|
|
* @protected
|
|
* @returns {boolean}
|
|
*/
|
|
_isToggled() {
|
|
return this._isAudioMuted();
|
|
}
|
|
|
|
/**
|
|
* Helper function to perform the actual setting of the audio mute / unmute
|
|
* action.
|
|
*
|
|
* @param {boolean} audioMuted - Whether audio should be muted or not.
|
|
* @protected
|
|
* @returns {void}
|
|
*/
|
|
_setAudioMuted(audioMuted: boolean) { // eslint-disable-line no-unused-vars
|
|
// To be implemented by subclass.
|
|
}
|
|
}
|