import { motion, useReducedMotion } from 'motion/react' import { Headphones, Lock, UserRound } from 'lucide-react' import { LIMITS } from '@music-together/shared' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useState } from 'react' import { storage } from '@/lib/storage' interface InteractionGateProps { onStart: (password?: string) => void roomName?: string hasPassword?: boolean passwordError?: string | null } export function InteractionGate({ onStart, roomName, hasPassword, passwordError }: InteractionGateProps) { const prefersReducedMotion = useReducedMotion() const [password, setPassword] = useState('') const savedNickname = storage.getNickname() const needsNickname = !savedNickname const [nickname, setNickname] = useState(savedNickname) const canStart = (!needsNickname || nickname.trim().length > 0) && (!hasPassword || password.trim().length > 0) const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!canStart) return if (needsNickname) { storage.setNickname(nickname.trim()) } onStart(hasPassword ? password.trim() : undefined) } return (
即将加入「{roomName}」
) : (点击开始,与房间好友一起听歌
)}