You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MuteEveryonesVideoDialog.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // @flow
  2. import React from 'react';
  3. import Dialog from 'react-native-dialog';
  4. import { Divider } from 'react-native-paper';
  5. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  6. import { ConfirmDialog } from '../../../base/dialog';
  7. import { translate } from '../../../base/i18n';
  8. import { connect } from '../../../base/redux';
  9. import { StyleType } from '../../../base/styles';
  10. import AbstractMuteEveryonesVideoDialog, {
  11. abstractMapStateToProps,
  12. type Props as AbstractProps } from '../AbstractMuteEveryonesVideoDialog';
  13. import styles from './styles';
  14. type Props = AbstractProps & {
  15. /**
  16. * The color-schemed stylesheet of the base/dialog feature.
  17. */
  18. _dialogStyles: StyleType
  19. }
  20. /**
  21. * A React Component with the contents for a dialog that asks for confirmation
  22. * from the user before muting all remote participants.
  23. *
  24. * @augments AbstractMuteEveryonesVideoDialog
  25. */
  26. class MuteEveryonesVideoDialog extends AbstractMuteEveryonesVideoDialog<Props> {
  27. /**
  28. * Renders the dialog switch.
  29. *
  30. * @returns {React$Component}
  31. */
  32. _renderSwitch() {
  33. return (
  34. this.props.exclude.length === 0
  35. && <Dialog.Switch
  36. label = { this.props.t('dialog.moderationVideoLabel') }
  37. onValueChange = { this._onToggleModeration }
  38. value = { !this.state.moderationEnabled } />
  39. );
  40. }
  41. /**
  42. * Toggles advanced moderation switch.
  43. *
  44. * @returns {void}
  45. */
  46. _onToggleModeration() {
  47. this.setState(state => {
  48. return {
  49. moderationEnabled: !state.moderationEnabled,
  50. content: this.props.t(state.moderationEnabled
  51. ? 'dialog.muteEveryonesVideoDialog' : 'dialog.muteEveryonesVideoDialogModerationOn'
  52. )
  53. };
  54. });
  55. }
  56. /**
  57. * Implements {@code Component#render}.
  58. *
  59. * @inheritdoc
  60. */
  61. render() {
  62. return (
  63. <ConfirmDialog
  64. confirmLabel = 'dialog.muteEveryonesVideoDialogOk'
  65. descriptionKey = { this.state.content }
  66. onSubmit = { this._onSubmit }
  67. title = { this.props.title }>
  68. <Divider style = { styles.dividerDialog } />
  69. { this._renderSwitch() }
  70. </ConfirmDialog>
  71. );
  72. }
  73. _onSubmit: () => boolean;
  74. }
  75. /**
  76. * Maps part of the Redux state to the props of this component.
  77. *
  78. * @param {Object} state - The Redux state.
  79. * @param {Props} ownProps - The own props of the component.
  80. * @returns {{
  81. * _dialogStyles: StyleType
  82. * }}
  83. */
  84. function _mapStateToProps(state: Object, ownProps: Props) {
  85. return {
  86. ...abstractMapStateToProps(state, ownProps),
  87. _dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
  88. };
  89. }
  90. export default translate(connect(_mapStateToProps)(MuteEveryonesVideoDialog));