import React, { useEffect } from 'react'; import NavDrawer from './NavDrawer'; import ReaderPanel from './ReaderPanel'; import RightToolbar from '../toolbar/RightToolbar'; import MobileBottomBar from './MobileBottomBar'; import AIPopup from '../ai/AIPopup'; import AIFloatingMenu from '../ai/AIFloatingMenu'; import ErrorBoundary from '../common/ErrorBoundary'; import { Menu } from 'lucide-react'; import { useUIStore, useThemeStore } from '../../stores/appStore'; import { useAIStore } from '../../stores/aiStore'; import { AnimatePresence, motion } from 'framer-motion'; import { useKeyboardNav } from '../../hooks/useKeyboardNav'; // Shell = NavDrawer bg per theme — seamless sidebar integration const SHELL_BG: Record = { dark: 'theme-dark-bg', light: 'theme-light-bg', classic: 'theme-classic-bg', }; // Menu button bg per theme (matches RightToolbar bg for visual consistency) const MENU_BTN: Record = { dark: 'bg-[#222242] hover:bg-[#2a2a4e]', light: 'bg-[#e8e0c8] hover:bg-[#ddd5bd]', classic: 'bg-[#e0d5b8] hover:bg-[#d5caad]', }; const AppShell: React.FC = () => { const { toggleNav, isNavOpen } = useUIStore(); const { isOpen } = useAIStore(); const { theme } = useThemeStore(); // Keyboard shortcut: ← → PgUp PgDown Space for page navigation useKeyboardNav(); const shellBg = SHELL_BG[theme] ?? SHELL_BG.dark; const menuBtn = MENU_BTN[theme] ?? MENU_BTN.dark; // ── Scroll Progress ──────────────────────────────────────── const [scrollProgress, setScrollProgress] = React.useState(0); useEffect(() => { const el = document.getElementById('reader-scroll-container'); if (!el) return; const handleScroll = () => { const total = el.scrollHeight - el.clientHeight; if (total <= 0) { setScrollProgress(0); return; } setScrollProgress((el.scrollTop / total) * 100); }; el.addEventListener('scroll', handleScroll); return () => el.removeEventListener('scroll', handleScroll); }, []); return (
{/* Left: NavDrawer */} {/* Centre: Reader — right-padded to clear RightToolbar (44px) on desktop */}
{/* Scroll Progress Bar */}
{/* Menu button — visible only when drawer is closed */} {!isNavOpen && ( )} {/* Scrollable reader — id is referenced by RightToolbar scroll-to-top */}
{/* Right: Reading controls toolbar */} {/* Mobile: bottom navigation bar (hidden on desktop) */} {/* AI Floating Menu */} {/* AI Popup */} {isOpen && ( )}
); }; export default AppShell;