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

AudioSettingsPopup.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @flow
  2. import React from 'react';
  3. import InlineDialog from '@atlaskit/inline-dialog';
  4. import AudioSettingsContent, { type Props as AudioSettingsContentProps } from './AudioSettingsContent';
  5. import { toggleAudioSettings } from '../../../actions';
  6. import {
  7. getAudioInputDeviceData,
  8. getAudioOutputDeviceData,
  9. setAudioInputDevice as setAudioInputDeviceAction,
  10. setAudioOutputDevice as setAudioOutputDeviceAction
  11. } from '../../../../base/devices';
  12. import { connect } from '../../../../base/redux';
  13. import { getAudioSettingsVisibility } from '../../../functions';
  14. import {
  15. getCurrentMicDeviceId,
  16. getCurrentOutputDeviceId
  17. } from '../../../../base/settings';
  18. type Props = AudioSettingsContentProps & {
  19. /**
  20. * Component's children (the audio button).
  21. */
  22. children: React$Node,
  23. /**
  24. * Flag controlling the visibility of the popup.
  25. */
  26. isOpen: boolean,
  27. /**
  28. * Callback executed when the popup closes.
  29. */
  30. onClose: Function,
  31. }
  32. /**
  33. * Popup with audio settings.
  34. *
  35. * @returns {ReactElement}
  36. */
  37. function AudioSettingsPopup({
  38. children,
  39. currentMicDeviceId,
  40. currentOutputDeviceId,
  41. isOpen,
  42. microphoneDevices,
  43. setAudioInputDevice,
  44. setAudioOutputDevice,
  45. onClose,
  46. outputDevices
  47. }: Props) {
  48. return (
  49. <div className = 'audio-preview'>
  50. <InlineDialog
  51. content = { <AudioSettingsContent
  52. currentMicDeviceId = { currentMicDeviceId }
  53. currentOutputDeviceId = { currentOutputDeviceId }
  54. microphoneDevices = { microphoneDevices }
  55. outputDevices = { outputDevices }
  56. setAudioInputDevice = { setAudioInputDevice }
  57. setAudioOutputDevice = { setAudioOutputDevice } /> }
  58. isOpen = { isOpen }
  59. onClose = { onClose }
  60. position = 'top left'>
  61. {children}
  62. </InlineDialog>
  63. </div>
  64. );
  65. }
  66. /**
  67. * Function that maps parts of Redux state tree into component props.
  68. *
  69. * @param {Object} state - Redux state.
  70. * @returns {Object}
  71. */
  72. function mapStateToProps(state) {
  73. return {
  74. currentMicDeviceId: getCurrentMicDeviceId(state),
  75. currentOutputDeviceId: getCurrentOutputDeviceId(state),
  76. isOpen: getAudioSettingsVisibility(state),
  77. microphoneDevices: getAudioInputDeviceData(state),
  78. outputDevices: getAudioOutputDeviceData(state)
  79. };
  80. }
  81. const mapDispatchToProps = {
  82. onClose: toggleAudioSettings,
  83. setAudioInputDevice: setAudioInputDeviceAction,
  84. setAudioOutputDevice: setAudioOutputDeviceAction
  85. };
  86. export default connect(mapStateToProps, mapDispatchToProps)(AudioSettingsPopup);