Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

VideoSettingsPopup.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @flow
  2. import React from 'react';
  3. import {
  4. getVideoDeviceIds,
  5. setVideoInputDeviceAndUpdateSettings
  6. } from '../../../../base/devices';
  7. import Popover from '../../../../base/popover/components/Popover.web';
  8. import { connect } from '../../../../base/redux';
  9. import { SMALL_MOBILE_WIDTH } from '../../../../base/responsive-ui/constants';
  10. import { getCurrentCameraDeviceId } from '../../../../base/settings';
  11. import { toggleVideoSettings } from '../../../actions';
  12. import { getVideoSettingsVisibility } from '../../../functions';
  13. import VideoSettingsContent, { type Props as VideoSettingsProps } from './VideoSettingsContent';
  14. type Props = VideoSettingsProps & {
  15. /**
  16. * Component children (the Video button).
  17. */
  18. children: React$Node,
  19. /**
  20. * Flag controlling the visibility of the popup.
  21. */
  22. isOpen: boolean,
  23. /**
  24. * Callback executed when the popup closes.
  25. */
  26. onClose: Function,
  27. /**
  28. * The popup placement enum value.
  29. */
  30. popupPlacement: string
  31. }
  32. /**
  33. * Popup with a preview of all the video devices.
  34. *
  35. * @returns {ReactElement}
  36. */
  37. function VideoSettingsPopup({
  38. currentCameraDeviceId,
  39. children,
  40. isOpen,
  41. onClose,
  42. popupPlacement,
  43. setVideoInputDevice,
  44. videoDeviceIds
  45. }: Props) {
  46. return (
  47. <div className = 'video-preview'>
  48. <Popover
  49. content = { <VideoSettingsContent
  50. currentCameraDeviceId = { currentCameraDeviceId }
  51. setVideoInputDevice = { setVideoInputDevice }
  52. toggleVideoSettings = { onClose }
  53. videoDeviceIds = { videoDeviceIds } /> }
  54. onPopoverClose = { onClose }
  55. position = { popupPlacement }
  56. trigger = 'click'
  57. visible = { isOpen }>
  58. { children }
  59. </Popover>
  60. </div>
  61. );
  62. }
  63. /**
  64. * Maps (parts of) the redux state to the associated {@code VideoSettingsPopup}'s
  65. * props.
  66. *
  67. * @param {Object} state - Redux state.
  68. * @returns {Object}
  69. */
  70. function mapStateToProps(state) {
  71. const { clientWidth } = state['features/base/responsive-ui'];
  72. return {
  73. currentCameraDeviceId: getCurrentCameraDeviceId(state),
  74. isOpen: getVideoSettingsVisibility(state),
  75. popupPlacement: clientWidth <= SMALL_MOBILE_WIDTH ? 'auto' : 'top-end',
  76. videoDeviceIds: getVideoDeviceIds(state)
  77. };
  78. }
  79. const mapDispatchToProps = {
  80. onClose: toggleVideoSettings,
  81. setVideoInputDevice: setVideoInputDeviceAndUpdateSettings
  82. };
  83. export default connect(mapStateToProps, mapDispatchToProps)(VideoSettingsPopup);