|
@@ -6,8 +6,11 @@ import PauseIcon from '@mui/icons-material/Pause';
|
|
import AttachFileIcon from '@mui/icons-material/AttachFile';
|
|
import AttachFileIcon from '@mui/icons-material/AttachFile';
|
|
import SentimentSatisfiedAltIcon from '@mui/icons-material/SentimentSatisfiedAlt';
|
|
import SentimentSatisfiedAltIcon from '@mui/icons-material/SentimentSatisfiedAlt';
|
|
import CloseIcon from '@mui/icons-material/Close';
|
|
import CloseIcon from '@mui/icons-material/Close';
|
|
|
|
+import PhotoCameraFrontIcon from '@mui/icons-material/PhotoCameraFront';
|
|
import CommentIcon from '@mui/icons-material/Comment';
|
|
import CommentIcon from '@mui/icons-material/Comment';
|
|
import Avatar from '@mui/material/Avatar';
|
|
import Avatar from '@mui/material/Avatar';
|
|
|
|
+import Webcam from "react-webcam";
|
|
|
|
+import CameraIcon from '@mui/icons-material/Camera';
|
|
import TextField from '@mui/material/TextField';
|
|
import TextField from '@mui/material/TextField';
|
|
import Picker from 'emoji-picker-react';
|
|
import Picker from 'emoji-picker-react';
|
|
|
|
|
|
@@ -230,7 +233,38 @@ const useStyles = makeStyles({
|
|
'80%': { transform: 'translate(-0.5px, -0.5px) rotate(1deg)'},
|
|
'80%': { transform: 'translate(-0.5px, -0.5px) rotate(1deg)'},
|
|
'90%': { transform: 'translate(0.5px, 1px) rotate(0deg)'},
|
|
'90%': { transform: 'translate(0.5px, 1px) rotate(0deg)'},
|
|
'100%': { transform: 'translate(0.5px, -1px) rotate(-1deg)'},
|
|
'100%': { transform: 'translate(0.5px, -1px) rotate(-1deg)'},
|
|
- },
|
|
|
|
|
|
+ },
|
|
|
|
+ overlayCamera: {
|
|
|
|
+ position: 'fixed',
|
|
|
|
+ top: 0,
|
|
|
|
+ left: 0,
|
|
|
|
+ width: '100vw',
|
|
|
|
+ height: '100vh',
|
|
|
|
+ zIndex: 100,
|
|
|
|
+ backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
|
|
+ overflowY: 'hidden',
|
|
|
|
+ display: 'flex',
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
+ alignContent: 'center',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ flexDirection:'column'
|
|
|
|
+ },
|
|
|
|
+ capturedPicture: {
|
|
|
|
+ borderRadius: 10,
|
|
|
|
+ border:'solid 2px rgb(62, 149, 231)'
|
|
|
|
+ },
|
|
|
|
+ capturePhoto: {
|
|
|
|
+ color: '#ffffff',
|
|
|
|
+ cursor: 'pointer',
|
|
|
|
+ '&:hover': {
|
|
|
|
+ color: '#48ff00',
|
|
|
|
+ animation: `$rotating 2s linear infinite`
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ '@keyframes rotating': {
|
|
|
|
+ 'from': { transform: 'rotate(0deg)'},
|
|
|
|
+ 'to': { transform: 'rotate(360deg)'},
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
interface ISendMessage{
|
|
interface ISendMessage{
|
|
@@ -248,28 +282,33 @@ const SendMessage = ({isArrow }:ISendMessage) => {
|
|
const [isOpenMenu, setIsOpenMenu] = useState<boolean>(false)
|
|
const [isOpenMenu, setIsOpenMenu] = useState<boolean>(false)
|
|
const [isOpenEmoji, setIsOpenEmoji] = useState<boolean>(false)
|
|
const [isOpenEmoji, setIsOpenEmoji] = useState<boolean>(false)
|
|
const [isRecording, setIsRecording] = useState<boolean>(false)
|
|
const [isRecording, setIsRecording] = useState<boolean>(false)
|
|
- const [isFilming, setIsFilming] = useState<boolean>(false)
|
|
|
|
|
|
+ const [isFilming, setIsFilming] = useState<boolean>(false)
|
|
|
|
+ const [isOpenCamera, setIsOpenCamera] = useState<boolean>(false)
|
|
const [type, setType] = useState<string>('')
|
|
const [type, setType] = useState<string>('')
|
|
const { status, startRecording, stopRecording, mediaBlobUrl, clearBlobUrl } = useReactMediaRecorder({ audio: true,blobPropertyBag:{type: "audio/mp3"}});
|
|
const { status, startRecording, stopRecording, mediaBlobUrl, clearBlobUrl } = useReactMediaRecorder({ audio: true,blobPropertyBag:{type: "audio/mp3"}});
|
|
const { status: _status, startRecording: _startRecording, stopRecording: _stopRecording,
|
|
const { status: _status, startRecording: _startRecording, stopRecording: _stopRecording,
|
|
- mediaBlobUrl: _mediaBlobUrl, clearBlobUrl: _clearBlobUrl } = useReactMediaRecorder({ video: true,blobPropertyBag:{type: "video/mp4"}});
|
|
|
|
|
|
+ mediaBlobUrl: _mediaBlobUrl, clearBlobUrl: _clearBlobUrl } = useReactMediaRecorder({ video: true, blobPropertyBag: { type: "video/mp4" } });
|
|
|
|
+ const videoConstraints = {
|
|
|
|
+ width: 1280,
|
|
|
|
+ height: 720,
|
|
|
|
+ facingMode: "user"
|
|
|
|
+ };
|
|
const onEmojiClick = (_e:any, emojiObject:any) => {
|
|
const onEmojiClick = (_e:any, emojiObject:any) => {
|
|
setValue(prevValue => prevValue + emojiObject.emoji)
|
|
setValue(prevValue => prevValue + emojiObject.emoji)
|
|
setIsOpenEmoji(false)
|
|
setIsOpenEmoji(false)
|
|
};
|
|
};
|
|
const clearMessage = () => {
|
|
const clearMessage = () => {
|
|
- file &&setFile(false)
|
|
|
|
- isRecording && setIsRecording(false)
|
|
|
|
- isFilming && setIsFilming(false)
|
|
|
|
- value && setValue('')
|
|
|
|
- caption&& setCaption('')
|
|
|
|
- type && setType('')
|
|
|
|
- mediaBlobUrl && clearBlobUrl()
|
|
|
|
- _mediaBlobUrl && _clearBlobUrl()
|
|
|
|
- isOpenMenu && setIsOpenMenu(false)
|
|
|
|
- isOpenEmoji && setIsOpenEmoji(false)
|
|
|
|
- isOpenCaption && setIsOpenCaption(false)
|
|
|
|
-
|
|
|
|
|
|
+ file && setFile(false)
|
|
|
|
+ isRecording && setIsRecording(false)
|
|
|
|
+ isFilming && setIsFilming(false)
|
|
|
|
+ value && setValue('')
|
|
|
|
+ caption&& setCaption('')
|
|
|
|
+ type && setType('')
|
|
|
|
+ mediaBlobUrl && clearBlobUrl()
|
|
|
|
+ _mediaBlobUrl && _clearBlobUrl()
|
|
|
|
+ isOpenMenu && setIsOpenMenu(false)
|
|
|
|
+ isOpenEmoji && setIsOpenEmoji(false)
|
|
|
|
+ isOpenCaption && setIsOpenCaption(false)
|
|
}
|
|
}
|
|
const sentMessage = async () => {
|
|
const sentMessage = async () => {
|
|
if (value) sentMessageById(companionId, value,caption.trim())
|
|
if (value) sentMessageById(companionId, value,caption.trim())
|
|
@@ -309,11 +348,11 @@ const SendMessage = ({isArrow }:ISendMessage) => {
|
|
}
|
|
}
|
|
video.send();
|
|
video.send();
|
|
}
|
|
}
|
|
- if (file && type) {
|
|
|
|
|
|
+ if (file && type && type !== 'base64') {
|
|
if (file.type.includes('image') && type === 'content') {
|
|
if (file.type.includes('image') && type === 'content') {
|
|
const formData: any = new FormData()
|
|
const formData: any = new FormData()
|
|
formData.append("image", file);
|
|
formData.append("image", file);
|
|
- await sentImgMessageById(companionId, formData, caption.trim())
|
|
|
|
|
|
+ sentImgMessageById(companionId, formData, caption.trim())
|
|
}
|
|
}
|
|
if (file.type.includes('audio') && type === 'content') {
|
|
if (file.type.includes('audio') && type === 'content') {
|
|
const formData: any = new FormData()
|
|
const formData: any = new FormData()
|
|
@@ -329,8 +368,16 @@ const SendMessage = ({isArrow }:ISendMessage) => {
|
|
const formData: any = new FormData()
|
|
const formData: any = new FormData()
|
|
formData.append("file", file);
|
|
formData.append("file", file);
|
|
sentFileMessageById(companionId, formData,caption.trim())
|
|
sentFileMessageById(companionId, formData,caption.trim())
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (typeof file === 'string' && type === 'base64') {
|
|
|
|
+ fetch(file).then(res => res.blob()).then(blob => {
|
|
|
|
+ const imgFile = new File([blob], "selfie", { type: "image/jpeg" })
|
|
|
|
+ const formData: any = new FormData()
|
|
|
|
+ formData.append("image", imgFile);
|
|
|
|
+ sentImgMessageById(companionId, formData, caption.trim())
|
|
|
|
+ })
|
|
|
|
+ }
|
|
clearMessage()
|
|
clearMessage()
|
|
playNotification(`${prodBaseURL}/send.mp3`)
|
|
playNotification(`${prodBaseURL}/send.mp3`)
|
|
}
|
|
}
|
|
@@ -358,7 +405,15 @@ const SendMessage = ({isArrow }:ISendMessage) => {
|
|
_startRecording()
|
|
_startRecording()
|
|
setType('filming')
|
|
setType('filming')
|
|
setIsFilming(true)
|
|
setIsFilming(true)
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ const handleOpenCamera = () => setIsOpenCamera(true)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const handleCloseCamera = (e: any) => {
|
|
|
|
+ const id = e.target.id
|
|
|
|
+ if (id === 'overlay') setIsOpenCamera(false)
|
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={value || file || status === 'stopped' || _status === 'stopped' ?classes.containerActive:classes.container}>
|
|
<div className={value || file || status === 'stopped' || _status === 'stopped' ?classes.containerActive:classes.container}>
|
|
@@ -428,15 +483,37 @@ const SendMessage = ({isArrow }:ISendMessage) => {
|
|
`${status === 'stopped' || _status === 'stopped' ? 'Recorded' : 'Recording in progress...'}`} rows={1}
|
|
`${status === 'stopped' || _status === 'stopped' ? 'Recorded' : 'Recording in progress...'}`} rows={1}
|
|
style={{color:value || file || status !== 'idle' || _status !== 'idle' ?'rgb(41, 139, 231)':'#6b6b6b'}}>
|
|
style={{color:value || file || status !== 'idle' || _status !== 'idle' ?'rgb(41, 139, 231)':'#6b6b6b'}}>
|
|
</textarea>
|
|
</textarea>
|
|
|
|
+ <PhotoCameraFrontIcon onClick={handleOpenCamera} fontSize='medium'
|
|
|
|
+ sx={{color: isOpenCamera || type === 'base64' ? 'rgb(62, 149, 231)' : '#6b6b6b', marginRight: 1, cursor: 'pointer',
|
|
|
|
+ pointerEvents: type === 'content' || type === 'application' || value || status !== 'idle'
|
|
|
|
+ || _status !== 'idle' ? 'none' : "auto",
|
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)'}}}/>
|
|
<AttachFileIcon onClick={handleOpenFileMenu} className={classes.attachIcon}
|
|
<AttachFileIcon onClick={handleOpenFileMenu} className={classes.attachIcon}
|
|
- fontSize='medium' sx={{color: isOpenMenu ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
|
- pointerEvents: value || status !== 'idle' || _status !== 'idle' ? 'none' : "auto",'&:hover': { color: 'rgb(41, 139, 231)'}}} />
|
|
|
|
|
|
+ fontSize='medium' sx={{color: isOpenMenu || type === 'content' || type === 'application' ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
|
+ pointerEvents: type === 'base64' || value || status !== 'idle' || _status !== 'idle' ? 'none' : "auto", '&:hover':
|
|
|
|
+ { color: 'rgb(41, 139, 231)'}}}/>
|
|
<div onClick={handleCloseFileMenu} className={classes.overlay} id='overlay'
|
|
<div onClick={handleCloseFileMenu} className={classes.overlay} id='overlay'
|
|
style={{ display: isOpenMenu ? 'block':'none'}}>
|
|
style={{ display: isOpenMenu ? 'block':'none'}}>
|
|
<div className={classes.filesMenu} style={{left: rightIsOpen?'52.5vw':'65vw'}}>
|
|
<div className={classes.filesMenu} style={{left: rightIsOpen?'52.5vw':'65vw'}}>
|
|
<FilesMenu setFile={setFile} setValue={setValue} setIsOpenMenu={setIsOpenMenu} setType={setType}/>
|
|
<FilesMenu setFile={setFile} setValue={setValue} setIsOpenMenu={setIsOpenMenu} setType={setType}/>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
|
|
+ {isOpenCamera &&
|
|
|
|
+ <div onClick={handleCloseCamera} id='overlay' className={classes.overlayCamera}>
|
|
|
|
+ <Webcam audio={false} screenshotFormat="image/jpeg" width='40%'
|
|
|
|
+ videoConstraints={videoConstraints} style={{marginBottom:30}}>
|
|
|
|
+ {({ getScreenshot }) => <>
|
|
|
|
+ <CameraIcon onClick={() => {
|
|
|
|
+ setFile(getScreenshot())
|
|
|
|
+ setType('base64')
|
|
|
|
+ playNotification(`${prodBaseURL}/cameraCapture.mp3`)
|
|
|
|
+ }}
|
|
|
|
+ className={classes.capturePhoto} fontSize='large' style={{marginBottom:30}} />
|
|
|
|
+ <img className={classes.capturedPicture} width='300' height='174'
|
|
|
|
+ style={{visibility:file?'visible':'hidden'}} src={file} alt='chosen pic'></img>
|
|
|
|
+ </>}
|
|
|
|
+ </Webcam>
|
|
|
|
+ </div>}
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|