jiti-meet/react/features/video-menu/components/native/MuteEveryoneDialog.js

104 lines
2.8 KiB
JavaScript
Raw Normal View History

// @flow
import React from 'react';
import Dialog from 'react-native-dialog';
import { Divider } from 'react-native-paper';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
import AbstractMuteEveryoneDialog, {
abstractMapStateToProps,
type Props as AbstractProps } from '../AbstractMuteEveryoneDialog';
import styles from './styles';
type Props = AbstractProps & {
/**
* The color-schemed stylesheet of the base/dialog feature.
*/
_dialogStyles: StyleType
}
/**
* A React Component with the contents for a dialog that asks for confirmation
* from the user before muting all remote participants.
*
2021-11-04 21:10:43 +00:00
* @augments AbstractMuteEveryoneDialog
*/
class MuteEveryoneDialog extends AbstractMuteEveryoneDialog<Props> {
/**
* Renders the dialog switch.
*
* @returns {React$Component}
*/
_renderSwitch() {
return (
this.props.exclude.length === 0
&& <Dialog.Switch
label = { this.props.t('dialog.moderationAudioLabel') }
onValueChange = { this._onToggleModeration }
value = { !this.state.audioModerationEnabled } />
);
}
/**
* Toggles advanced moderation switch.
*
* @returns {void}
*/
_onToggleModeration() {
this.setState(state => {
return {
audioModerationEnabled: !state.audioModerationEnabled,
content: this.props.t(state.audioModerationEnabled
? 'dialog.muteEveryoneDialog' : 'dialog.muteEveryoneDialogModerationOn'
)
};
});
}
/**
* Implements {@code Component#render}.
*
* @inheritdoc
*/
render() {
return (
<ConfirmDialog
confirmLabel = 'dialog.muteParticipantButton'
descriptionKey = { this.state.content }
onSubmit = { this._onSubmit }
title = { this.props.title } >
<Divider style = { styles.dividerDialog } />
{ this._renderSwitch() }
</ConfirmDialog>
);
}
_onSubmit: () => boolean;
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @param {Props} ownProps - The own props of the component.
* @returns {{
* _dialogStyles: StyleType
* }}
*/
function _mapStateToProps(state: Object, ownProps: Props) {
return {
...abstractMapStateToProps(state, ownProps),
_dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
};
}
export default translate(connect(_mapStateToProps)(MuteEveryoneDialog));