import { makeStyles, Typography } from '@material-ui/core' import { useState,useEffect } from 'react'; import { useSelector } from 'react-redux'; import ListItemText from '@mui/material/ListItemText'; import ListItemAvatar from '@mui/material/ListItemAvatar'; import Avatar from '@mui/material/Avatar'; import MinimizeIcon from '@mui/icons-material/Minimize'; import CropLandscapeIcon from '@mui/icons-material/CropLandscape'; import CloseIcon from '@mui/icons-material/Close'; import ScreenShareIcon from '@mui/icons-material/ScreenShare'; import StopScreenShareIcon from '@mui/icons-material/StopScreenShare'; import VideocamIcon from '@mui/icons-material/Videocam'; import VideocamOffIcon from '@mui/icons-material/VideocamOff'; import MicIcon from '@mui/icons-material/Mic'; import MicOffIcon from '@mui/icons-material/MicOff'; import CallEndIcon from '@mui/icons-material/CallEnd'; import Moveable from "react-moveable"; import { OnDrag } from "react-moveable"; import { getChat } from '../../../../../../redux/chat/selector'; import { prodAwsS3,firstLetter,slicedWord } from '../../../../../../helpers' const useStyles = makeStyles({ overlay: { position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', zIndex: 100, overflow: 'hidden', display: 'flex', justifyContent: 'center', alignItems: 'center', alignContent: "center", backgroundColor: 'rgba(104, 105, 104, 0.6)', }, shareScreenActive: { width: '90%', borderRadius: 7, margin: 'auto', border:'solid 2px #0084ff', }, shareScreenDisabled: { width: 0, height:0, }, modalCall: { background: 'rgb(36, 36, 36)', display: 'flex', flexDirection: 'column', justifyContent: 'start', alignItems: 'center', justifyItems:"center", width: '34vw', height:'50vh', borderRadius: 7, }, rightIcons: { display: 'flex', justifyContent: 'end', alignContent: 'center', alignItems: 'center', width:'100%' }, rightIconWrapper: { color: '#ffffff', cursor: 'pointer', padding:'3px 10px 3px 10px', '&:hover': { backgroundColor:'rgb(80, 80, 80)' } }, rightIconWrapperClose: { color: '#ffffff', cursor: 'pointer', padding:'3px 10px 3px 10px', borderTopRightRadius:7, '&:hover': { backgroundColor:'#f02a2a' } }, statusCall: { color: "#dfdfdf", animation: 'ripple 4s infinite ease-in-out', }, animatedDots: { fontWeight: 'bold', display:'inline-block', fontFamily: 'monospace', clipPath: 'inset(0 3ch 0 0)', animation: `$run 2s steps(5) infinite`, }, bottomWrapper: { display: 'flex', justifyContent: 'center', padding: 5 }, bottomItem: { display: 'flex', flexDirection: 'column', justifyContent: 'center', alignContent: 'center', alignItems: 'center', cursor:'pointer', width: 80, }, bottomIcon: { cursor:'pointer', }, titleIconBottom: { color: '#ffffff', fontSize: 13, paddingTop:7 }, '@keyframes run': { to: { clipPath: 'inset(0 -1ch 0 0)' }, }, }) interface ICallModal { setModalCall:any, shareRef: any, videoRef: any, } const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => { const classes = useStyles() const { name, lastName, avatarUrl, color } = useSelector(getChat) const [audio, setAudio] = useState(true) const [video, setVideo] = useState(false) const [share, setShare] = useState(null) const handleShareScreen = async () => { const displayMediaStreamConstraints = { video: true, }; const navigator:any = window.navigator const stream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints); shareRef.current.srcObject = stream; setShare(true) stream.getVideoTracks()[0].onended = () => setShare(false) }; const handleAudio = () => setAudio(prevState => !prevState) const handleVideo = async () => { const displayMediaStreamConstraints = { audio: false, video: { width: { min: 1280, ideal: 1920, max: 2560, }, height: { min: 720, ideal: 1080, max: 1440 }, facingMode: 'user' }, }; const navigator:any = window.navigator const stream = await navigator.mediaDevices.getUserMedia(displayMediaStreamConstraints) if (!video) { setVideo(true) videoRef.current.srcObject = stream; } else { videoRef.current.srcObject = null; stream.getVideoTracks()[0].stop() setVideo(false) } } const handleCloseCallModal = () => setModalCall(false) // requesting, waiting ,ringing, hanging up,line busy // useEffect(() => { // socket.on('connect', () => { // setIsConnected(true); // }); // socket.on('disconnect', () => { // setIsConnected(false); // }); // socket.on('pong', () => { // setLastPong(new Date().toISOString()); // }); // return () => { // socket.off('connect'); // socket.off('disconnect'); // socket.off('pong'); // }; // }, []); return (
) } export default CallModal