Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

MuteEveryoneDialog.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // @flow
  2. import React from 'react';
  3. import { Text, View, Switch } from 'react-native';
  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 AbstractMuteEveryoneDialog, {
  11. abstractMapStateToProps,
  12. type Props as AbstractProps } from '../AbstractMuteEveryoneDialog';
  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. * @extends AbstractMuteEveryoneDialog
  25. */
  26. class MuteEveryoneDialog extends AbstractMuteEveryoneDialog<Props> {
  27. /**
  28. * Toggles advanced moderation switch.
  29. *
  30. * @returns {void}
  31. */
  32. _onToggleModeration() {
  33. this.setState(state => {
  34. return {
  35. audioModerationEnabled: !state.audioModerationEnabled,
  36. content: this.props.t(state.audioModerationEnabled
  37. ? 'dialog.muteEveryoneDialog' : 'dialog.muteEveryoneDialogModerationOn'
  38. )
  39. };
  40. });
  41. }
  42. /**
  43. * Implements {@code Component#render}.
  44. *
  45. * @inheritdoc
  46. */
  47. render() {
  48. return (
  49. <ConfirmDialog
  50. okKey = 'dialog.muteParticipantButton'
  51. onSubmit = { this._onSubmit } >
  52. <Text style = { this.props._dialogStyles.text }>
  53. { `${this.props.title} \n\n ${this.state.content}` }
  54. </Text>
  55. {this.props.exclude.length === 0 && <>
  56. <Divider style = { styles.dividerWithSpacing } />
  57. <View style = { styles.toggleContainer }>
  58. <Text
  59. style = {{
  60. ...this.props._dialogStyles.text,
  61. ...styles.toggleLabel
  62. }}>
  63. {this.props.t('dialog.moderationAudioLabel')}
  64. </Text>
  65. <Switch
  66. onValueChange = { this._onToggleModeration }
  67. value = { !this.state.audioModerationEnabled } />
  68. </View>
  69. </>}
  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)(MuteEveryoneDialog));