Add CameraSettings context and provider; integrate into AppProviders and VideoFeed

This commit is contained in:
2025-12-22 16:10:34 +00:00
parent 6879e30b9c
commit 70083d9c60
10 changed files with 118 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ import { Stage, Layer, Image, Rect } from "react-konva";
import type { SightingType } from "../../../../utils/types";
import { useCreateVideoSnapshot } from "../../hooks/useCreateVideoSnapshot";
import { useEffect, useState } from "react";
import { useCameraSettingsContext } from "../../../../app/context/CameraSettingsContext";
type VideoFeedProps = {
mostRecentSighting: SightingType;
@@ -9,13 +10,16 @@ type VideoFeedProps = {
};
const VideoFeed = ({ mostRecentSighting, isLoading }: VideoFeedProps) => {
const { state: cameraSettings, dispatch } = useCameraSettingsContext();
const mode = cameraSettings.mode;
const [size, setSize] = useState<{ width: number; height: number }>({ width: 1280, height: 960 });
const [mode, setMode] = useState<number>(0);
const { image, plateRect, plateTrack } = useCreateVideoSnapshot(mostRecentSighting);
const handleModeChange = (newMode: number) => {
if (newMode > 2) setMode(0);
else setMode(newMode);
if (newMode > 2) dispatch({ type: "SET_MODE", payload: 0 });
else dispatch({ type: "SET_MODE", payload: newMode });
};
useEffect(() => {