- New InstallSheet mounted in the root layout: appears ~1s after load on iOS/Android phones and tablets, over any screen including the key gate, with a dimmed backdrop. Never on desktop, never in standalone mode, and at most once per 7 days after a dismissal (localStorage). - Platform/browser detection (lib/install.ts): iPhone/iPad incl. iPadOS reporting as Mac with touch, Android, Safari vs Chrome vs other vs in-app browsers, with step 1 adapted accordingly. - iOS: numbered steps with chips (Safari, Share, ... , More, Add to Home Screen) and the accent Add pill. Android: captured beforeinstallprompt turns into a native Install button; fallback steps use Install app / Add to Home screen chips and an accent Install pill. - Close via X, backdrop, Escape or swipe-down on the handle; the site is untouched afterwards. Anchored to 100dvh so browser toolbars never hide the last step; pb-safe respects the home indicator. - Dark sheet by default; light only when the app theme was explicitly set to light. Settings gains a mobile-only Install app row that reopens it. - The inline head script captures beforeinstallprompt before hydration and records appinstalled. Old InstallHint banner removed. - Tests: new install-sheet suite (45 checks across iPhone Safari/Chrome/ in-app, Android Chrome/Samsung, desktop, prompt path, dismissal, 7-day expiry, standalone, Settings row, both themes); pwa suite updated.
79 lines
2.9 KiB
TypeScript
79 lines
2.9 KiB
TypeScript
import type { Metadata, Viewport } from "next";
|
|
|
|
import { InstallSheet } from "@/components/InstallSheet";
|
|
import { ServiceWorkerRegistrar } from "@/components/ServiceWorkerRegistrar";
|
|
import "./globals.css";
|
|
|
|
export const metadata: Metadata = {
|
|
title: {
|
|
default: "Freezmo — turn your notes into a study feed",
|
|
template: "%s · Freezmo",
|
|
},
|
|
description:
|
|
"Freezmo turns photos and documents of your notes into a swipeable feed of short interactive study activities, powered by your own Ollama models.",
|
|
applicationName: "Freezmo",
|
|
manifest: "/manifest.webmanifest",
|
|
appleWebApp: {
|
|
capable: true,
|
|
title: "Freezmo",
|
|
statusBarStyle: "default",
|
|
},
|
|
icons: {
|
|
icon: [
|
|
{ url: "/icons/favicon-32.png", sizes: "32x32", type: "image/png" },
|
|
{ url: "/icons/icon-192.png", sizes: "192x192", type: "image/png" },
|
|
{ url: "/icons/icon-512.png", sizes: "512x512", type: "image/png" },
|
|
],
|
|
apple: [
|
|
{ url: "/icons/apple-touch-icon.png", sizes: "180x180" },
|
|
{ url: "/icons/apple-touch-icon-167.png", sizes: "167x167" },
|
|
{ url: "/icons/apple-touch-icon-152.png", sizes: "152x152" },
|
|
],
|
|
},
|
|
other: {
|
|
// iOS standalone niceties
|
|
"apple-mobile-web-app-capable": "yes",
|
|
"mobile-web-app-capable": "yes",
|
|
"format-detection": "telephone=no",
|
|
},
|
|
};
|
|
|
|
export const viewport: Viewport = {
|
|
width: "device-width",
|
|
initialScale: 1,
|
|
maximumScale: 5,
|
|
viewportFit: "cover",
|
|
themeColor: [
|
|
{ media: "(prefers-color-scheme: light)", color: "#f8fafc" },
|
|
{ media: "(prefers-color-scheme: dark)", color: "#0a0f13" },
|
|
],
|
|
};
|
|
|
|
/** Applies the saved theme before paint to avoid a flash. */
|
|
const themeScript = `(function(){try{var s=localStorage.getItem('freezmo.theme');var d=s?s==='dark':window.matchMedia('(prefers-color-scheme: dark)').matches;if(d)document.documentElement.classList.add('dark');}catch(e){}})();`;
|
|
|
|
/**
|
|
* Captures Chrome's `beforeinstallprompt` (it can fire before React hydrates)
|
|
* and records an install so the prompt never comes back. Static, no user data.
|
|
*/
|
|
const installScript = `(function(){try{
|
|
window.addEventListener('beforeinstallprompt',function(e){e.preventDefault();window.__freezmoInstallPrompt=e;window.dispatchEvent(new Event('freezmo:installprompt'));});
|
|
window.addEventListener('appinstalled',function(){try{localStorage.setItem('freezmo.install.installed','1')}catch(e){}window.dispatchEvent(new Event('freezmo:installed'));});
|
|
}catch(e){}})();`;
|
|
|
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<html lang="en" suppressHydrationWarning>
|
|
<head>
|
|
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
|
<script dangerouslySetInnerHTML={{ __html: installScript }} />
|
|
</head>
|
|
<body className="min-h-full antialiased">
|
|
<div className="app-backdrop" aria-hidden />
|
|
{children}
|
|
<InstallSheet />
|
|
<ServiceWorkerRegistrar />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|