您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

VirtualBackgroundTab.tsx 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import React from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { withStyles } from 'tss-react/mui';
  4. import AbstractDialogTab, {
  5. IProps as AbstractDialogTabProps
  6. } from '../../../base/dialog/components/web/AbstractDialogTab';
  7. import { translate } from '../../../base/i18n/functions';
  8. import VirtualBackgrounds from '../../../virtual-background/components/VirtualBackgrounds';
  9. import { IVirtualBackground } from '../../../virtual-background/reducer';
  10. /**
  11. * The type of the React {@code Component} props of {@link VirtualBackgroundTab}.
  12. */
  13. export interface IProps extends AbstractDialogTabProps, WithTranslation {
  14. /**
  15. * CSS classes object.
  16. */
  17. classes?: Partial<Record<keyof ReturnType<typeof styles>, string>>;
  18. /**
  19. * Virtual background options.
  20. */
  21. options: IVirtualBackground;
  22. /**
  23. * The id of the selected video device.
  24. */
  25. selectedVideoInputId: string;
  26. }
  27. const styles = () => {
  28. return {
  29. container: {
  30. width: '100%',
  31. display: 'flex',
  32. flexDirection: 'column' as const
  33. }
  34. };
  35. };
  36. /**
  37. * React {@code Component} for modifying language and moderator settings.
  38. *
  39. * @augments Component
  40. */
  41. class VirtualBackgroundTab extends AbstractDialogTab<IProps, any> {
  42. /**
  43. * Initializes a new {@code ModeratorTab} instance.
  44. *
  45. * @param {Object} props - The read-only properties with which the new
  46. * instance is to be initialized.
  47. */
  48. constructor(props: IProps) {
  49. super(props);
  50. // Bind event handler so it is only bound once for every instance.
  51. this._onOptionsChanged = this._onOptionsChanged.bind(this);
  52. }
  53. /**
  54. * Callback invoked to select if follow-me mode
  55. * should be activated.
  56. *
  57. * @param {Object} options - The new background options.
  58. *
  59. * @returns {void}
  60. */
  61. _onOptionsChanged(options: any) {
  62. super._onChange({ options });
  63. }
  64. /**
  65. * Implements React's {@link Component#render()}.
  66. *
  67. * @inheritdoc
  68. * @returns {ReactElement}
  69. */
  70. render() {
  71. const {
  72. options,
  73. selectedVideoInputId
  74. } = this.props;
  75. const classes = withStyles.getClasses(this.props);
  76. return (
  77. <div
  78. className = { classes.container }
  79. id = 'virtual-background-dialog'
  80. key = 'virtual-background'>
  81. <VirtualBackgrounds
  82. onOptionsChange = { this._onOptionsChanged }
  83. options = { options }
  84. selectedThumbnail = { options.selectedThumbnail ?? '' }
  85. selectedVideoInputId = { selectedVideoInputId } />
  86. </div>
  87. );
  88. }
  89. }
  90. export default withStyles(translate(VirtualBackgroundTab), styles);