Queue document writes durably and surface sync trouble in the UI

iCloud Drive writes now flow through a persistent WriteBacklog sidecar
(drained with backoff, flushed on backgrounding, wiped with the cache on
account change), so a save can never be lost to a transient coordinator
error. A status banner on the workout list surfaces stuck syncing.
Also: the split picker gains a Recent section with day labels, split
rows fold SplitItem into SplitListView, and list rows dim the multiply
sign in sets-by-reps.

Claude-Session: https://claude.ai/code/session_01HJDQQDA9QdP8zByg43H5v3
This commit is contained in:
2026-07-08 12:48:12 -04:00
parent 495fce1e5a
commit c05e83cff7
13 changed files with 1175 additions and 144 deletions
+49 -20
View File
@@ -10,39 +10,37 @@
import SwiftUI
import SwiftData
/// The Splits library screen, pushed from Settings Library: a two-column grid of
/// split tiles. Tapping a tile opens `SplitDetailView`; long-pressing offers Delete
/// (the sole split-delete affordance); the toolbar's + adds a new split. Starter
/// splits are seeded automatically on the true first run (`SyncEngine.autoSeedIfEmpty`),
/// so an empty library just invites creating one.
/// The Splits library screen, pushed from Settings Library: a plain list of
/// splits, one row each. Tapping a row opens `SplitDetailView`; long-pressing
/// offers Delete (the sole split-delete affordance); the toolbar's + adds a new
/// split. Starter splits are seeded automatically on the true first run
/// (`SyncEngine.autoSeedIfEmpty`), so an empty library just invites creating one.
struct SplitListView: View {
@Environment(SyncEngine.self) private var sync
@Query(sort: \Split.order) private var splits: [Split]
@Query(sort: \Split.name) private var splits: [Split]
@State private var showingAddSheet = false
@State private var splitToDelete: Split?
var body: some View {
ScrollView {
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], spacing: 16) {
ForEach(splits) { split in
NavigationLink {
SplitDetailView(split: split)
List {
ForEach(splits) { split in
NavigationLink {
SplitDetailView(split: split)
} label: {
SplitRow(split: split)
}
.contextMenu {
Button(role: .destructive) {
splitToDelete = split
} label: {
SplitItem(split: split)
}
.contextMenu {
Button(role: .destructive) {
splitToDelete = split
} label: {
Label("Delete", systemImage: "trash")
}
Label("Delete", systemImage: "trash")
}
}
}
.padding()
}
.listStyle(.insetGrouped)
.overlay {
if splits.isEmpty {
ContentUnavailableView(
@@ -87,3 +85,34 @@ struct SplitListView: View {
}
}
}
/// A single split row: a small rounded-square badge (the split's color at low
/// opacity, its symbol tinted full-strength) beside the split name and its
/// exercise count.
private struct SplitRow: View {
var split: Split
var body: some View {
HStack(spacing: 12) {
Image(systemName: split.systemImage)
.font(.title3)
.foregroundStyle(splitColor)
.frame(width: 36, height: 36)
.background(splitColor.opacity(0.12), in: RoundedRectangle(cornerRadius: 8))
VStack(alignment: .leading, spacing: 2) {
Text(split.name)
.foregroundStyle(.primary)
Text("\(split.exercisesArray.count) exercises")
.font(.caption)
.foregroundStyle(.secondary)
}
}
.padding(.vertical, 2)
}
private var splitColor: Color {
Color.color(from: split.color)
}
}