|
@@ -1,18 +1,22 @@
|
|
-import WebcamComponent from "./WebcamComponent";
|
|
|
|
import {useRef, useState, useCallback} from 'react';
|
|
import {useRef, useState, useCallback} from 'react';
|
|
|
|
+import Webcam from "react-webcam";
|
|
|
|
+import {Button} from '@mui/material';
|
|
|
|
+import { fileMessage } from '../../../../reducers/messageReducer';
|
|
|
|
+import { useDispatch } from 'react-redux';
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
const WebcamCapture = () => {
|
|
const WebcamCapture = () => {
|
|
|
|
|
|
|
|
+ const dispatch = useDispatch();
|
|
|
|
+
|
|
const webcamRef = useRef(null);
|
|
const webcamRef = useRef(null);
|
|
const [imgSrc, setImgSrc] = useState(null);
|
|
const [imgSrc, setImgSrc] = useState(null);
|
|
- console.log(webcamRef)
|
|
|
|
|
|
|
|
const capture = useCallback(() => {
|
|
const capture = useCallback(() => {
|
|
-
|
|
|
|
-
|
|
|
|
- // const imageSrc = webcamRef.current.getScreenshot();
|
|
|
|
- //setImgSrc(imageSrc);
|
|
|
|
|
|
+ const imageSrc = webcamRef.current.getScreenshot();
|
|
|
|
+ setImgSrc(imageSrc);
|
|
|
|
+ // dispatch(fileMessage( imageSrc))
|
|
}, [webcamRef, setImgSrc]);
|
|
}, [webcamRef, setImgSrc]);
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -25,16 +29,46 @@ const WebcamCapture = () => {
|
|
'zIndex': 9999,
|
|
'zIndex': 9999,
|
|
|
|
|
|
}}>
|
|
}}>
|
|
- <WebcamComponent
|
|
|
|
|
|
+ <Webcam
|
|
audio={false}
|
|
audio={false}
|
|
ref={webcamRef}
|
|
ref={webcamRef}
|
|
screenshotFormat="image/jpeg"
|
|
screenshotFormat="image/jpeg"
|
|
|
|
+ style={{
|
|
|
|
+ 'maxHeight': '350px',
|
|
|
|
+ 'maxWidth': '350px'
|
|
|
|
+ }}
|
|
/>
|
|
/>
|
|
- <button onClick={capture}>Capture photo</button>
|
|
|
|
- {imgSrc && (
|
|
|
|
|
|
+ <Button
|
|
|
|
+ onClick={capture}
|
|
|
|
+ variant="contained"
|
|
|
|
+ component="label"
|
|
|
|
+ >
|
|
|
|
+ New photo
|
|
|
|
+ </Button> {imgSrc && (
|
|
|
|
+ <>
|
|
|
|
+ <Button
|
|
|
|
+ variant="contained"
|
|
|
|
+ component="label"
|
|
|
|
+
|
|
|
|
+ >
|
|
|
|
+ Send
|
|
|
|
+ </Button>
|
|
|
|
+ <Button
|
|
|
|
+ variant="contained"
|
|
|
|
+ component="label"
|
|
|
|
+ >
|
|
|
|
+ Save avatar
|
|
|
|
+ </Button>
|
|
<img
|
|
<img
|
|
src={imgSrc}
|
|
src={imgSrc}
|
|
|
|
+ style={{
|
|
|
|
+ 'border':'4px solid blue',
|
|
|
|
+ 'borderRadius': '10px'
|
|
|
|
+ }}
|
|
|
|
+
|
|
/>
|
|
/>
|
|
|
|
+
|
|
|
|
+ </>
|
|
)}
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|