Files
jitsi-meet/react/features/toolbox/components/buttons/AbstractAudioMuteButton.js
Saúl Ibarra Corretgé b634f6b200 feat(toolbox): implement buttons using ToolboxItem
Currently the following are implemented:

- AudioMuteButton
- HangupButton
- VideoMuteButton

In order to implement these new buttons a new abstract class was introduced,
which abstracts the ToolboxItem into a button with enough hooks so a stateful
and a stateless version of it can be created.

This patch only adds the stateful implementation of the aforementioned buttons.
2018-05-15 14:12:38 -05:00

63 lines
1.5 KiB
JavaScript

// @flow
import AbstractButton from './AbstractButton';
import type { Props } from './AbstractButton';
/**
* An abstract implementation of a button for toggling audio mute.
*/
class AbstractAudioMuteButton<P: Props, S: *> extends AbstractButton<P, S> {
accessibilityLabel = 'Audio mute';
iconName = 'icon-microphone';
toggledIconName = 'icon-mic-disabled toggled';
/**
* Handles clicking / pressing the button, and toggles the audio mute state
* accordingly.
*
* @override
* @private
* @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.
*
* @abstract
* @private
* @returns {boolean}
*/
_isAudioMuted() {
// To be implemented by subclass.
}
/**
* Indicates whether this button is in toggled state or not.
*
* @override
* @private
* @returns {boolean}
*/
_isToggled() {
return this._isAudioMuted();
}
/**
* Helper function to perform the actual setting of the audio mute / unmute
* action.
*
* @param {boolean} audioMuted - Whether video should be muted or not.
* @private
* @returns {void}
*/
_setAudioMuted(audioMuted: boolean) { // eslint-disable-line no-unused-vars
// To be implemented by subclass.
}
}
export default AbstractAudioMuteButton;