Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Photos: the viewer's filmstrip, as icloud.com's
Yashwanth Kamireddif90637932005
diff --git a/.uiverify/photos-strip.mjs b/.uiverify/photos-strip.mjsnew file mode 100644index 0000000..322ae09--- /dev/null+++ b/.uiverify/photos-strip.mjs@@ -0,0 +1,40 @@+// The viewer's filmstrip, as icloud.com's: the photos either side as slips, the shown one wider+// in the middle; a click goes to it and the strip glides to keep it in the middle; in a library+// of thousands only the nearest are built.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });+await ctx.addInitScript(() => {+ const P = (id, t) => ({ id, master: `m${id}`, takenAt: t, addedAt: t, kind: "image", width: 4032, height: 3024, duration: null,+ 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));+});+const page = await ctx.newPage();+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");+await page.waitForTimeout(500);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const centred = () => page.evaluate(() => {+ const s = document.querySelector(".px-slip.is-shown").getBoundingClientRect(), st = document.querySelector(".px-strip").getBoundingClientRect();+ return Math.abs(s.left + s.width / 2 - (st.left + st.width / 2));+});++await page.locator(".px-tile").nth(40).dblclick();+await page.waitForTimeout(800);+ok((await page.locator(".px-slip").count()) <= 61 && (await page.locator(".px-slip").count()) > 20, `only the nearest slips are built (${await page.locator(".px-slip").count()} of 2000)`);+ok((await centred()) <= 1, "the shown photo's slip sits in the middle");+await page.locator(".px-slip").nth(25).click();+await page.waitForTimeout(700);+const shown = await page.locator(".px-shown").getAttribute("src");+const slip = await page.locator(".px-slip.is-shown img").getAttribute("src");+ok(shown.split("pic%2F")[1]?.split("%2F")[0] === slip.split("pic%2F")[1]?.split("%2F")[0], "a click on a slip goes to that photo");+ok((await centred()) <= 1, "and the strip glides to keep it in the middle");+for (let i = 0; i < 40; i++) await page.keyboard.press("ArrowRight");+await page.waitForTimeout(700);+ok((await centred()) <= 1 && (await page.locator(".px-slip").count()) <= 61, "stepping far along, still in the middle and still few");+await b.close();+process.exitCode = failures ? 1 : (process.exitCode ?? 0);diff --git a/check.sh b/check.shindex 9bbc8cc..6beacd2 100755--- a/check.sh+++ b/check.sh@@ -66,6 +66,7 @@ step "photos real faults" node .uiverify/photos-real.mjsstep "whole photos" node .uiverify/photos-fit.mjsstep "star ratings" node .uiverify/photos-rating.mjsstep "viewer, real sizes" node .uiverify/photos-viewer-real.mjs+step "filmstrip" node .uiverify/photos-strip.mjsstep "notes delete" node .uiverify/notes-delete.mjsstep "empty today" node .uiverify/reminders-empty.mjsstep "calendar keys" node .uiverify/calendar-keys.mjs@@ -115,6 +116,7 @@ step "webkit: real faults" env ENGINE=webkit node .uiverify/photos-real.mjsstep "webkit: whole photos" env ENGINE=webkit node .uiverify/photos-fit.mjsstep "webkit: ratings" env ENGINE=webkit node .uiverify/photos-rating.mjsstep "webkit: viewer sizes" env ENGINE=webkit node .uiverify/photos-viewer-real.mjs+step "webkit: filmstrip" env ENGINE=webkit node .uiverify/photos-strip.mjsstep "webkit: delete" env ENGINE=webkit node .uiverify/notes-delete.mjsstep "webkit: row hover" env ENGINE=webkit node .uiverify/row-hover.mjsstep "webkit: fold" env ENGINE=webkit node .uiverify/sidebar-fold.mjsdiff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsxindex 8129a83..e21d2d0 100644--- a/src/screens/PhotosView.tsx+++ b/src/screens/PhotosView.tsx@@ -108,6 +108,46 @@ const fitFrame = (p: Photo): React.CSSProperties =>? { width: "100%", height: `${(100 * p.height) / p.width}%` }: { height: "100%", width: `${(100 * p.width) / p.height}%` };+/**+ * The viewer's filmstrip, as icloud.com's: the photos either side as narrow slips, the one shown+ * wider in the middle; a click goes to it. Only the sixty or so nearest are built, and the+ * strip glides on the compositor to keep the one shown in the middle.+ */+const SLIP = 26;+const SHOWN = 54;+const GAP = 2;+const REACH = 30;+function Filmstrip({ photos, at, onPick }: { photos: Photo[]; at: number; onPick: (index: number) => void }) {+ const from = Math.max(0, at - REACH);+ const to = Math.min(photos.length - 1, at + REACH);+ // Each slip has its place by its index in the whole library, so the slips built as the+ // window moves along never jump; the strip glides to put the shown one's centre in the middle.+ const shift = -(at * (SLIP + GAP) + SHOWN / 2);+ const slips = [];+ for (let i = from; i <= to; i++) {+ const p = photos[i];+ slips.push(+ <button+ key={p.id}+ className={`px-slip${i === at ? " is-shown" : ""}`}+ style={{ left: i * (SLIP + GAP) + (i > at ? SHOWN - SLIP : 0) }}+ aria-label={p.filename ?? "Photo"}+ aria-current={i === at}+ onClick={() => i !== at && onPick(i)}+ >+ <img src={pictureSrc(p.id, "thumb")} alt="" loading="lazy" decoding="async" draggable={false} />+ </button>,+ );+ }+ return (+ <div className="px-strip" role="toolbar" aria-label="Photos">+ <div className="px-strip-run" style={{ transform: `translateX(${shift}px)` }}>+ {slips}+ </div>+ </div>+ );+}+/** What a tile can ask of the screen; one object, kept the same, so tiles need not redraw. */type Acts = {pick: (index: number, e: React.MouseEvent) => void;@@ -1742,6 +1782,9 @@ export function PhotosView() {</button>)}</div>+ {open !== null && photos && photos.length > 1 && (+ <Filmstrip photos={photos} at={open} onPick={(i) => step(i - open)} />+ )}{info && (<dl className="px-info">{/* As in Photos' Info: the caption first, typed in place, and kept on everydiff --git a/src/styles/photos.css b/src/styles/photos.cssindex 83fe5a1..adf44a7 100644--- a/src/styles/photos.css+++ b/src/styles/photos.css@@ -322,7 +322,7 @@.px-viewer-when strong { font-size: var(--t-13); font-weight: 600; }.px-viewer-when span { color: var(--text-2); font-size: var(--t-11); }.px-cap[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }-.px-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 62px 64px 22px; }+.px-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 62px 64px 70px; }.px-stage img, .px-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }/* The photo's frame: what zooms and pans. The full picture lies over the screen-sized one,faded in once loaded, so zooming never shows a blank. */@@ -352,12 +352,13 @@top: 50%;display: grid;place-items: center;- width: 36px;- height: 36px;- margin-top: -18px;+ width: 38px;+ height: 38px;+ margin-top: -19px;padding: 0;border: 0;- border-radius: 50%;+ /* A rounded square, as icloud.com's viewer has them. */+ border-radius: 10px;background: color-mix(in srgb, var(--sheet) 90%, transparent);box-shadow: var(--glass-float);color: var(--text);@@ -658,3 +659,42 @@}.px-twisty[aria-expanded="true"] .px-chevron { transform: rotate(90deg); }.px-parent-row .px-parent { padding-left: 20px; }++/* ---- the viewer's filmstrip: slips either side, the photo shown wider in the middle --------- */+.px-strip {+ position: absolute;+ left: 0;+ right: 0;+ bottom: 12px;+ z-index: 2;+ height: 44px;+ overflow: hidden;+ pointer-events: none;+}+.px-strip-run {+ position: absolute;+ left: 50%;+ top: 0;+ height: 44px;+ transition: transform 260ms var(--spring-smooth);+ will-change: transform;+}+.px-slip {+ position: absolute;+ top: 2px;+ width: 26px;+ height: 40px;+ padding: 0;+ border: 0;+ border-radius: 4px;+ overflow: hidden;+ background: color-mix(in srgb, var(--text) 10%, transparent);+ pointer-events: auto;+ cursor: default;+ opacity: 0.82;+ transition: opacity 140ms ease;+}+.px-slip:hover { opacity: 1; }+.px-slip img { width: 100%; height: 100%; object-fit: cover; display: block; }+.px-slip.is-shown { width: 54px; top: 0; height: 44px; opacity: 1; box-shadow: 0 0 0 2px var(--accent); }+@media (prefers-reduced-motion: reduce) { .px-strip-run { transition: none; } }