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.

Drive list: Name, Kind, Size and Date headings as Finder and icloud.com show them, each a click to sort; a Kind column naming each file's type

Yashwanth Kamireddibb124ccc3c08
diff --git a/.uiverify/drive-sort.mjs b/.uiverify/drive-sort.mjs
index feb90a2..1199d08 100644
--- a/.uiverify/drive-sort.mjs
+++ b/.uiverify/drive-sort.mjs
@@ -43,6 +43,11 @@ ok((await names())[0] === "Downloads", "folders stay at the top");
await pick("Size");
const bySize = await files();
ok(JSON.stringify(bySize) === JSON.stringify(["File 2.txt", "Semester Plan.pdf", "File 10.txt"]), `by Size, largest first ${JSON.stringify(bySize)}`);
+// The column heading is the same choice as the menu.
+await pick("Name");
+await page.locator(".drive-head").getByRole("button", { name: "Size" }).click();
+await page.waitForTimeout(150);
+ok(JSON.stringify(await files()) === JSON.stringify(bySize), "a click on the Size heading sorts by size");
await pick("Date");
const byDate = await files();
ok(JSON.stringify(byDate) === JSON.stringify(["File 10.txt", "Semester Plan.pdf", "File 2.txt"]), `by Date, newest first ${JSON.stringify(byDate)}`);
diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsx
index 6cb65f2..e46568f 100644
--- a/src/screens/DriveView.tsx
+++ b/src/screens/DriveView.tsx
@@ -141,6 +141,7 @@ function DriveTrash({ onClose }: { onClose: () => void }) {
<FileGlyph kind={item.kind} extension={item.extension} />
</span>
<span className="drive-name">{driveName(item)}</span>
+ <span className="drive-meta drive-kind">{kindName(item)}</span>
<span className="drive-meta">{isContainer(item) ? "" : fileSize(item.size)}</span>
<span className="drive-meta">{modified(item.modifiedAt ?? item.createdAt)}</span>
</span>
@@ -764,6 +765,27 @@ export function DriveView() {
</p>
)}
+ {!grid && (
+ // Finder's and icloud.com's column headings: what each column is, and a click to
+ // sort by it — the menu above and these are the same choice.
+ <div className="drive-row drive-head" role="presentation">
+ <span className="drive-row-hit">
+ <span />
+ {(["name", "kind", "size", "date"] as const).map((key) => (
+ <button
+ key={key}
+ className={`drive-col${sortBy === key ? " is-on" : ""}${key === "name" ? " is-name" : ""}`}
+ aria-pressed={sortBy === key}
+ onClick={() => chooseSort(key)}
+ >
+ {SORTS.find((o) => o.key === key)?.label}
+ {sortBy === key && <span aria-hidden="true"> ⌄</span>}
+ </button>
+ ))}
+ </span>
+ <span className="drive-row-actions" aria-hidden="true" />
+ </div>
+ )}
<ul className={`drive-rows${grid ? " is-grid" : ""}`}>
{pending
.filter((p) => p.folder === here.id && !items.some((i) => driveName(i) === p.name))
@@ -774,6 +796,7 @@ export function DriveView() {
<span className="drive-spinner" />
</span>
<span className="drive-name">{p.name}</span>
+ <span className="drive-meta drive-kind" />
<span className="drive-meta">{p.doing}</span>
<span className="drive-meta" />
</span>
@@ -872,6 +895,7 @@ export function DriveView() {
)}
</span>
<span className="drive-name">{driveName(item)}</span>
+ <span className="drive-meta drive-kind">{kindName(item)}</span>
<span className="drive-meta">
{container
? item.childCount === null
diff --git a/src/styles/app.css b/src/styles/app.css
index 9453954..670f643 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -1003,7 +1003,7 @@
.drive-row-hit {
display: grid;
- grid-template-columns: 40px 1fr 90px 110px;
+ grid-template-columns: 40px minmax(0, 1fr) minmax(0, 170px) 80px 120px;
align-items: center;
gap: 12px;
flex: 1;
@@ -1784,3 +1784,12 @@
font-size: var(--t-12, 12px); font-weight: 600;
border-bottom: 1px solid var(--separator);
}
+/* The column headings, in the rows' own grid, quiet until one is the order. */
+.drive-head { border-bottom: 1px solid var(--separator); border-radius: 0; }
+.drive-head:hover { background: none; }
+.drive-head .drive-row-hit { cursor: default; padding-block: 4px; }
+.drive-col { padding: 0; border: 0; background: none; box-shadow: none; color: var(--text-3); font: inherit; font-size: var(--t-12, 12px); text-align: left; cursor: pointer; }
+.drive-col.is-on { color: var(--text-2); font-weight: 600; }
+.drive-col:hover { color: var(--text); }
+.drive-kind { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+@media (max-width: 900px) { .drive-kind, .drive-col:nth-of-type(2) { display: none; } .drive-row-hit { grid-template-columns: 40px minmax(0, 1fr) 80px 110px; } }