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 viewer: full screen and "2 of 5", as icloud.com's; errors shown over it
Yashwanth Kamireddia7ddaba58db3
diff --git a/.uiverify/photos-fullscreen.mjs b/.uiverify/photos-fullscreen.mjsnew file mode 100644index 0000000..7f24db5--- /dev/null+++ b/.uiverify/photos-fullscreen.mjs@@ -0,0 +1,41 @@+// The viewer as icloud.com's: where the photo is among them ("2 of 5") under its date, and a+// button for full screen; Escape leaves full screen before it closes the photo, and closing a+// photo leaves full screen too.+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 });+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(400);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const asked = () => page.evaluate(() => window.__fullscreen ?? []);++await page.locator(".px-tile").nth(1).dblclick();+await page.waitForTimeout(300);+ok(/2 of 5/.test(await page.locator(".px-viewer-when").innerText()), `where the photo is among them, under its date "${(await page.locator(".px-viewer-when").innerText()).replace(/\n/g, " ")}"`);+await page.keyboard.press("ArrowRight");+await page.waitForTimeout(150);+ok(/3 of 5/.test(await page.locator(".px-viewer-when").innerText()), "and it follows the arrows");+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");+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");+await page.keyboard.press("Escape");+await page.waitForTimeout(150);+ok((await page.locator(".px-viewer").count()) === 0, "and Escape again closes the photo");+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.waitForTimeout(200);+ok((await asked()).at(-1) === false, "closing a photo leaves full screen too");+await b.close();+process.exitCode = failures ? 1 : (process.exitCode ?? 0);diff --git a/.uiverify/photos.mjs b/.uiverify/photos.mjsindex 48f7f70..4268e57 100644--- a/.uiverify/photos.mjs+++ b/.uiverify/photos.mjs@@ -81,8 +81,13 @@ await page.getByRole("button", { name: "Favorite", exact: true }).click();await page.waitForTimeout(300);ok((await page.getByRole("button", { name: "Favorite", exact: true }).count()) === 1 && (await page.locator(".notice").count()) === 1,"a change iCloud refuses goes back, and says why");-await page.keyboard.press("Escape");+ok(await page.locator(".notice").evaluate((n) => {+ const r = n.getBoundingClientRect();+ return n.contains(document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2));+}), "and says it in front of the open photo, not hidden behind it");await page.evaluate(() => { window.__flagFail = false; });+await page.getByRole("button", { name: "Dismiss" }).click();+await page.keyboard.press("Escape");// It goes back into its tile first, then is gone.await page.waitForTimeout(650);ok((await page.locator(".px-viewer").count()) === 0, "Escape closes the viewer");diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex dfe728a..9c6ecd2 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -440,6 +440,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notecase "photo_play": (window.__plays ??= []).push(args); return null;case "video_base": return window.__videoBase ?? null;case "window_tint": (window.__tints ??= []).push(args.rgb.join(",")); return null;+ case "window_fullscreen": (window.__fullscreen ??= []).push(args.on); return args.on;case "photo_download": (window.__downloads ??= []).push(args); return `/home/test/Downloads/IMG_${args.id}.JPG`;// Each file is answered at once with where it stands; a test plays the rest in with __emit.case "photos_upload": {diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex e273853..7291e98 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -3532,6 +3532,14 @@ fn window_tint(window: tauri::WebviewWindow, rgb: [u8; 3]) -> UiResult<()> {.map_err(|e| e.to_string())}+/// The window full screen, or back, as the photo viewer's button asks (icloud.com's); answers+/// whether it now is.+#[tauri::command]+fn window_fullscreen(window: tauri::WebviewWindow, on: bool) -> UiResult<bool> {+ window.set_fullscreen(on).map_err(|e| e.to_string())?;+ window.is_fullscreen().map_err(|e| e.to_string())+}+/// Whether this session runs under a tiling Wayland compositor, which manages windows itself.fn tiling_compositor() -> bool {let set = |k: &str| std::env::var_os(k).is_some_and(|v| !v.is_empty());@@ -3872,6 +3880,7 @@ fn main() {photos::photos_prepare,video::video_base,window_tint,+ window_fullscreen,photos::photos_upload,photos::photos_upload_cancel,photos::photos_album_create,diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex 7c2b1bd..7a72a4c 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -97,6 +97,8 @@ export const api = {photoPlay: (id: string) => invoke<void>("photo_play", { id }),/** Where the window's player fetches videos from (a loopback server), or null without one. */videoBase: () => invoke<string | null>("video_base"),+ /** The window full screen or back; answers whether it now is. */+ windowFullscreen: (on: boolean) => invoke<boolean>("window_fullscreen", { on }),/** What the window shows pictures at, so the app makes them before they are shown. */photosPrepare: (shown: { cell: number; fit: boolean; stageW: number; stageH: number; dpr: number }) =>invoke<void>("photos_prepare", { shown }),diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsxindex 4cd06f1..d0554cf 100644--- a/src/screens/PhotosView.tsx+++ b/src/screens/PhotosView.tsx@@ -7,7 +7,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useStatimport { 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, type LucideIcon } from "lucide-react";+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, type LucideIcon } from "lucide-react";import {api,messageOf,@@ -791,6 +791,21 @@ export function PhotosView() {useEffect(() => {if (open === null && inBurst) void leaveBurst(false);}, [open === null]); // eslint-disable-line react-hooks/exhaustive-deps+ /**+ * The window full screen for a photo, as icloud.com's viewer offers: the button, and Escape+ * leaving full screen before it closes the photo. Closing the photo leaves it too.+ */+ const [fullscreen, setFullscreen] = useState(false);+ const toggleFullscreen = async (on = !fullscreen) => {+ try {+ setFullscreen(await api.windowFullscreen(on));+ } catch (e) {+ setError(messageOf(e));+ }+ };+ useEffect(() => {+ if (open === null && fullscreen) void toggleFullscreen(false);+ }, [open === null]); // eslint-disable-line react-hooks/exhaustive-deps/** A Live Photo's moving part playing over it. */const [moving, setMoving] = useState<string | null>(null);useEffect(() => setMoving(null), [shown?.id]);@@ -883,6 +898,7 @@ export function PhotosView() {if (e.key === "ArrowRight") step(1);else if (e.key === "ArrowLeft") step(-1);else if (e.key === "Escape" && lensRef.current.k > 1) unzoom();+ else if (e.key === "Escape" && fullscreen) void toggleFullscreen(false);else if (e.key === "Escape") close();// Cmd/Ctrl + "." closes too, as icloud.com's one-up view does.else if ((e.ctrlKey || e.metaKey) && e.key === ".") close();@@ -2277,13 +2293,31 @@ export function PhotosView() {<button className="px-cap" aria-label="Close" title="Close (Esc)" onClick={close}><X size={17} strokeWidth={2} /></button>+ <button+ className="px-cap"+ aria-label={fullscreen ? "Exit Full Screen" : "Enter Full Screen"}+ aria-pressed={fullscreen}+ title={fullscreen ? "Exit Full Screen" : "Enter Full Screen"}+ onClick={() => void toggleFullscreen()}+ >+ {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" })}</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><div className="px-capsule">diff --git a/src/styles/photos.css b/src/styles/photos.cssindex 2cdb2d5..0e60295 100644--- a/src/styles/photos.css+++ b/src/styles/photos.css@@ -85,7 +85,8 @@.px-count { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: var(--t-12, 12px); }/* ---- the library ------------------------------------------------------------------------- */-.px-notice { position: absolute; z-index: 5; top: 62px; left: 18px; right: 18px; max-width: 420px; }+/* Above the photo viewer too: a change refused while a photo was open said so behind it, unseen. */+.px-notice { position: absolute; z-index: 7; top: 62px; left: 18px; right: 18px; max-width: 420px; }.px-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }.px-bar {position: absolute;