import React, { Component } from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; import Settings from '/imports/ui/services/settings'; import { isMobile, isIPad13 } from 'react-device-detect'; import WebcamDraggable from './webcam-draggable-overlay/component'; import { styles } from './styles'; import Storage from '../../services/storage/session'; const BROWSER_ISMOBILE = isMobile || isIPad13; const propTypes = { children: PropTypes.element.isRequired, usersVideo: PropTypes.arrayOf(Array), singleWebcam: PropTypes.bool.isRequired, hideOverlay: PropTypes.bool, swapLayout: PropTypes.bool, disableVideo: PropTypes.bool, audioModalIsOpen: PropTypes.bool, layoutContextState: PropTypes.instanceOf(Object).isRequired, }; const defaultProps = { usersVideo: [], hideOverlay: true, swapLayout: false, disableVideo: false, audioModalIsOpen: false, }; export default class Media extends Component { constructor(props) { super(props); this.refContainer = React.createRef(); } render() { const { swapLayout, singleWebcam, hideOverlay, disableVideo, children, audioModalIsOpen, usersVideo, layoutContextState, } = this.props; const { webcamsPlacement: placement } = layoutContextState; const placementStorage = Storage.getItem('webcamsPlacement'); const webcamsPlacement = placement || placementStorage; const contentClassName = cx({ [styles.content]: true, }); const overlayClassName = cx({ [styles.overlay]: true, [styles.hideOverlay]: hideOverlay, [styles.floatingOverlay]: (webcamsPlacement === 'floating'), }); const containerClassName = cx({ [styles.container]: true, [styles.containerV]: webcamsPlacement === 'top' || webcamsPlacement === 'bottom' || webcamsPlacement === 'floating', [styles.containerH]: webcamsPlacement === 'left' || webcamsPlacement === 'right', }); const { viewParticipantsWebcams } = Settings.dataSaving; const showVideo = usersVideo.length > 0 && viewParticipantsWebcams; const fullHeight = !showVideo || (webcamsPlacement === 'floating'); return (