Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Photos: full screen is the photo alone; stepping back to full frame rate

Yashwanth Kamireddibe850df3b345
diff --git a/.uiverify/photos-fullscreen.mjs b/.uiverify/photos-fullscreen.mjs
index 7f24db5..4cf6b7b 100644
--- a/.uiverify/photos-fullscreen.mjs
+++ b/.uiverify/photos-fullscreen.mjs
@@ -24,9 +24,47 @@ ok(/3 of 5/.test(await page.locator(".px-viewer-when").innerText()), "and it fol
await page.getByRole("button", { name: "Enter Full Screen" }).click();
await page.waitForTimeout(150);
ok(JSON.stringify(await asked()) === "[true]" && (await page.getByRole("button", { name: "Exit Full Screen" }).count()) === 1, "the button takes the window full screen, and becomes Exit");
+// Full screen is the photo alone, as icloud.com's: the viewer covers the whole window, black,
+// no sidebar showing; the photo uses the whole height.
+const box = await page.locator(".px-viewer").boundingBox();
+ok(box.x === 0 && box.y === 0 && box.width === 1280 && box.height === 800, `the viewer covers the whole window (${JSON.stringify(box)})`);
+const hit = await page.evaluate(() => [document.elementFromPoint(100, 400)?.closest(".px-viewer") !== null, getComputedStyle(document.querySelector(".px-backdrop")).backgroundColor]);
+ok(hit[0] && hit[1] === "rgb(0, 0, 0)", `nothing of the app beside it, on black (${hit[1]})`);
+const stage = await page.locator(".px-stage").boundingBox();
+ok(stage.height === 800 && stage.width === 1280, `the photo has the whole screen (${stage.width}×${stage.height})`);
+ok((await page.locator(".px-strip").count()) === 0, "no thumbnails until asked for");
+// Its bar goes out of sight, and comes back when the pointer goes to the top.
+await page.mouse.move(640, 400);
+await page.waitForTimeout(2000);
+ok(!(await page.locator(".px-full-bar").isVisible()), "the bar goes out of sight");
+await page.mouse.move(640, 10);
+await page.waitForTimeout(200);
+ok(await page.locator(".px-full-bar").isVisible(), "and comes up when the pointer reaches the top");
+ok(/3 of 5/.test(await page.locator(".px-full-bar .px-viewer-when").innerText()), "with the date and where it is among them");
+// The thumbnails button shows the photos along the bottom; the photo fits above them.
+await page.getByRole("button", { name: "Show Thumbnails" }).click();
+await page.waitForTimeout(200);
+const strip = await page.locator(".px-strip").boundingBox();
+const stage2 = await page.locator(".px-stage").boundingBox();
+ok(strip && strip.y + strip.height === 800 && stage2.y + stage2.height <= strip.y + 1, `Show Thumbnails puts them along the bottom, the photo above (strip ${JSON.stringify(strip)})`);
+await page.getByRole("button", { name: "Hide Thumbnails" }).click();
+await page.waitForTimeout(150);
+ok((await page.locator(".px-strip").count()) === 0, "and Hide Thumbnails takes them away");
+// The slider zooms the photo (a photo, not the video this one is) about its middle; − and + step it.
+await page.keyboard.press("ArrowRight");
+await page.waitForTimeout(300);
+await page.mouse.move(640, 10);
+await page.waitForTimeout(150);
+await page.locator(".px-full-bar").getByRole("button", { name: "Zoom In" }).click();
+await page.waitForTimeout(400);
+const k = await page.locator(".px-zoom input").inputValue();
+ok(Number(k) > 1.4 && /scale/.test(await page.locator(".px-pan").evaluate((e) => e.style.transform)), `Zoom In zooms the photo, the slider following (${k})`);
+await page.locator(".px-zoom input").fill("1");
+await page.waitForTimeout(200);
+ok(!/scale\(/.test(await page.locator(".px-pan").evaluate((e) => e.style.transform)), "and the slider back at its start fits it again");
await page.keyboard.press("Escape");
await page.waitForTimeout(150);
-ok(JSON.stringify(await asked()) === "[true,false]" && (await page.locator(".px-viewer").count()) === 1, "Escape leaves full screen first, the photo still open");
+ok(JSON.stringify(await asked()) === "[true,false]" && (await page.locator(".px-viewer").count()) === 1 && (await page.locator(".px-viewer-bar").count()) === 1, "Escape leaves full screen first, the photo still open with its own bar");
await page.keyboard.press("Escape");
await page.waitForTimeout(150);
ok((await page.locator(".px-viewer").count()) === 0, "and Escape again closes the photo");
@@ -34,8 +72,8 @@ await page.locator(".px-tile").nth(0).dblclick();
await page.waitForTimeout(300);
await page.getByRole("button", { name: "Enter Full Screen" }).click();
await page.waitForTimeout(100);
-await page.getByRole("button", { name: "Close" }).click();
+await page.keyboard.press("Control+.");
await page.waitForTimeout(200);
-ok((await asked()).at(-1) === false, "closing a photo leaves full screen too");
+ok((await asked()).at(-1) === false && (await page.locator(".px-viewer").count()) === 0, "closing a photo leaves full screen too");
await b.close();
process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/.uiverify/photos-strip.mjs b/.uiverify/photos-strip.mjs
index b2efe10..7fb2b42 100644
--- a/.uiverify/photos-strip.mjs
+++ b/.uiverify/photos-strip.mjs
@@ -11,7 +11,18 @@ await ctx.addInitScript(() => {
filename: `IMG_${id}.JPG`, size: 1, uti: "public.jpeg", favorite: false, hidden: false, deleted: false, deletedAt: null, subtype: 0, changeTag: null });
window.__photos = Array.from({ length: 2000 }, (_, i) => P(`q${i}`, 1792600000 - i * 40000));
});
+await ctx.addInitScript(() => { window.__picBase = "http://pics.test"; });
const page = await ctx.newPage();
+// Real pictures throughout, each a different colour, the screen-sized ones slow to come (as a
+// photo not yet made at that size is), so a step has to wait for its picture.
+await page.route("http://pics.test/**", async (route) => {
+ const path = decodeURIComponent(route.request().url().split("/").pop());
+ const n = Number(/q(\d+)/.exec(path)?.[1] ?? 0);
+ if (/fit(\d+)/.test(path) && Number(/fit(\d+)/.exec(path)[1]) > 256) await new Promise((r) => setTimeout(r, 700));
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1200"><rect width="1600" height="1200" fill="hsl(${(n * 47) % 360} 60% 50%)"/></svg>`;
+ await route.fulfill({ status: 200, contentType: "image/svg+xml", body: svg });
+});
+
page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
await openScreen(page, "Photos");
@@ -54,5 +65,29 @@ ok(await page.evaluate(() => [...document.querySelectorAll(".px-slip, .px-strip-
}) && document.getAnimations().filter((a) => a.playState === "running").length === 0),
"the strip and its slips move at once — nothing in it animates (animated, it flickered)");
ok((await page.locator(".px-slip img[loading=lazy]").count()) === 0, "and every slip's picture is fetched at once, never lazily");
+// Stepping fast, frame by frame: every frame has a picture on the stage — the new one decoded,
+// or the last one painted held under it — and a step never shows the soft thumbnail.
+const seen = await page.evaluate(async () => {
+ const bad = [];
+ let frames = 0, held = 0;
+ const look = () => {
+ frames++;
+ const top = document.querySelector(".px-pan > .px-shown");
+ const under = document.querySelector(".px-stage > .px-under");
+ const underOn = under && under.style.visibility !== "hidden";
+ if (underOn) held++;
+ if (underOn && getComputedStyle(top).backgroundImage !== "none") bad.push("thumbnail under a step");
+ if (!underOn && !(top.complete && top.naturalWidth > 0) && getComputedStyle(top).backgroundImage === "none") bad.push("nothing on the stage");
+ };
+ for (let i = 0; i < 12; i++) {
+ window.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }));
+ for (let f = 0; f < 4; f++) { await new Promise((r) => requestAnimationFrame(r)); look(); }
+ }
+ await new Promise((r) => setTimeout(r, 600));
+ const under = document.querySelector(".px-stage > .px-under");
+ return { bad: [...new Set(bad)], frames, held, left: !!under && under.style.visibility !== "hidden" };
+});
+ok(seen.bad.length === 0 && seen.held > 0, `stepping, every frame has a picture and never the thumbnail (${seen.frames} frames, ${seen.held} holding the last; ${seen.bad.join(", ")})`);
+ok(!seen.left, "and once the new picture is decoded, the one held under it is gone");
await b.close();
process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index e1094a9..9a1ea61 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -133,7 +133,9 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
window.__TAURI_INTERNALS__ = {
transformCallback: (cb) => cb,
// As Tauri builds it on Linux (tauri/scripts/core.js): the whole path escaped.
- convertFileSrc: (path, protocol = "asset") => `${protocol}://localhost/${encodeURIComponent(path)}`,
+ // A test that needs real pictures sets __picBase and serves them there (page.route).
+ convertFileSrc: (path, protocol = "asset") =>
+ window.__picBase ? `${window.__picBase}/${encodeURIComponent(path)}` : `${protocol}://localhost/${encodeURIComponent(path)}`,
invoke: async (cmd, args) => {
switch (cmd) {
case "auth_status":
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index 43945b0..9d52afa 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -7,7 +7,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useStat
import { listen } from "@tauri-apps/api/event";
import { getCurrentWebview } from "@tauri-apps/api/webview";
import { open as openFileDialog } from "@tauri-apps/plugin-dialog";
-import { ChevronLeft, ChevronRight, CopyMinus, CopyPlus, Download, Clock, Heart, ImagePlus, Images, Info, Minus, Play, Plus, RotateCcw, Scan, Trash2, EyeOff, ArrowDownUp, MonitorPlay, Square, RectangleHorizontal, Star, Layers, Search as SearchIcon, Folder as FolderIcon, Aperture, Video, X, CalendarDays, Maximize2, Minimize2, Users, type LucideIcon } from "lucide-react";
+import { ChevronLeft, ChevronRight, Ellipsis, GalleryThumbnails, CopyMinus, CopyPlus, Download, Clock, Heart, ImagePlus, Images, Info, Minus, Play, Plus, RotateCcw, Scan, Trash2, EyeOff, ArrowDownUp, MonitorPlay, Square, RectangleHorizontal, Star, Layers, Search as SearchIcon, Folder as FolderIcon, Aperture, Video, X, CalendarDays, Maximize2, Minimize2, Users, type LucideIcon } from "lucide-react";
import {
api,
messageOf,
@@ -159,7 +159,7 @@ function Filmstrip({ photos, at, onPick }: { photos: Photo[]; at: number; onPick
{/* At once, never lazily: a slip coming into the strip showed empty for a moment. */}
{/* One size for every slip, shown or not, so a step never asks for a new picture; decoded
before it is drawn (they are small), so none appears blank first. */}
- <img src={fitSrc(p.id, SHOWN * 2 * (window.devicePixelRatio || 1))} alt="" decoding="sync" draggable={false} />
+ <img src={fitSrc(p.id, SHOWN * 2 * (window.devicePixelRatio || 1))} alt="" decoding="async" draggable={false} />
</button>,
);
}
@@ -582,24 +582,35 @@ export function PhotosView() {
const shown = open !== null ? photos?.[open] ?? null : null;
/**
- * The photo whose picture is on the stage. A step changes `shown` at once (its date, its
- * place, its info) but the picture changes only once the next one is decoded — at once when
- * it already is, as the photos either side are made to be — so a step never shows a blank or
- * the soft thumbnail before the sharp picture: the flicker on every switch.
+ * The picture last painted on the stage, kept beneath the next one until that one is decoded:
+ * a step never shows a blank, nor the soft thumbnail before the sharp picture (the flicker on
+ * every switch). The next is decoded where it stands, by the engine, as it would be anyway —
+ * holding the step back until a copy off the page was decoded cost a fifth of its frames.
*/
- const [pictured, setPictured] = useState<Photo | null>(null);
- useLayoutEffect(() => {
- if (!shown) return setPictured(null);
- if (shown.kind === "video" || decoded.has(viewSrc(shown))) return setPictured(shown);
- let live = true;
- const take = () => live && setPictured(shown);
- void warm(shown).then(take);
- const t = window.setTimeout(take, 250);
- return () => {
- live = false;
- window.clearTimeout(t);
- };
- }, [shown?.id]); // eslint-disable-line react-hooks/exhaustive-deps
+ // The viewer's date, time and place among the photos, as its bar shows them.
+ const when = shown && (
+ <div className="px-viewer-when">
+ <strong>{new Date(shown.takenAt * 1000).toLocaleDateString(undefined, { dateStyle: "long" })}</strong>
+ {view === "recentlyDeleted" && !album && timeLeft(shown, false) ? (
+ <span className={timeLeft(shown, false)!.soon ? "is-soon" : undefined}>{timeLeft(shown, false)!.words}</span>
+ ) : (
+ <span>
+ {new Date(shown.takenAt * 1000).toLocaleTimeString(undefined, { timeStyle: "short" })}
+ {/* Where it is among them, as icloud.com says it: "133 of 169". */}
+ {photos && photos.length > 1 && open !== null && !inBurst && (
+ <span className="px-viewer-place">
+ {" · "}
+ {(open + 1).toLocaleString()} of {photos.length.toLocaleString()}
+ </span>
+ )}
+ </span>
+ )}
+ </div>
+ );
+ const painted = useRef<Photo | null>(null);
+ const underEl = useRef<HTMLImageElement | null>(null);
+ const under = shown && shown.kind !== "video" && painted.current && painted.current.id !== shown.id && painted.current.kind !== "video" && !decoded.has(viewSrc(shown)) ? painted.current : null;
+ if (!shown || shown.kind === "video") painted.current = null;
// The viewer follows the photo, not its place: when the list moves under it — its date
// changed, a sync reordered the library — it finds the photo again rather than showing
// whichever came to stand where it was.
@@ -760,6 +771,7 @@ export function PhotosView() {
drawn_.current = l;
const el = pan.current;
if (el) el.style.transform = l.k > 1 || l.x || l.y ? `translate(${l.x}px, ${l.y}px) scale(${l.k})` : "";
+ if (zoomSlider.current && zoomSlider.current !== document.activeElement) zoomSlider.current.value = String(l.k);
};
const paint = (next: { k: number; x: number; y: number }, glide = false) => {
lensRef.current = next;
@@ -855,6 +867,54 @@ export function PhotosView() {
useEffect(() => {
if (open === null && fullscreen) void toggleFullscreen(false);
}, [open === null]); // eslint-disable-line react-hooks/exhaustive-deps
+ /**
+ * Full screen is the photo alone, as icloud.com's: black to every edge, its bar out of sight
+ * until the pointer goes to the top (or a key's focus lands in it), the thumbnails along the
+ * bottom only when asked for — remembered for next time.
+ */
+ const [thumbs, setThumbs] = useState(() => {
+ try {
+ return localStorage.getItem("quince.photos.fullThumbs") === "1";
+ } catch {
+ return false;
+ }
+ });
+ const toggleThumbs = () =>
+ setThumbs((v) => {
+ try {
+ localStorage.setItem("quince.photos.fullThumbs", v ? "0" : "1");
+ } catch {
+ /* a convenience only */
+ }
+ return !v;
+ });
+ const [barUp, setBarUp] = useState(true);
+ const barTimer = useRef<number | undefined>(undefined);
+ const fullBar = useRef<HTMLElement | null>(null);
+ // Shown as full screen begins, then away after a moment unless the pointer is on it.
+ const barAway = (after = 1600) => {
+ window.clearTimeout(barTimer.current);
+ barTimer.current = window.setTimeout(() => {
+ if (fullBar.current?.matches(":hover") || fullBar.current?.querySelector(":focus-visible")) return;
+ setBarUp(false);
+ }, after);
+ };
+ useEffect(() => {
+ if (!fullscreen) return window.clearTimeout(barTimer.current);
+ setBarUp(true);
+ barAway();
+ return () => window.clearTimeout(barTimer.current);
+ }, [fullscreen]); // eslint-disable-line react-hooks/exhaustive-deps
+ // It comes back with a page-drawn fade, never the compositor's (see lib/fade).
+ useLayoutEffect(() => {
+ if (fullscreen && barUp) fadeIn(fullBar.current, { duration: 120 });
+ }, [barUp, fullscreen]);
+ const zoomSlider = useRef<HTMLInputElement | null>(null);
+ /** Zoom about the stage's middle, as the bar's slider and its − and + do. */
+ const zoomMiddle = (k: number, glide = true) => {
+ const box = stage.current?.getBoundingClientRect();
+ if (box) zoomAt(k, box.left + box.width / 2, box.top + box.height / 2, glide);
+ };
/** A Live Photo's moving part playing over it. */
const [moving, setMoving] = useState<string | null>(null);
useEffect(() => setMoving(null), [shown?.id]);
@@ -907,13 +967,18 @@ export function PhotosView() {
h: el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom),
};
if (shown && shown.kind !== "video") setStep(viewSrc(shown));
- // Where the photo itself sits on the stage, for the marks laid on its corner (LIVE,
- // BURST): read a frame later, once the picture has its box.
+ // Where the photo itself sits on the stage, for the LIVE mark laid on its corner: read a
+ // frame later, once the picture has its box. Only for a Live Photo, and written only when
+ // it moved — read and set on every step, it restyled the whole stage each time and cost
+ // the stepping a fifth of its frames.
+ if (shown?.kind !== "live") return;
requestAnimationFrame(() => {
- const p = el.querySelector<HTMLElement>(".px-pan, .px-video");
+ const p = el.querySelector<HTMLElement>(".px-pan");
if (!p) return;
- el.style.setProperty("--photo-x", `${p.offsetLeft}px`);
- el.style.setProperty("--photo-y", `${p.offsetTop}px`);
+ const x = `${p.offsetLeft}px`;
+ const y = `${p.offsetTop}px`;
+ if (el.style.getPropertyValue("--photo-x") !== x) el.style.setProperty("--photo-x", x);
+ if (el.style.getPropertyValue("--photo-y") !== y) el.style.setProperty("--photo-y", y);
});
};
measure();
@@ -951,7 +1016,9 @@ export function PhotosView() {
const current = photos?.[open] ?? null;
const onKey = (e: KeyboardEvent) => {
// Keys typed into a field — the caption — are words, not commands.
- if ((e.target as HTMLElement | null)?.closest?.("input, textarea, [contenteditable]")) return;
+ if ((e.target as HTMLElement | null)?.closest?.("input:not([type=range]), textarea, [contenteditable]")) return;
+ // The zoom slider's own arrows move it; every other key still works with it focused.
+ if ((e.target as HTMLElement | null)?.matches?.("input[type=range]") && e.key.startsWith("Arrow")) return;
if (e.key === "ArrowRight") step(1);
else if (e.key === "ArrowLeft") step(-1);
else if (e.key === "Escape" && lensRef.current.k > 1) unzoom();
@@ -2371,9 +2438,128 @@ export function PhotosView() {
</div>
{shown && (
- <div className="px-viewer" ref={viewer} role="dialog" aria-label={shown.filename ?? "Photo"}>
+ <div
+ className={`px-viewer${fullscreen ? " is-full" : ""}${fullscreen && thumbs ? " has-thumbs" : ""}`}
+ ref={viewer}
+ role="dialog"
+ aria-label={shown.filename ?? "Photo"}
+ onPointerMove={
+ fullscreen
+ ? (e) => {
+ // The bar comes up as the pointer reaches the top, as icloud.com's does.
+ if (e.clientY < 56) {
+ if (!barUp) setBarUp(true);
+ window.clearTimeout(barTimer.current);
+ } else if (barUp) barAway(700);
+ }
+ : undefined
+ }
+ >
<div className="px-backdrop" aria-hidden="true" />
- <header className="px-viewer-bar">
+ {fullscreen ? (
+ <header
+ key="full"
+ className={`px-full-bar${barUp ? "" : " is-away"}`}
+ ref={fullBar}
+ // Kept up while a key's focus is in it; a click's focus does not hold it.
+ onFocus={(e) => {
+ if (!(e.target as HTMLElement).matches(":focus-visible")) return;
+ setBarUp(true);
+ window.clearTimeout(barTimer.current);
+ }}
+ onBlur={() => barAway()}
+ >
+ <div className="px-full-side">
+ <button className="px-full-btn" aria-label="Exit Full Screen" title="Exit Full Screen (Esc)" onClick={() => void toggleFullscreen(false)}>
+ <Minimize2 size={16} />
+ </button>
+ {photos && photos.length > 1 && (
+ <button
+ className="px-full-btn"
+ aria-label={thumbs ? "Hide Thumbnails" : "Show Thumbnails"}
+ aria-pressed={thumbs}
+ title={thumbs ? "Hide Thumbnails" : "Show Thumbnails"}
+ onClick={toggleThumbs}
+ >
+ <GalleryThumbnails size={17} />
+ </button>
+ )}
+ {shown.kind !== "video" && (
+ <div className="px-zoom">
+ <button className="px-full-btn is-small" aria-label="Zoom Out" title="Zoom Out" onClick={() => zoomMiddle(lensRef.current.k / 1.5)}>
+ <Minus size={13} />
+ </button>
+ <input
+ ref={zoomSlider}
+ type="range"
+ min={1}
+ max={5}
+ step={0.01}
+ defaultValue={lensRef.current.k}
+ aria-label="Zoom"
+ onInput={(e) => zoomMiddle(Number(e.currentTarget.value), false)}
+ />
+ <button className="px-full-btn is-small" aria-label="Zoom In" title="Zoom In" onClick={() => zoomMiddle(lensRef.current.k * 1.5)}>
+ <Plus size={13} />
+ </button>
+ </div>
+ )}
+ </div>
+ {when}
+ <div className="px-full-side is-end">
+ <button className="px-full-btn" aria-label="Info" aria-pressed={info} title="Info (I)" onClick={() => setInfo((v) => !v)}>
+ <Info size={17} />
+ </button>
+ {view === "recentlyDeleted" && !album ? (
+ <>
+ <button className="px-full-btn" aria-label="Recover" title="Recover" onClick={() => void change(shown, "deleted", false)}>
+ <RotateCcw size={17} />
+ </button>
+ <button className="px-full-btn" aria-label="Delete Permanently" title="Delete permanently (Delete)" onClick={() => void change(shown, "expunged", true)}>
+ <Trash2 size={17} />
+ </button>
+ </>
+ ) : (
+ <>
+ <button
+ className="px-full-btn"
+ aria-label={shown.favorite ? "Unfavorite" : "Favorite"}
+ aria-pressed={shown.favorite}
+ title={shown.favorite ? "Unfavorite (.)" : "Favorite (.)"}
+ onClick={() => void change(shown, "favorite", !shown.favorite)}
+ >
+ <Heart size={17} fill={shown.favorite ? "currentColor" : "none"} />
+ </button>
+ <button className="px-full-btn" aria-label="Download" title="Download the original" onClick={() => void download(shown)}>
+ <Download size={17} />
+ </button>
+ {album ? (
+ <button className="px-full-btn" aria-label="Remove from Album" title="Remove from Album (Delete)" onClick={() => void removeFrom([shown])}>
+ <CopyMinus size={17} />
+ </button>
+ ) : (
+ <button className="px-full-btn" aria-label="Delete" title="Delete (Delete)" onClick={() => void change(shown, "deleted", true)}>
+ <Trash2 size={17} />
+ </button>
+ )}
+ </>
+ )}
+ <button
+ className="px-full-btn"
+ aria-label="More"
+ aria-haspopup="menu"
+ title="More"
+ onClick={(e) => {
+ const r = e.currentTarget.getBoundingClientRect();
+ photoMenu(shown, { x: r.right, y: r.bottom + 4, alignRight: true });
+ }}
+ >
+ <Ellipsis size={17} />
+ </button>
+ </div>
+ </header>
+ ) : (
+ <header key="bar" className="px-viewer-bar">
<div className="px-capsule">
<button className="px-cap" aria-label="Close" title="Close (Esc)" onClick={close}>
<X size={17} strokeWidth={2} />
@@ -2388,23 +2574,7 @@ export function PhotosView() {
{fullscreen ? <Minimize2 size={16} /> : <Maximize2 size={16} />}
</button>
</div>
- <div className="px-viewer-when">
- <strong>{new Date(shown.takenAt * 1000).toLocaleDateString(undefined, { dateStyle: "long" })}</strong>
- {view === "recentlyDeleted" && !album && timeLeft(shown, false) ? (
- <span className={timeLeft(shown, false)!.soon ? "is-soon" : undefined}>{timeLeft(shown, false)!.words}</span>
- ) : (
- <span>
- {new Date(shown.takenAt * 1000).toLocaleTimeString(undefined, { timeStyle: "short" })}
- {/* Where it is among them, as icloud.com says it: "133 of 169". */}
- {photos && photos.length > 1 && open !== null && !inBurst && (
- <span className="px-viewer-place">
- {" · "}
- {(open + 1).toLocaleString()} of {photos.length.toLocaleString()}
- </span>
- )}
- </span>
- )}
- </div>
+ {when}
<div className="px-capsule">
{view === "recentlyDeleted" && !album ? (
<>
@@ -2462,6 +2632,7 @@ export function PhotosView() {
</button>
</div>
</header>
+ )}
<div
className="px-stage"
ref={stage}
@@ -2494,6 +2665,21 @@ export function PhotosView() {
</span>
</button>
) : (
+ <>
+ {under && (
+ // The last picture painted, held until the next one over it is decoded.
+ <img
+ key={`${under.id}-under`}
+ ref={underEl}
+ className="px-under"
+ src={viewSrc(under)}
+ alt=""
+ aria-hidden="true"
+ decoding="async"
+ draggable={false}
+ style={fitted(under)}
+ />
+ )}
<div
ref={pan}
className={`px-pan${zoomed ? " is-zoomed" : ""}`}
@@ -2512,34 +2698,38 @@ export function PhotosView() {
onPointerCancel={() => (dragging.current = null)}
>
{/* The picture made the size the stage draws it at — every pixel used, none
- thrown away by the engine — over the thumbnail until it is decoded. */}
- {/* The picture on the stage is `pictured`'s: the next one takes its place
- only once decoded (see pictured). */}
- {(() => {
- const pic = pictured && pictured.kind !== "video" ? pictured : shown;
- return (
+ thrown away by the engine — over the last one painted, or on first opening
+ over the grid's thumbnail, until it is decoded. */}
<img
- key={pic.id}
+ key={shown.id}
className="px-shown"
- src={viewSrc(pic)}
+ src={viewSrc(shown)}
// What was asked for, kept whatever the fallback below does to `src`.
- data-picture={viewSrc(pic)}
- alt={pic.filename ?? ""}
+ data-picture={viewSrc(shown)}
+ alt={shown.filename ?? ""}
decoding="async"
draggable={false}
- style={fitted(pic)}
+ style={under ? { ...fitted(shown), backgroundImage: "none" } : fitted(shown)}
+ onLoad={(e) => {
+ const img = e.currentTarget;
+ const url = viewSrc(shown);
+ const done = () => {
+ decoded.add(url);
+ painted.current = shown;
+ if (underEl.current) underEl.current.style.visibility = "hidden";
+ };
+ img.decode().then(done, done);
+ }}
// Never the engine's broken-picture box (a white frame, a question mark, the
// file's name): a picture that will not come falls back to the thumbnail,
// and past that shows nothing over the thumbnail already painted under it.
onError={(e) => {
const img = e.currentTarget;
- const thumb = pictureSrc(pic.id, "thumb");
+ const thumb = pictureSrc(shown.id, "thumb");
if (!img.src.includes("thumb")) img.src = thumb;
else img.dataset.failed = "";
}}
/>
- );
- })()}
{moving === shown.id && videoBase && (
// The moving part, laid exactly over the still, played once and gone.
<video
@@ -2569,6 +2759,7 @@ export function PhotosView() {
/>
)}
</div>
+ </>
)}
{/* What kind of photo it is, as Photos marks it at the stage's corner: a Live
Photo plays its moving part while the pointer rests on LIVE; a burst's BURST
@@ -2616,7 +2807,7 @@ export function PhotosView() {
</button>
)}
</div>
- {open !== null && photos && photos.length > 1 && (
+ {open !== null && photos && photos.length > 1 && (!fullscreen || thumbs) && (
<Filmstrip photos={photos} at={open} onPick={(i) => step(i - open)} />
)}
{info && (
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 6d3e7bc..4cf2155 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -1104,3 +1104,71 @@ img[data-failed] { content: url("data:image/gif;base64,R0lGODlhAQABAAAAACw="); }
box-shadow: inset 0 0 0 1px var(--field-edge, var(--separator));
}
.px-shared-name:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-ring); }
+/* The last picture painted, in the same place as the frame over it (the stage's one cell). */
+.px-stage > .px-under, .px-stage > .px-pan { grid-area: 1 / 1; }
+.px-under { background-size: 100% 100%; }
+
+/* Full screen: the photo alone, black to every edge, over the whole window — as icloud.com's.
+ Its bar lies over the top and is out of sight until the pointer goes there; the thumbnails,
+ when asked for, take a band along the bottom and the photo fits above them. */
+.px-viewer.is-full { position: fixed; inset: 0; z-index: 40; color: #f5f5f7; }
+.px-viewer.is-full .px-backdrop { background: #000; }
+.px-viewer.is-full .px-stage { padding: 0; }
+.px-viewer.is-full.has-thumbs { grid-template-rows: minmax(0, 1fr) 64px; }
+.px-viewer.is-full .px-strip {
+ position: relative;
+ bottom: auto;
+ grid-row: 2;
+ height: 64px;
+ background: #1c1c1e;
+ border-top: 1px solid rgba(255, 255, 255, 0.08);
+}
+.px-viewer.is-full .px-strip-run { top: 10px; }
+.px-full-bar {
+ position: absolute;
+ inset: 0 0 auto 0;
+ z-index: 3;
+ display: grid;
+ grid-template-columns: 1fr auto 1fr;
+ align-items: center;
+ gap: 12px;
+ height: 44px;
+ padding: 0 10px;
+ /* Solid, not a live blur (WebKitGTK repaints a blur every frame under it). */
+ background: rgba(40, 36, 34, 0.92);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+}
+/* Away: out of sight at once (an animated hide is the compositor's, and flickered). */
+.px-full-bar.is-away { visibility: hidden; }
+.px-full-bar .px-viewer-when strong { color: #f5f5f7; }
+.px-full-bar .px-viewer-when span { color: rgba(245, 245, 247, 0.6); }
+.px-full-side { display: flex; align-items: center; gap: 4px; min-width: 0; }
+.px-full-side.is-end { justify-content: flex-end; }
+.px-full-btn {
+ display: grid;
+ place-items: center;
+ width: 32px;
+ height: 30px;
+ padding: 0;
+ border: 0;
+ border-radius: 7px;
+ background: none;
+ color: #f5f5f7;
+ cursor: pointer;
+}
+.px-full-btn:hover { background: rgba(255, 255, 255, 0.1); }
+.px-full-btn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.16); }
+.px-full-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
+.px-full-btn.is-small { width: 22px; height: 24px; color: rgba(245, 245, 247, 0.75); }
+.px-zoom { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
+.px-zoom input[type="range"] {
+ width: 84px;
+ height: 16px;
+ margin: 0;
+ background: none;
+ accent-color: #f5f5f7;
+ cursor: pointer;
+}
+.px-viewer.is-full .px-nav { background: rgba(60, 60, 64, 0.85); color: #f5f5f7; }
+.px-viewer.is-full .px-nav:hover { background: rgba(80, 80, 86, 0.95); }
+.px-viewer.is-full .px-info { top: 54px; }