Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

iPhone: the status bar follows the theme and turns black in full screen

Gabriele Lozuponecb53d6452864
diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest
index 1074cec..8f29dd6 100644
--- a/public/manifest.webmanifest
+++ b/public/manifest.webmanifest
@@ -6,7 +6,6 @@
"scope": "/",
"display": "standalone",
"background_color": "#f4f4f4",
- "theme_color": "#f4f4f4",
"icons": [
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
diff --git a/public/theme.js b/public/theme.js
index 9444a6a..694df0f 100644
--- a/public/theme.js
+++ b/public/theme.js
@@ -13,8 +13,10 @@
} catch (e) {}
var theme = t === "light" || t === "dark" ? t : dark.matches ? "dark" : "light";
document.documentElement.dataset.theme = theme;
- // The status bar of a phone (Kokon added to the home screen) in the page's own ground colour
- // (styles.css --ground), not the manifest's light one.
+ // The status bar in the page's own ground colour (styles.css --ground): Android's Chrome and iOS
+ // before 26 read these tags. iOS 26+ ignores them and takes the colour of the page at the top
+ // (a fixed element there, else the body), which is why manifest.webmanifest has no theme_color:
+ // a home-screen app would keep that fixed colour (WebKit bug 317153).
var ground = theme === "dark" ? (document.documentElement.dataset.platform === "mac" ? "#161616" : "#0a0a0a") : "#f4f4f4";
// Replaced, not edited: iOS (a home-screen app) seems to read a new tag but not a changed one.
document.querySelectorAll('meta[name="theme-color"]').forEach(function (m) {
diff --git a/src/components/PhoneApp.tsx b/src/components/PhoneApp.tsx
index 929465e..0f69af0 100644
--- a/src/components/PhoneApp.tsx
+++ b/src/components/PhoneApp.tsx
@@ -3,6 +3,7 @@
// sheets from the bottom); App.tsx shows it on screens up to 720 px wide (platform.ts isNarrow).
import { PhotoReview } from "./PhotoReview";
+import { StatusTint } from "./StatusTint";
import { Check, ChevronLeft, EyeOff, Plus, Settings, SquarePen, Trash2, X } from "lucide-react";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { createPortal } from "react-dom";
@@ -67,6 +68,7 @@ export function PhoneApp() {
{overlay === "inpaint" && <InpaintEditor />}
{overlay === "expand" && <ExpandEditor />}
<PhotoReview />
+ <StatusTint />
</div>
);
}
diff --git a/src/components/StatusTint.tsx b/src/components/StatusTint.tsx
new file mode 100644
index 0000000..51ba596
--- /dev/null
+++ b/src/components/StatusTint.tsx
@@ -0,0 +1,30 @@
+// The status bar colour on iOS 26+ (see StatusTint).
+
+import { useEffect, useState } from "react";
+import { createPortal } from "react-dom";
+import { blackScreenOpen, onBlackScreens } from "../lib/theme";
+
+/** iOS 26+ ignores theme-color: Safari and home-screen apps colour the status bar from an opaque
+ * fixed element at the top of the page, read when the page loads. This strip is that element, in
+ * the page's ground colour (black while a black screen is open); it is created anew with its
+ * colour inline at every change (theme, system appearance, full screen), which makes iOS read
+ * it again without a reload (found by cole-titze/nhl-odds#101, tested on an iPhone). */
+export function StatusTint() {
+ const [color, setColor] = useState<string | null>(null);
+ useEffect(() => {
+ const read = () => setColor(blackScreenOpen() ? "#000" : getComputedStyle(document.body).backgroundColor);
+ read();
+ const off = onBlackScreens(read);
+ // data-theme changes with the Settings choice and with the system's (public/theme.js).
+ const mo = new MutationObserver(read);
+ mo.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
+ return () => {
+ off();
+ mo.disconnect();
+ };
+ }, []);
+ if (!color) return null;
+ // On the body, not in the layout: above the full-screen view (also a portal there), so that one
+ // turns the bar black too.
+ return createPortal(<div key={color} className="status-tint" aria-hidden style={{ backgroundColor: color }} />, document.body);
+}
diff --git a/src/lib/theme.ts b/src/lib/theme.ts
index 0f7b596..61ee375 100644
--- a/src/lib/theme.ts
+++ b/src/lib/theme.ts
@@ -41,15 +41,36 @@ export function setStatusBar(color: string | null) {
});
}
-/** `setStatusBar("#000")` while mounted (a browser only). */
+// Black screens open now (StatusTint shows black while there is one).
+let blackScreens = 0;
+const tintListeners = new Set<() => void>();
+const tintChanged = () => tintListeners.forEach((f) => f());
+
+/** The status bar black while mounted (a browser only): the theme-color tags (Android's Chrome,
+ * iOS before 26) and components/StatusTint (iOS 26+). */
export function useBlackStatusBar() {
useEffect(() => {
if (!inBrowser) return;
setStatusBar("#000");
- return () => setStatusBar(null);
+ blackScreens++;
+ tintChanged();
+ return () => {
+ blackScreens--;
+ tintChanged();
+ setStatusBar(null);
+ };
}, []);
}
+/** Calls `f` when a black screen opens or closes; returns the unsubscribe. */
+export function onBlackScreens(f: () => void): () => void {
+ tintListeners.add(f);
+ return () => tintListeners.delete(f);
+}
+
+/** A black screen (full screen, the photo views) is open. */
+export const blackScreenOpen = () => blackScreens > 0;
+
export function setThemeChoice(t: ThemeChoice) {
try {
if (t === "system") localStorage.removeItem(KEY);
diff --git a/src/phone.css b/src/phone.css
index de5523f..75e3f33 100644
--- a/src/phone.css
+++ b/src/phone.css
@@ -327,6 +327,9 @@ html.keyboard .composer-wrap.phone { padding-bottom: 8px; }
.hold-save-img > img:not(.develop-ph img) { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 18px; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.hold-save-img .develop-ph { inset: 8px 12px calc(env(safe-area-inset-bottom) + 16px); border-radius: 18px; background: #111; }
.hold-save-img .develop-ph img { object-fit: contain; }
+/* the element iOS 26+ colours the status bar from (StatusTint.tsx): opaque, at the top, over
+ everything. 6 px: a 1 px strip was not taken (iPhone 15, iOS 27, home-screen app and Safari) */
+.status-tint { position: fixed; top: 0; left: 0; right: 0; height: max(6px, env(safe-area-inset-top)); z-index: 400; pointer-events: none; }
/* a photo just taken, before it is uploaded (PhotoReview.tsx) */
.photo-review { position: fixed; inset: 0; z-index: 210; display: flex; flex-direction: column; background: #000; color: #fff; animation: fade 0.25s ease-out both; }
.photo-review-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 12px; }