"use client" import { useState, useEffect } from "react" import { List, Settings2, Headphones, X, Settings, Menu, ArrowUp } from "lucide-react" import { Button } from "@/components/ui/button" import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" import { cn } from "@/lib/utils" import Link from "next/link" import { ReadingSettingsContent } from "./reading-settings" import { TTSPlayer } from "./tts-player" import { ReaderTOC } from "./reader-toc" interface ReaderFABProps { novelId: string novelSlug: string // TTS Props paragraphs: string[] currentChapter: number maxChapter: number chapterTitle: string } export function ReaderFAB({ novelId, novelSlug, paragraphs, currentChapter, maxChapter, chapterTitle }: ReaderFABProps) { const [isOpen, setIsOpen] = useState(false) const [isTTSOpen, setIsTTSOpen] = useState(false) const [isTTSExpanded, setIsTTSExpanded] = useState(false) const [showScrollTop, setShowScrollTop] = useState(false) useEffect(() => { const handleScroll = () => { setShowScrollTop(window.scrollY > 400) } window.addEventListener("scroll", handleScroll, { passive: true }) return () => window.removeEventListener("scroll", handleScroll) }, []) const handleScrollToTop = () => { window.scrollTo({ top: 0, behavior: "smooth" }) } // Reading settings state lifted up for persistence const [fontSize, setFontSize] = useState(18) const [lineHeight, setLineHeight] = useState(1.8) const [letterSpacing, setLetterSpacing] = useState(0) return ( <>
{/* Main FAB Toggle (Mobile mostly, but works as container) */} {/* Action Items */}
{/* TTS Toggle */} {/* TOC */} {/* Settings */} {/* Scroll to Top */}
{/* Inject styles OUTSIDE the popover so it survives */} {/* Render the TTS Player connected to this FAB state */} setIsTTSOpen(false)} isExpanded={isTTSExpanded} onExpandedChange={setIsTTSExpanded} paragraphs={paragraphs} novelSlug={novelSlug} currentChapter={currentChapter} maxChapter={maxChapter} chapterTitle={chapterTitle} /> ) }