/** * @ai-summary Camera viewfinder with live preview and capture controls * @ai-context Displays video stream with guidance overlay and capture/cancel buttons */ import React, { useRef, useEffect } from 'react'; import { Box, IconButton, Typography } from '@mui/material'; import CameraAltIcon from '@mui/icons-material/CameraAlt'; import CloseIcon from '@mui/icons-material/Close'; import CameraswitchIcon from '@mui/icons-material/Cameraswitch'; import type { CameraViewfinderProps } from './types'; import { GuidanceOverlay } from './GuidanceOverlay'; export const CameraViewfinder: React.FC = ({ stream, guidanceType, onCapture, onCancel, onSwitchCamera, canSwitchCamera, facingMode, }) => { const videoRef = useRef(null); // Attach stream to video element useEffect(() => { if (videoRef.current && stream) { videoRef.current.srcObject = stream; } return () => { if (videoRef.current) { videoRef.current.srcObject = null; } }; }, [stream]); return ( {/* Video preview */} {/* Bottom controls */} {/* Capture button */} Tap to capture ); }; export default CameraViewfinder;