2020-11-10 14:49:38 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
2021-09-22 14:05:42 +00:00
|
|
|
import { Text, View, Switch } from 'react-native';
|
|
|
|
import { Divider } from 'react-native-paper';
|
2020-11-10 14:49:38 +00:00
|
|
|
|
|
|
|
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';
|
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2020-11-10 14:49:38 +00:00
|
|
|
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
|
2020-11-10 14:49:38 +00:00
|
|
|
*/
|
|
|
|
class MuteEveryoneDialog extends AbstractMuteEveryoneDialog<Props> {
|
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
/**
|
|
|
|
* Toggles advanced moderation switch.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onToggleModeration() {
|
|
|
|
this.setState(state => {
|
|
|
|
return {
|
|
|
|
audioModerationEnabled: !state.audioModerationEnabled,
|
|
|
|
content: this.props.t(state.audioModerationEnabled
|
|
|
|
? 'dialog.muteEveryoneDialog' : 'dialog.muteEveryoneDialogModerationOn'
|
|
|
|
)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-10 14:49:38 +00:00
|
|
|
/**
|
|
|
|
* Implements {@code Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<ConfirmDialog
|
|
|
|
okKey = 'dialog.muteParticipantButton'
|
|
|
|
onSubmit = { this._onSubmit } >
|
|
|
|
<Text style = { this.props._dialogStyles.text }>
|
2021-09-22 14:05:42 +00:00
|
|
|
{ `${this.props.title} \n\n ${this.state.content}` }
|
2020-11-10 14:49:38 +00:00
|
|
|
</Text>
|
2021-09-22 14:05:42 +00:00
|
|
|
{this.props.exclude.length === 0 && <>
|
|
|
|
<Divider style = { styles.dividerWithSpacing } />
|
|
|
|
<View style = { styles.toggleContainer }>
|
|
|
|
<Text
|
|
|
|
style = {{
|
|
|
|
...this.props._dialogStyles.text,
|
|
|
|
...styles.toggleLabel
|
|
|
|
}}>
|
|
|
|
{this.props.t('dialog.moderationAudioLabel')}
|
|
|
|
</Text>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onToggleModeration }
|
|
|
|
value = { !this.state.audioModerationEnabled } />
|
|
|
|
</View>
|
|
|
|
</>}
|
2020-11-10 14:49:38 +00:00
|
|
|
</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));
|