From 5f25f29d7e98966e9e04b760b51249c8fded2a61 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 1 Apr 2024 13:55:04 -0600 Subject: [PATCH] Show frigate features in bottom sheet on mobile --- web/src/views/live/LiveCameraView.tsx | 198 +++++++++++++++++++------- 1 file changed, 150 insertions(+), 48 deletions(-) diff --git a/web/src/views/live/LiveCameraView.tsx b/web/src/views/live/LiveCameraView.tsx index b406f603b..668d850f5 100644 --- a/web/src/views/live/LiveCameraView.tsx +++ b/web/src/views/live/LiveCameraView.tsx @@ -8,12 +8,15 @@ import { import CameraFeatureToggle from "@/components/dynamic/CameraFeatureToggle"; import LivePlayer from "@/components/player/LivePlayer"; import { Button } from "@/components/ui/button"; +import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; import { TooltipProvider } from "@/components/ui/tooltip"; import { useResizeObserver } from "@/hooks/resize-observer"; import useKeyboardListener from "@/hooks/use-keyboard-listener"; @@ -39,6 +42,7 @@ import { FaAngleLeft, FaAngleRight, FaAngleUp, + FaCog, FaCompress, FaExpand, FaMicrophone, @@ -70,19 +74,6 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) { const [{ width: windowWidth, height: windowHeight }] = useResizeObserver(window); - // camera features - - const { payload: detectState, send: sendDetect } = useDetectState( - camera.name, - ); - const { payload: recordState, send: sendRecord } = useRecordingsState( - camera.name, - ); - const { payload: snapshotState, send: sendSnapshot } = useSnapshotsState( - camera.name, - ); - const { payload: audioState, send: sendAudio } = useAudioState(camera.name); - // click overlay for ptzs const [clickOverlay, setClickOverlay] = useState(false); @@ -264,42 +255,11 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) { title={`${audio ? "Disable" : "Enable"} Camera Audio`} onClick={() => setAudio(!audio)} /> - sendDetect(detectState == "ON" ? "OFF" : "ON")} + - sendRecord(recordState == "ON" ? "OFF" : "ON")} - /> - - sendSnapshot(snapshotState == "ON" ? "OFF" : "ON") - } - /> - {camera.audio.enabled_in_config && ( - sendAudio(audioState == "ON" ? "OFF" : "ON")} - /> - )} @@ -532,3 +492,145 @@ function PtzControlPanel({ ); } + +type FrigateCameraFeaturesProps = { + camera: string; + audioDetectEnabled: boolean; + fullscreen: boolean; +}; +function FrigateCameraFeatures({ + camera, + audioDetectEnabled, + fullscreen, +}: FrigateCameraFeaturesProps) { + const { payload: detectState, send: sendDetect } = useDetectState(camera); + const { payload: recordState, send: sendRecord } = useRecordingsState(camera); + const { payload: snapshotState, send: sendSnapshot } = + useSnapshotsState(camera); + const { payload: audioState, send: sendAudio } = useAudioState(camera); + + // desktop shows icons part of row + if (isDesktop) { + return ( + <> + sendDetect(detectState == "ON" ? "OFF" : "ON")} + /> + sendRecord(recordState == "ON" ? "OFF" : "ON")} + /> + sendSnapshot(snapshotState == "ON" ? "OFF" : "ON")} + /> + {audioDetectEnabled && ( + sendAudio(audioState == "ON" ? "OFF" : "ON")} + /> + )} + + ); + } + + // mobile doesn't show settings in fullscreen view + if (fullscreen) { + return; + } + + return ( + + + + + +
+ + + sendDetect(detectState == "ON" ? "OFF" : "ON") + } + /> +
+
+ + + sendRecord(recordState == "ON" ? "OFF" : "ON") + } + /> +
+
+ + + sendSnapshot(snapshotState == "ON" ? "OFF" : "ON") + } + /> +
+ {audioDetectEnabled && ( +
+ + + sendAudio(audioState == "ON" ? "OFF" : "ON") + } + /> +
+ )} +
+
+ ); +}