"use client"; import { Activity, Bell, Dumbbell, Home, Lightbulb, MoreHorizontal, Pill, Plus, Settings, Trophy, Waves, } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useState } from "react"; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "@/components/ui/sheet"; import { CapturePicker } from "@/components/layout/capture-picker"; import { cn } from "@/lib/utils"; import { useTranslations } from "@/lib/i18n/context"; interface NavLink { href: string; tKey: string; icon: typeof Home; } // v1.12.x — iOS-parity bottom bar (additive middle-path). // // The mobile bar is a 5-slot shape: Home · Meds · Log(center) · // Insights · More — mirroring the native client. The center slot is a // capture ACTION (not a destination): it opens a picker that routes to // the existing measurement / medication / mood quick-entry surfaces // (see ``). // // PRIMARY_LEFT / PRIMARY_RIGHT are the two anchor pairs that flank the // center action. The previous strip (Home · Measurements · Mood · // Medications · Insights) carried Measurements and Mood inline; those // stay fully reachable — through the center capture picker AND the More // hub below — so nothing is orphaned. On desktop the sidebar still // lists every destination. const PRIMARY_LEFT: ReadonlyArray = [ { href: "/", tKey: "nav.dashboard", icon: Home }, { href: "/medications", tKey: "nav.medications", icon: Pill }, ]; const PRIMARY_RIGHT: ReadonlyArray = [ { href: "/insights", tKey: "nav.insights", icon: Lightbulb }, ]; // The "More" hub — a real hub of the remaining top-level destinations, // not just an overflow bucket. Measurements and Mood live here (they // left the always-visible strip when the center capture action took the // middle slot), alongside Workouts, Achievements, Notifications and // Settings. Every entry is an existing top-level route. const MORE_HUB: ReadonlyArray = [ { href: "/measurements", tKey: "nav.measurements", icon: Activity }, { href: "/mood", tKey: "nav.mood", icon: Waves }, { href: "/insights/workouts", tKey: "nav.workouts", icon: Dumbbell }, { href: "/achievements", tKey: "nav.achievements", icon: Trophy }, { href: "/notifications", tKey: "nav.notifications", icon: Bell }, { href: "/settings/account", tKey: "nav.settings", icon: Settings }, ]; export function BottomNav() { const pathname = usePathname(); const { t } = useTranslations(); const [moreOpen, setMoreOpen] = useState(false); const [captureOpen, setCaptureOpen] = useState(false); function isActiveLink(href: string) { return href === "/" ? pathname === "/" : pathname.startsWith(href); } // The "More" entry is treated as active when any of its children // is the current page — gives the user a clue that they've drilled // into a sub-route via the hub. const moreActive = MORE_HUB.some((item) => isActiveLink(item.href)); function renderPrimary(item: NavLink) { const isActive = isActiveLink(item.href); return ( {isActive && ( )} ); } return ( <> {/* v1.4.33 F14 — bar height and safe-area defence so the bar can never overlap the last viewport line of scrollable page content. `min-h-16` floors the bar at 64px; `pb-[env(safe-area-inset-bottom)]` reserves the home-indicator inset on iOS / iPadOS PWA installs; `bg-card` + `border-t` give the bar a clean visual edge so page content that scrolls under the bar is occluded, not bleeding through. */} {t("nav.moreSheetTitle")} {t("nav.moreSheetDescription")}
{MORE_HUB.map((item) => { const isActive = isActiveLink(item.href); return ( setMoreOpen(false)} aria-current={isActive ? "page" : undefined} // v1.12 — `min-h-14` matches the capture-picker tiles so // the equivalent tappable rows share one height at this // tier (and the larger row is a more comfortable target). className={cn( "border-border flex min-h-14 items-center gap-3 rounded-lg border px-4 py-3 transition-colors", isActive ? "text-primary bg-primary/5" : "text-foreground hover:bg-accent/40", )} >
); }