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: a burst's tile shows its stack, a long video its hours

Yashwanth Kamireddia5a213c8afe1
diff --git a/.uiverify/photos-burst-live.mjs b/.uiverify/photos-burst-live.mjs
index f88ac77..f10ac7c 100644
--- a/.uiverify/photos-burst-live.mjs
+++ b/.uiverify/photos-burst-live.mjs
@@ -24,7 +24,8 @@ await ctx.addInitScript((v) => {
// A selfie Live Photo's moving part: a quarter turn and a mirror, as the front camera writes it.
window.__turn = [0, 1, 1, 0];
// p2 is a burst's chosen photo (of 3), p4 a Live Photo.
- window.__photoExtra = { p2: { burst: "B1", burstPick: true, burstCount: 3 }, p4: { kind: "live" } };
+ // p3 a video just over an hour long, 0.4 s short of 1:01:00: written "1:01:00", never "60:60".
+ window.__photoExtra = { p2: { burst: "B1", burstPick: true, burstCount: 3 }, p3: { duration: 3659.6 }, p4: { kind: "live" } };
}, base);
const page = await ctx.newPage();
page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
@@ -36,6 +37,15 @@ const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failu
const tiles = () => page.locator(".px-tile").count();
const before = await tiles();
+// In the grid: the burst is one tile, marked as a stack with how many it holds; the video
+// shows its length, whole.
+const badge = page.locator('.px-tile[data-id="p2"] .px-burst');
+ok((await badge.count()) === 1 && (await badge.innerText()).trim() === "3" && (await badge.locator("svg").count()) === 1, "a burst's tile is marked as a stack of 3");
+ok(/burst of 3 photos/.test(await page.locator('.px-tile[data-id="p2"]').getAttribute("aria-label")), "…and says so to a screen reader");
+ok((await page.locator(".px-burst").count()) === 1, "no other tile is marked as a burst");
+const length = (await page.locator('.px-tile[data-id="p3"] .px-duration').innerText()).trim();
+ok(length === "1:01:00", `a video over an hour shows hours, minutes and seconds (${length})`);
+
await page.locator('.px-tile[data-id="p2"]').dblclick();
await page.waitForTimeout(600);
const burst = page.getByRole("button", { name: /View all 3 photos in this burst/ });
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index d6614f6..e4cbc8a 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -8,7 +8,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useStat
import { listen } from "@tauri-apps/api/event";
import { getCurrentWebview } from "@tauri-apps/api/webview";
import { pickOpen } from "../lib/pick";
-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, 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, SquareStack, Folder as FolderIcon, Aperture, Video, X, CalendarDays, Maximize2, Minimize2, Users, type LucideIcon } from "lucide-react";
import {
api,
messageOf,
@@ -128,10 +128,15 @@ const timeLeft = (p: Photo, compact: boolean) => {
return { words: `${n} ${unit}${n === 1 ? "" : "s"}${compact ? "" : " left"}`, soon: ms < 4 * 86_400_000 };
};
+/** A video's length as Photos writes it on its tile: "0:07", "4:32", "1:02:05". */
const clock = (s: number | null) => {
if (!s) return "";
- const m = Math.floor(s / 60);
- return `${m}:${String(Math.round(s % 60)).padStart(2, "0")}`;
+ // Whole seconds first: the seconds rounded on their own read 59.6 s as "0:60", and an
+ // hour-long video ran on in minutes ("75:03"). A clip under half a second is still "0:01".
+ const t = Math.max(1, Math.round(s));
+ const two = (n: number) => String(n).padStart(2, "0");
+ const [h, m, sec] = [Math.floor(t / 3600), Math.floor((t % 3600) / 60), t % 60];
+ return h ? `${h}:${two(m)}:${two(sec)}` : `${m}:${two(sec)}`;
};
/** A photo's frame when fitted: its own shape, as large as the square cell lets it be. */
@@ -375,7 +380,9 @@ const Tile = memo(function Tile({
// A photo is chosen as an option in a listbox is: aria-selected belongs to an option.
role="option"
className="px-tile"
- aria-label={`${photo.filename ?? "Photo"}, ${new Date(photo.takenAt * 1000).toLocaleString()}`}
+ aria-label={`${photo.filename ?? "Photo"}, ${new Date(photo.takenAt * 1000).toLocaleString()}${
+ photo.burst && (photo.burstCount ?? 0) > 1 ? `, burst of ${photo.burstCount} photos` : ""
+ }`}
data-id={photo.id}
data-index={index}
aria-selected={selected}
@@ -443,6 +450,14 @@ const Tile = memo(function Tile({
{clock(photo.duration)}
</span>
)}
+ {/* A burst is one photo in the grid, as in Photos: its chosen shot, marked as a stack
+ with how many it holds, so it is known for one before it is opened. */}
+ {photo.burst && (photo.burstCount ?? 0) > 1 && (
+ <span className="px-badge px-burst">
+ <SquareStack size={11} strokeWidth={2.2} aria-hidden="true" />
+ {photo.burstCount}
+ </span>
+ )}
{left && <span className={`px-badge px-left${soon ? " is-soon" : ""}`}>{left}</span>}
{(photo.rating ?? 0) > 0 && <span className="px-stars" aria-label={`${photo.rating} stars`}>{photo.rating}★</span>}
{photo.favorite && <Heart className="px-heart" size={13} strokeWidth={0} fill="currentColor" aria-label="Favorite" />}
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 4490222..8379b61 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -217,6 +217,8 @@
font-variant-numeric: tabular-nums;
text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}
+/* The stack a burst is marked with: shadowed as the count beside it is, to read on any photo. */
+.px-burst svg { filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6)); }
.px-heart { position: absolute; left: 6px; bottom: 6px; color: #fff; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6)); }
/* ---- the viewer: a dark stage, the photo fitted to it -------------------------------------- */