'use client'; import { createContext, useContext, useMemo, useState, type ReactNode } from 'react'; type MobileChromeState = { title: string | null; primaryAction: ReactNode | null; showBackButton: boolean; }; type MobileChromeApi = MobileChromeState & { setChrome: (next: Partial) => void; }; const MobileChromeContext = createContext(null); export function MobileLayoutProvider({ children }: { children: ReactNode }) { const [state, setState] = useState({ title: null, primaryAction: null, showBackButton: false, }); const value = useMemo( () => ({ ...state, setChrome: (next) => setState((prev) => ({ ...prev, ...next })), }), [state], ); return {children}; } /** * Page-level hook to push a title / back-button / primary action into the * mobile topbar. The provider is only mounted by ``, so * desktop-shell renders never call into this context. */ export function useMobileChrome() { const ctx = useContext(MobileChromeContext); if (!ctx) { throw new Error('useMobileChrome must be used inside '); } return ctx; }