Add the watch app and its eight complications

The watch receives the phone's payload over WatchConnectivity and writes it
into its own App Group container through the same SnapshotStore, so there is
one wire format and one reader. The agenda, the detail screen and the filter
all read that; the complications read what the app last wrote, since an
extension cannot run a WCSession of its own.

Complication timelines land on event boundaries rather than a schedule, so the
next appointment flips in the exact minute it changes without spending refresh
budget.

CalendarrWatchShared holds what both watch targets need, attached to each the
way Shared/ is attached to the app and the widgets.

recommendations() is implemented because watchOS requires it — iOS has a
default, the watch does not, since the complication gallery has to be
populated. Found by building, not by reading.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-09-11 17:08:27 +02:00
co-authored by Claude Opus 5
parent 6a7afe0647
commit f9bc1965a5
23 changed files with 1190 additions and 223 deletions
@@ -0,0 +1,49 @@
import SwiftUI
import CalendarrCore
/// Narrows what this watch shows, on top of what the phone already filtered.
/// One toggle here affects the agenda and every complication at once.
struct WatchCalendarFilterView: View {
@Environment(WatchSnapshotModel.self) private var model
var body: some View {
NavigationStack {
List {
if model.calendars.isEmpty {
Text(WatchL10n.t("watch.waiting", model.language))
.font(.footnote)
.foregroundStyle(.secondary)
} else {
ForEach(model.calendars) { calendar in
row(calendar)
}
}
}
.navigationTitle(WatchL10n.t("watch.calendars", model.language))
}
}
private func row(_ calendar: SnapshotCalendar) -> some View {
let shown = !model.isHidden(calendar.id)
return Button {
model.setHidden(calendar.id, shown)
} label: {
HStack(spacing: 8) {
// A checkbox, not a Toggle: a switch reads as a state indicator
// you wait on rather than a control you tap.
Image(systemName: shown ? "checkmark.square.fill" : "square")
.font(.system(size: 16))
.foregroundStyle(shown ? Color.accentColor : Color.secondary)
Circle()
.fill(Color(watchHex: calendar.colorHex))
.frame(width: 7, height: 7)
Text(calendar.name)
.font(.system(size: 14))
.lineLimit(1)
Spacer(minLength: 0)
}
}
.buttonStyle(.plain)
.accessibilityAddTraits(shown ? [.isSelected] : [])
}
}