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
Contacts: in Contacts' order — last name then first, companies by name, nameless cards last — under sticky letter headings
Yashwanth Kamireddi962a6ea96870
diff --git a/.uiverify/contacts-order.mjs b/.uiverify/contacts-order.mjsnew file mode 100644index 0000000..05ad56a--- /dev/null+++ b/.uiverify/contacts-order.mjs@@ -0,0 +1,20 @@+// Contacts in Contacts' order — last name, then first; a company by its name; a card with+// no name last — under the letter each run begins with.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true });+const page = await ctx.newPage();+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(page, "Contacts");+await page.waitForTimeout(400);+const seen = await page.locator(".contact-rows > li").allInnerTexts();+const flat = seen.map((t) => t.replace(/\s+/g, " ").trim());+console.log(JSON.stringify(flat));+const names = flat.filter((t) => t.length > 1 && !/^[A-Z#]$/.test(t)).map((t) => t.replace(/^\S+ /, ""));+const letters = flat.filter((t) => /^[A-Z#]$/.test(t));+const pass = names.at(-1)?.startsWith("+91") && letters.at(-1) === "#" && new Set(letters).size === letters.length;+console.log(pass ? "PASS contacts run in Contacts' order under their letters" : `FAIL order ${JSON.stringify({ names, letters })}`);+await b.close();+process.exitCode = pass ? 0 : 1;diff --git a/.uiverify/look-all.mjs b/.uiverify/look-all.mjsnew file mode 100644index 0000000..83a5a7e--- /dev/null+++ b/.uiverify/look-all.mjs@@ -0,0 +1,16 @@+// Not a check: every screen with fixture data, to look at. node look-all.mjs <dir> [w] [h] [scheme]+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const [out = ".", w = "1400", h = "850", scheme = "dark"] = process.argv.slice(2);+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: +w, height: +h }, colorScheme: scheme });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,+ calendarFixture: true, notesFixture: true, contactsFixture: true, driveFixture: true, remindersFixture: true });+const p = await ctx.newPage();+await p.goto("http://localhost:4173", { waitUntil: "networkidle" });+for (const s of ["Reminders", "Notes", "iCloud Drive", "Calendar", "Contacts"]) {+ await openScreen(p, s);+ await p.waitForTimeout(500);+ await p.screenshot({ path: `${out}/all-${s.replace(/\W/g, "")}.png` });+}+await b.close();diff --git a/check.sh b/check.shindex aac23dc..9c1670a 100755--- a/check.sh+++ b/check.sh@@ -59,6 +59,7 @@ step "drive delete" node .uiverify/drive-delete.mjsstep "notes folders" node .uiverify/notes-folders.mjsstep "list info" node .uiverify/reminders-list-info.mjsstep "reminder date" node .uiverify/reminders-date.mjs+step "contacts order" node .uiverify/contacts-order.mjs# The same screens in WebKit, the engine Quince draws in. Chromium above catches most things;# this catches what only WebKit does — pointer capture, blur on removal, its own layout.diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsxindex 5869844..708e6fc 100644--- a/src/screens/ContactsView.tsx+++ b/src/screens/ContactsView.tsx@@ -1,4 +1,4 @@-import { useCallback, useEffect, useMemo, useState } from "react";+import { Fragment, useCallback, useEffect, useMemo, useState } from "react";import { Notice } from "../components/Notice";import { ChevronLeft } from "lucide-react";import {@@ -206,8 +206,12 @@ export function ContactsView() {{error && <Notice message={error} onDismiss={() => setError(null)} />}<ul className="contact-rows">- {contacts.map((contact) => (- <li key={contact.guid}>+ {sortedContacts(contacts).map((contact, i, all) => (+ <Fragment key={contact.guid}>+ {(i === 0 || letterOf(all[i - 1]) !== letterOf(contact)) && (+ <li className="contact-letter" aria-hidden="true">{letterOf(contact)}</li>+ )}+ <li><buttonclassName="contact-row"aria-current={openGuid === contact.guid}@@ -220,6 +224,7 @@ export function ContactsView() {<span className="contact-row-name">{displayName(contact)}</span></button></li>+ </Fragment>))}</ul>@@ -474,3 +479,24 @@ function birthdayText(raw: string): string {const date = new Date(y === Number(NO_YEAR) ? 2000 : y, m - 1, d);return date.toLocaleDateString(undefined, y === Number(NO_YEAR) ? { day: "numeric", month: "long" } : { dateStyle: "long" });}++/**+ * The order Contacts keeps: by last name, then first — a company by its name — letters+ * before anything else, accents and case aside, and a card with no name at all ("#") last.+ */+const contactCollator = new Intl.Collator(undefined, { sensitivity: "base", numeric: true });+function sortKey(c: Contact): string {+ if (c.isCompany && c.company) return c.company;+ return [c.lastName, c.firstName, c.middleName].filter(Boolean).join(" ") || c.company || "";+}+function letterOf(c: Contact): string {+ const first = sortKey(c).trim().charAt(0).toLocaleUpperCase();+ return /\p{L}/u.test(first) ? first.normalize("NFD").charAt(0) : "#";+}+function sortedContacts(list: Contact[]): Contact[] {+ return [...list].sort((a, b) => {+ const la = letterOf(a) === "#", lb = letterOf(b) === "#";+ if (la !== lb) return la ? 1 : -1;+ return contactCollator.compare(sortKey(a), sortKey(b));+ });+}diff --git a/src/styles/app.css b/src/styles/app.cssindex c67ae59..9453954 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -1777,3 +1777,10 @@.drive-row.is-selected .drive-more { color: #fff; }/* A time typed as said: the width of "12:45 PM", right-aligned figures, as macOS's. */.time-field { width: 8.5ch; text-align: center; font-variant-numeric: tabular-nums; }+/* The letter a run of names begins with, as Contacts heads its list. */+.contact-letter {+ position: sticky; top: 0; z-index: 1; padding: 10px 10px 4px;+ background: var(--bg); color: var(--text-3);+ font-size: var(--t-12, 12px); font-weight: 600;+ border-bottom: 1px solid var(--separator);+}