mosaicmap/app/control.tsx
2025-07-17 22:57:07 +08:00

170 lines
6.9 KiB
TypeScript

import { Button, buttonVariants } from "@/components/ui/button"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Separator } from "@/components/ui/separator"
import { Slider } from "@/components/ui/slider"
import { Switch } from "@/components/ui/switch"
import { Download, Pause, Play, RotateCcw, Settings, Share2 } from "lucide-react"
import { useState } from "react"
export const Control = () => {
const [selectedLocation, setSelectedLocation] = useState('beijing');
const handleLocationChange = (value: string) => {
setSelectedLocation(value);
}
const [selectedLayer, setSelectedLayer] = useState('precipitation');
const handleLayerChange = (value: string) => {
setSelectedLayer(value);
}
const [isPlaying, setIsPlaying] = useState(false);
const togglePlayback = () => {
setIsPlaying(!isPlaying);
}
const [animationSpeed, setAnimationSpeed] = useState([1.0]);
const resetAnimation = () => {
setAnimationSpeed([1.0]);
}
const [radarVisible, setRadarVisible] = useState(true);
const [showLegend, setShowLegend] = useState(true);
const [opacity, setOpacity] = useState([0.5]);
return (
<Card className="lg:col-span-1">
<CardHeader>
<div className="flex items-center gap-2">
<Settings className="w-5 h-5" />
<h3 className="font-semibold"></h3>
</div>
</CardHeader>
<CardContent>
<div className="space-y-4">
<div className="flex flex-col gap-2">
<Label htmlFor="location"></Label>
<Select value={selectedLocation} onValueChange={handleLocationChange}>
<SelectTrigger className="w-full">
<SelectValue placeholder="选择城市" />
</SelectTrigger>
<SelectContent>
<SelectItem value="beijing"></SelectItem>
<SelectItem value="shanghai"></SelectItem>
<SelectItem value="guangzhou">广</SelectItem>
<SelectItem value="shenzhen"></SelectItem>
</SelectContent>
</Select>
</div>
{/* Layer Selection */}
<div className="flex flex-col gap-2">
<Label></Label>
<Select value={selectedLayer} onValueChange={setSelectedLayer}>
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="precipitation"></SelectItem>
<SelectItem value="velocity"></SelectItem>
<SelectItem value="reflectivity"></SelectItem>
</SelectContent>
</Select>
</div>
<Separator />
{/* Animation Controls */}
<div className="space-y-3">
<Label></Label>
<div className="flex gap-2">
<Button
variant="outline"
size="sm"
onClick={togglePlayback}
className="flex-1"
>
{isPlaying ? <Pause className="w-4 h-4" /> : <Play className="w-4 h-4" />}
</Button>
<Button
variant="outline"
size="sm"
onClick={resetAnimation}
>
<RotateCcw className="w-4 h-4" />
</Button>
</div>
<div>
<Label className="text-sm">: {animationSpeed[0]}x</Label>
<Slider
value={animationSpeed}
onValueChange={setAnimationSpeed}
max={3}
min={0.5}
step={0.5}
className="mt-2"
/>
</div>
</div>
<Separator />
{/* Display Options */}
<div className="space-y-3">
<Label></Label>
<div className="flex items-center justify-between">
<span className="text-sm"></span>
<Switch checked={radarVisible} onCheckedChange={setRadarVisible} />
</div>
<div className="flex items-center justify-between">
<span className="text-sm"></span>
<Switch checked={showLegend} onCheckedChange={setShowLegend} />
</div>
<div>
<Label className="text-sm">: {Math.round(opacity[0] * 100)}%</Label>
<Slider
value={opacity}
onValueChange={setOpacity}
max={1}
min={0.1}
step={0.1}
className="mt-2"
/>
</div>
</div>
<Separator />
{/* Export Options */}
<div className="space-y-2">
<Label></Label>
<div className="flex gap-2">
<Button variant="outline" size="sm" className="flex-1">
<Download className="w-4 h-4 mr-1" />
</Button>
<Button variant="outline" size="sm" className="flex-1">
<Share2 className="w-4 h-4 mr-1" />
</Button>
</div>
</div>
</div>
</CardContent>
</Card>
)
}