mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-04 19:11:14 +03:00
implement draw and move mode on mobile
This commit is contained in:
parent
a3c46e45fd
commit
aad0b77921
@ -24,7 +24,9 @@
|
|||||||
"points_one": "{{count}} point",
|
"points_one": "{{count}} point",
|
||||||
"points_other": "{{count}} points",
|
"points_other": "{{count}} points",
|
||||||
"undo": "Undo last point",
|
"undo": "Undo last point",
|
||||||
"reset": "Reset polygon"
|
"reset": "Reset polygon",
|
||||||
|
"drawMode": "Draw",
|
||||||
|
"moveMode": "Move"
|
||||||
},
|
},
|
||||||
"motionHeatmapLabel": "Motion Heatmap",
|
"motionHeatmapLabel": "Motion Heatmap",
|
||||||
"dialog": {
|
"dialog": {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { isDesktop, isIOS, isMobile } from "react-device-detect";
|
import { isDesktop, isIOS, isMobile } from "react-device-detect";
|
||||||
import { FaArrowRight, FaCalendarAlt, FaCheckCircle } from "react-icons/fa";
|
import { FaArrowRight, FaCalendarAlt, FaCheckCircle } from "react-icons/fa";
|
||||||
import { MdOutlineRestartAlt, MdUndo } from "react-icons/md";
|
import { MdOutlineRestartAlt, MdUndo } from "react-icons/md";
|
||||||
|
import { LuHand, LuPencil } from "react-icons/lu";
|
||||||
|
|
||||||
import { FrigateConfig } from "@/types/frigateConfig";
|
import { FrigateConfig } from "@/types/frigateConfig";
|
||||||
import { TimeRange } from "@/types/timeline";
|
import { TimeRange } from "@/types/timeline";
|
||||||
@ -114,6 +115,7 @@ export default function MotionSearchDialog({
|
|||||||
const { t } = useTranslation(["views/motionSearch", "common"]);
|
const { t } = useTranslation(["views/motionSearch", "common"]);
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const [imageLoaded, setImageLoaded] = useState(false);
|
const [imageLoaded, setImageLoaded] = useState(false);
|
||||||
|
const [panMode, setPanMode] = useState(false);
|
||||||
|
|
||||||
const cameraConfig = useMemo(() => {
|
const cameraConfig = useMemo(() => {
|
||||||
if (!selectedCamera) return undefined;
|
if (!selectedCamera) return undefined;
|
||||||
@ -166,6 +168,7 @@ export default function MotionSearchDialog({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setImageLoaded(false);
|
setImageLoaded(false);
|
||||||
|
setPanMode(false);
|
||||||
}, [selectedCamera]);
|
}, [selectedCamera]);
|
||||||
|
|
||||||
const Overlay = isDesktop ? Dialog : Drawer;
|
const Overlay = isDesktop ? Dialog : Drawer;
|
||||||
@ -240,7 +243,13 @@ export default function MotionSearchDialog({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>
|
<TransformWrapper
|
||||||
|
minScale={1.0}
|
||||||
|
wheel={{ smoothStep: 0.005 }}
|
||||||
|
panning={{ disabled: !isDesktop && !panMode }}
|
||||||
|
pinch={{ disabled: !isDesktop && !panMode }}
|
||||||
|
doubleClick={{ disabled: !isDesktop && !panMode }}
|
||||||
|
>
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<TransformComponent
|
<TransformComponent
|
||||||
wrapperStyle={{
|
wrapperStyle={{
|
||||||
@ -291,6 +300,7 @@ export default function MotionSearchDialog({
|
|||||||
isDrawing={isDrawingROI}
|
isDrawing={isDrawingROI}
|
||||||
setIsDrawing={setIsDrawingROI}
|
setIsDrawing={setIsDrawingROI}
|
||||||
isInteractive={true}
|
isInteractive={true}
|
||||||
|
panMode={panMode}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@ -312,11 +322,41 @@ export default function MotionSearchDialog({
|
|||||||
{polygonClosed && <FaCheckCircle className="ml-2 size-5" />}
|
{polygonClosed && <FaCheckCircle className="ml-2 size-5" />}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row justify-center gap-2">
|
<div className="flex flex-row justify-center gap-2">
|
||||||
|
{!isDesktop && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant={panMode ? "select" : "default"}
|
||||||
|
className="size-8 rounded-md p-1.5"
|
||||||
|
aria-label={
|
||||||
|
panMode
|
||||||
|
? t("polygonControls.moveMode")
|
||||||
|
: t("polygonControls.drawMode")
|
||||||
|
}
|
||||||
|
onClick={() => setPanMode((prev) => !prev)}
|
||||||
|
>
|
||||||
|
{panMode ? (
|
||||||
|
<LuHand className="text-selected-foreground" />
|
||||||
|
) : (
|
||||||
|
<LuPencil className="text-secondary-foreground" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
{panMode
|
||||||
|
? t("polygonControls.moveMode")
|
||||||
|
: t("polygonControls.drawMode")}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
className="size-6 rounded-md p-1"
|
className={cn(
|
||||||
|
"rounded-md",
|
||||||
|
isDesktop ? "size-6 p-1" : "size-8 p-1.5",
|
||||||
|
)}
|
||||||
aria-label={t("polygonControls.undo")}
|
aria-label={t("polygonControls.undo")}
|
||||||
disabled={polygonPoints.length === 0 || isSearching}
|
disabled={polygonPoints.length === 0 || isSearching}
|
||||||
onClick={undoPolygonPoint}
|
onClick={undoPolygonPoint}
|
||||||
@ -332,7 +372,10 @@ export default function MotionSearchDialog({
|
|||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
className="size-6 rounded-md p-1"
|
className={cn(
|
||||||
|
"rounded-md",
|
||||||
|
isDesktop ? "size-6 p-1" : "size-8 p-1.5",
|
||||||
|
)}
|
||||||
aria-label={t("polygonControls.reset")}
|
aria-label={t("polygonControls.reset")}
|
||||||
disabled={polygonPoints.length === 0 || isSearching}
|
disabled={polygonPoints.length === 0 || isSearching}
|
||||||
onClick={resetPolygon}
|
onClick={resetPolygon}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ type MotionSearchROICanvasProps = {
|
|||||||
isDrawing: boolean;
|
isDrawing: boolean;
|
||||||
setIsDrawing: React.Dispatch<React.SetStateAction<boolean>>;
|
setIsDrawing: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
isInteractive?: boolean;
|
isInteractive?: boolean;
|
||||||
|
panMode?: boolean;
|
||||||
motionHeatmap?: Record<string, number> | null;
|
motionHeatmap?: Record<string, number> | null;
|
||||||
showMotionHeatmap?: boolean;
|
showMotionHeatmap?: boolean;
|
||||||
};
|
};
|
||||||
@ -26,6 +27,7 @@ export default function MotionSearchROICanvas({
|
|||||||
isDrawing,
|
isDrawing,
|
||||||
setIsDrawing,
|
setIsDrawing,
|
||||||
isInteractive = true,
|
isInteractive = true,
|
||||||
|
panMode = false,
|
||||||
motionHeatmap,
|
motionHeatmap,
|
||||||
showMotionHeatmap = false,
|
showMotionHeatmap = false,
|
||||||
}: MotionSearchROICanvasProps) {
|
}: MotionSearchROICanvasProps) {
|
||||||
@ -341,7 +343,9 @@ export default function MotionSearchROICanvas({
|
|||||||
ref={setContainerNode}
|
ref={setContainerNode}
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute inset-0 z-10",
|
"absolute inset-0 z-10",
|
||||||
isInteractive ? "pointer-events-auto" : "pointer-events-none",
|
isInteractive && !panMode
|
||||||
|
? "pointer-events-auto"
|
||||||
|
: "pointer-events-none",
|
||||||
)}
|
)}
|
||||||
style={{ cursor: isDrawing ? "crosshair" : "default" }}
|
style={{ cursor: isDrawing ? "crosshair" : "default" }}
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user