201 lines
7.1 KiB
TypeScript
201 lines
7.1 KiB
TypeScript
/* ============================================================
|
|
BOTTOM NAV — Luxsin X9 Controller (Mobile)
|
|
Design: iOS/Android App-style bottom tab bar
|
|
5 tabs — labels from locales/bottomNav, language = deviceState.language (同系统页)
|
|
- 社区:移动端进入 /community 引导复制链接;桌面(lg+)点击仍 window.open 论坛
|
|
- Active tab: cyan icon + top indicator bar
|
|
- Inactive: muted icon + label
|
|
============================================================ */
|
|
import { useDevice } from "@/contexts/DeviceContext";
|
|
import { cn } from "@/lib/utils";
|
|
import { readAndClearAiSplitRestorePath, useAIDrawer } from "@/contexts/AIDrawerContext";
|
|
import { useIsLgUp } from "@/hooks/useIsLgUp";
|
|
import localeZh from "@/locales/data-zh.json";
|
|
import localeEn from "@/locales/data-en.json";
|
|
import { resolveLocalePack } from "@/locales/resolveLocale";
|
|
import {
|
|
Activity,
|
|
Bot,
|
|
Home,
|
|
MessageSquare,
|
|
Sliders,
|
|
} from "lucide-react";
|
|
import { Link, useLocation } from "wouter";
|
|
import { useMemo } from "react";
|
|
import { bottomNavInnerClass, bottomNavOuterClass } from "@/lib/appShell";
|
|
|
|
type BottomNavLocale = NonNullable<(typeof localeZh)["bottomNav"]>;
|
|
|
|
interface NavItem {
|
|
path: string;
|
|
icon: React.ComponentType<{ size?: number; className?: string }>;
|
|
labelKey: keyof BottomNavLocale;
|
|
}
|
|
|
|
const FORUM_URL = "https://forum.zidoo.tv/index.php";
|
|
|
|
const NAV_ITEMS: NavItem[] = [
|
|
{ path: "/community", icon: MessageSquare, labelKey: "community" },
|
|
{ path: "/eq", icon: Sliders, labelKey: "hpEq" },
|
|
{ path: "/", icon: Home, labelKey: "home" },
|
|
{ path: "/effects", icon: Activity, labelKey: "effects" },
|
|
{ path: "/ai", icon: Bot, labelKey: "myAi" },
|
|
];
|
|
|
|
export default function BottomNav() {
|
|
const [location, setLocation] = useLocation();
|
|
const isLgUp = useIsLgUp();
|
|
const { open: aiDrawerOpen, setOpen: setAiDrawerOpen } = useAIDrawer();
|
|
const { deviceState } = useDevice();
|
|
|
|
const navText = useMemo((): BottomNavLocale => {
|
|
const pack = resolveLocalePack(deviceState?.language);
|
|
return (pack.bottomNav ?? localeEn.bottomNav) as BottomNavLocale;
|
|
}, [deviceState?.language]);
|
|
|
|
return (
|
|
<nav
|
|
className={bottomNavOuterClass}
|
|
>
|
|
<div
|
|
className={bottomNavInnerClass}
|
|
style={{
|
|
background: "rgba(10, 10, 12, 0.96)",
|
|
backdropFilter: "blur(40px) saturate(200%)",
|
|
WebkitBackdropFilter: "blur(40px) saturate(200%)",
|
|
borderTop: "0.5px solid rgba(255,255,255,0.1)",
|
|
boxShadow: "0 -1px 0 rgba(0,255,246,0.05)",
|
|
paddingBottom: "env(safe-area-inset-bottom, 8px)",
|
|
}}
|
|
>
|
|
<div className="flex items-stretch justify-around">
|
|
{NAV_ITEMS.map((item) => {
|
|
const isActive =
|
|
item.path === "/ai"
|
|
? location === "/ai" || (isLgUp && aiDrawerOpen)
|
|
: location === item.path ||
|
|
(item.path === "/" && location === "/") ||
|
|
(item.path !== "/" && location.startsWith(item.path));
|
|
const Icon = item.icon;
|
|
|
|
const inner = (
|
|
<div className="flex flex-col items-center justify-center relative pt-2.5 pb-1.5 px-3">
|
|
{/* Active indicator bar */}
|
|
<div
|
|
className="absolute top-0 left-1/2 -translate-x-1/2 rounded-b-full transition-all duration-300"
|
|
style={{
|
|
width: isActive ? 24 : 0,
|
|
height: 2.5,
|
|
background: "#00FFF6",
|
|
boxShadow: isActive ? "0 0 8px rgba(0,255,246,0.9)" : "none",
|
|
opacity: isActive ? 1 : 0,
|
|
transition: "width 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease",
|
|
}}
|
|
/>
|
|
|
|
{/* Icon */}
|
|
<div
|
|
className="flex items-center justify-center rounded-[12px] transition-all duration-200"
|
|
style={{
|
|
width: 38,
|
|
height: 32,
|
|
background: isActive ? "rgba(0,255,246,0.1)" : "transparent",
|
|
}}
|
|
>
|
|
<Icon
|
|
size={isActive ? 20 : 19}
|
|
className={cn(
|
|
"transition-all duration-200",
|
|
isActive ? "text-[#00FFF6]" : "text-white/30"
|
|
)}
|
|
/>
|
|
</div>
|
|
|
|
{/* Label */}
|
|
<span
|
|
className="mt-0.5 transition-all duration-200 leading-none"
|
|
style={{
|
|
fontFamily: "-apple-system, 'SF Pro Text', sans-serif",
|
|
fontSize: 10,
|
|
fontWeight: isActive ? 600 : 400,
|
|
color: isActive ? "#00FFF6" : "rgba(255,255,255,0.28)",
|
|
textShadow: isActive ? "0 0 8px rgba(0,255,246,0.5)" : "none",
|
|
}}
|
|
>
|
|
{navText[item.labelKey]}
|
|
</span>
|
|
</div>
|
|
);
|
|
|
|
if (item.path === "/community") {
|
|
if (isLgUp) {
|
|
return (
|
|
<button
|
|
key={item.path}
|
|
type="button"
|
|
className="cursor-pointer border-0 bg-transparent p-0 text-inherit outline-none focus-visible:ring-2 focus-visible:ring-[#00FFF6]/40 focus-visible:ring-offset-2 focus-visible:ring-offset-[rgba(10,10,12,0.96)]"
|
|
onClick={() => window.open(FORUM_URL, "_blank", "noopener,noreferrer")}
|
|
>
|
|
{inner}
|
|
</button>
|
|
);
|
|
}
|
|
return (
|
|
<Link key={item.path} href={item.path}>
|
|
{inner}
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
if (item.path === "/ai") {
|
|
if (!isLgUp) {
|
|
return (
|
|
<Link key={item.path} href={item.path}>
|
|
{inner}
|
|
</Link>
|
|
);
|
|
}
|
|
return (
|
|
<div
|
|
key={item.path}
|
|
role="button"
|
|
tabIndex={0}
|
|
className="cursor-pointer select-none"
|
|
onClick={() => {
|
|
if (location === "/ai") {
|
|
const path = readAndClearAiSplitRestorePath();
|
|
setLocation(path);
|
|
setAiDrawerOpen(true);
|
|
return;
|
|
}
|
|
setAiDrawerOpen((o) => !o);
|
|
}}
|
|
onKeyDown={(e) => {
|
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
e.preventDefault();
|
|
if (location === "/ai") {
|
|
const path = readAndClearAiSplitRestorePath();
|
|
setLocation(path);
|
|
setAiDrawerOpen(true);
|
|
return;
|
|
}
|
|
setAiDrawerOpen((o) => !o);
|
|
}}
|
|
>
|
|
{inner}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Link key={item.path} href={item.path}>
|
|
{inner}
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
);
|
|
}
|