2024-03-28 00:03:05 +01:00
|
|
|
import { useState } from "react";
|
|
|
|
import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer";
|
|
|
|
import { Button } from "../ui/button";
|
|
|
|
import { FaVideo } from "react-icons/fa";
|
|
|
|
import { isMobile } from "react-device-detect";
|
|
|
|
|
|
|
|
type MobileCameraDrawerProps = {
|
|
|
|
allCameras: string[];
|
|
|
|
selected: string;
|
|
|
|
onSelectCamera: (cam: string) => void;
|
|
|
|
};
|
|
|
|
export default function MobileCameraDrawer({
|
|
|
|
allCameras,
|
|
|
|
selected,
|
|
|
|
onSelectCamera,
|
|
|
|
}: MobileCameraDrawerProps) {
|
|
|
|
const [cameraDrawer, setCameraDrawer] = useState(false);
|
|
|
|
|
|
|
|
if (!isMobile) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Drawer open={cameraDrawer} onOpenChange={setCameraDrawer}>
|
|
|
|
<DrawerTrigger asChild>
|
2024-04-10 00:49:14 +02:00
|
|
|
<Button className="rounded-lg capitalize" size="sm">
|
2024-04-04 22:55:04 +02:00
|
|
|
<FaVideo className="text-secondary-foreground" />
|
2024-03-28 00:03:05 +01:00
|
|
|
</Button>
|
|
|
|
</DrawerTrigger>
|
2024-05-14 17:06:44 +02:00
|
|
|
<DrawerContent className="mx-1 max-h-[75dvh] overflow-hidden rounded-t-2xl px-4">
|
|
|
|
<div className="flex h-auto w-full flex-col items-center gap-2 overflow-y-auto overflow-x-hidden py-4">
|
2024-03-28 18:53:36 +01:00
|
|
|
{allCameras.map((cam) => (
|
|
|
|
<div
|
|
|
|
key={cam}
|
2024-05-14 17:06:44 +02:00
|
|
|
className={`mx-4 w-full py-2 text-center capitalize ${cam == selected ? "rounded-lg bg-secondary" : ""}`}
|
2024-03-28 18:53:36 +01:00
|
|
|
onClick={() => {
|
|
|
|
onSelectCamera(cam);
|
|
|
|
setCameraDrawer(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{cam.replaceAll("_", " ")}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2024-03-28 00:03:05 +01:00
|
|
|
</DrawerContent>
|
|
|
|
</Drawer>
|
|
|
|
);
|
|
|
|
}
|