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.

Phones: full screen with a black status bar, zoom bar clear of the view switch

Gabriele Lozuponed31e313637dc
diff --git a/src/components/PhoneStage.tsx b/src/components/PhoneStage.tsx
index db80138..64447af 100644
--- a/src/components/PhoneStage.tsx
+++ b/src/components/PhoneStage.tsx
@@ -2,6 +2,7 @@
// versions and tapped for full screen, and what you can do with it sits in one row under it.
// Stage.tsx uses these in place of its desktop bar.
+import { useBlackStatusBar } from "../lib/theme";
import { Brush, Copy, Download, Ellipsis, Expand, Heart, ImagePlus, Info, RefreshCw, SlidersHorizontal, TextCursorInput, Trash2, X } from "lucide-react";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { createPortal } from "react-dom";
@@ -181,6 +182,7 @@ async function saveImage(url: string, name: string, hold: () => void) {
/** The image to save, full screen and at full size: holding it brings the system's menu, whose
* Save to Photos puts it in Photos. */
function HoldToSave({ src, thumb, onClose }: { src: string; thumb?: string; onClose: () => void }) {
+ useBlackStatusBar();
useEffect(() => {
const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose();
window.addEventListener("keydown", onKey);
diff --git a/src/components/PhotoReview.tsx b/src/components/PhotoReview.tsx
index 8455525..17e1938 100644
--- a/src/components/PhotoReview.tsx
+++ b/src/components/PhotoReview.tsx
@@ -7,6 +7,7 @@ import { useEffect, useState, useSyncExternalStore } from "react";
import { createPortal } from "react-dom";
import { haptic } from "../lib/haptics";
import { isNarrow } from "../lib/platform";
+import { useBlackStatusBar } from "../lib/theme";
interface Pending {
file: File;
@@ -77,6 +78,11 @@ export function PhotoReview() {
setBusy(false);
}, [p]);
if (!p) return null;
+ return <Review p={p} flip={flip} setFlip={setFlip} busy={busy} setBusy={setBusy} />;
+}
+
+function Review({ p, flip, setFlip, busy, setBusy }: { p: Pending; flip: boolean; setFlip: (f: (v: boolean) => boolean) => void; busy: boolean; setBusy: (b: boolean) => void }) {
+ useBlackStatusBar();
const use = async () => {
setBusy(true);
try {
diff --git a/src/components/Viewer.tsx b/src/components/Viewer.tsx
index fb3af93..6b68bd3 100644
--- a/src/components/Viewer.tsx
+++ b/src/components/Viewer.tsx
@@ -8,6 +8,7 @@ import { urls } from "../lib/api";
import { haptic } from "../lib/haptics";
import { native } from "../lib/native";
import { inBrowser } from "../lib/platform";
+import { useBlackStatusBar } from "../lib/theme";
import { ZoomPan } from "./ZoomPan";
export const isTyping = (t: EventTarget | null) => t instanceof HTMLElement && (t.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(t.tagName));
@@ -185,6 +186,7 @@ export function navKey(e: KeyboardEvent, nav: ViewerNav | undefined): boolean {
function FullscreenShell({ children, hint, onClose, nav }: { children: ReactNode; hint?: string; onClose: () => void; nav?: ViewerNav }) {
const [active, wake] = useMouseActive();
+ useBlackStatusBar();
// Real full screen for the window while open; restored on close unless it already was.
useEffect(() => {
let wasFull = false;
diff --git a/src/lib/theme.ts b/src/lib/theme.ts
index 489da6f..0f7b596 100644
--- a/src/lib/theme.ts
+++ b/src/lib/theme.ts
@@ -1,6 +1,8 @@
// Light / dark appearance. public/theme.js resolves the choice into data-theme on <html> before
// the first paint; this module stores the choice and keeps the native title bar in step.
+import { useEffect } from "react";
import { native } from "./native";
+import { inBrowser } from "./platform";
export type ThemeChoice = "system" | "light" | "dark";
@@ -21,6 +23,33 @@ export function syncWindowTheme(t: ThemeChoice = themeChoice()) {
native.setTheme(t === "system" ? null : t).catch(() => {});
}
+/** A phone's status bar (the theme-color tags, public/theme.js) in `color` while a black screen
+ * is open (full screen, the photo views); null gives it back to the theme. Tags are replaced,
+ * not edited, as theme.js does (iOS seems to read a new tag but not a changed one). */
+export function setStatusBar(color: string | null) {
+ if (color === null) {
+ window.dispatchEvent(new Event("qls-theme"));
+ return;
+ }
+ document.querySelectorAll('meta[name="theme-color"]').forEach((m) => {
+ const fresh = document.createElement("meta");
+ fresh.name = "theme-color";
+ fresh.content = color;
+ const media = m.getAttribute("media");
+ if (media) fresh.setAttribute("media", media);
+ m.replaceWith(fresh);
+ });
+}
+
+/** `setStatusBar("#000")` while mounted (a browser only). */
+export function useBlackStatusBar() {
+ useEffect(() => {
+ if (!inBrowser) return;
+ setStatusBar("#000");
+ return () => setStatusBar(null);
+ }, []);
+}
+
export function setThemeChoice(t: ThemeChoice) {
try {
if (t === "system") localStorage.removeItem(KEY);
diff --git a/src/phone.css b/src/phone.css
index c5e42b2..de5523f 100644
--- a/src/phone.css
+++ b/src/phone.css
@@ -369,6 +369,11 @@ html.keyboard .composer-wrap.phone { padding-bottom: 8px; }
.viewer-close { width: 44px; height: 44px; border-radius: 50%; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.viewer-tag { border-radius: 12px; padding: 5px 10px; }
.viewer-compare-bar { bottom: calc(14px + env(safe-area-inset-bottom)); }
+ /* zoom buttons above the home indicator, and above the view switch when there is one; the
+ mini-map top left, clear of both (the close button is top right) */
+ .viewer .zoom-controls { bottom: calc(14px + env(safe-area-inset-bottom)); }
+ .viewer:has(.viewer-compare-bar) .zoom-controls { bottom: calc(66px + env(safe-area-inset-bottom)); }
+ .viewer .zoom-minimap { top: calc(env(safe-area-inset-top) + 12px); left: 12px; right: auto; bottom: auto; }
.viewer .zoom-controls { border-radius: 18px; }
.viewer-compare-bar .compare-bar { border-radius: 18px; }
.viewer-compare-bar .seg button { padding: 0 12px; }
diff --git a/src/styles.css b/src/styles.css
index e116e5f..77a2fde 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -681,6 +681,10 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font
.swipe-nav-page.enter-left { animation: page-left 0.46s var(--ease) both; }
.viewer-compare-bar { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; }
.viewer-compare-bar .compare-bar { margin: 0; padding: 4px; border-radius: 12px; background: rgba(20, 20, 20, 0.85); }
+/* the viewer is black in both themes: the switch too (the theme's light segments glared) */
+.viewer-compare-bar .seg { background: transparent; }
+.viewer-compare-bar .seg button { color: rgba(255, 255, 255, 0.7); }
+.viewer-compare-bar .seg button.on { color: #fff; background: rgba(255, 255, 255, 0.2); box-shadow: none; }
/* full screen is viewed from further away: larger view switch and zoom bar */
.viewer-compare-bar .seg button { height: 34px; padding: 0 16px; font-size: 13px; }
.viewer .zoom-btn { height: 36px; min-width: 36px; }