This repository has been archived on 2026-09-14. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Calendarr-IOS/CalendarrWatch/Views/WatchStatusView.swift
T
ScarriffleandClaude Opus 5 f9bc1965a5 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>
2026-09-11 17:08:27 +02:00

45 lines
1.6 KiB
Swift

import SwiftUI
import CalendarrCore
/// Every reason there is nothing to show, named. "Never received", "signed out"
/// and "genuinely empty" call for different sentences, and showing the wrong one
/// sends the user looking in the wrong place.
struct WatchStatusView: View {
let result: SnapshotReadResult
let language: String
var body: some View {
VStack(spacing: 8) {
Image(systemName: symbol)
.font(.system(size: 22))
.foregroundStyle(.secondary)
Text(message)
.font(.footnote)
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
}
.padding(.horizontal, 6)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
private var symbol: String {
switch result {
case .ok: return "calendar"
case .loggedOut: return "person.crop.circle.badge.xmark"
case .neverWritten: return "iphone.and.arrow.forward"
case .incompatible: return "arrow.down.circle"
case .unreadable: return "exclamationmark.triangle"
}
}
private var message: String {
switch result {
case .ok: return WatchL10n.t("watch.no_events", language)
case .loggedOut: return WatchL10n.t("watch.sign_in", language)
case .neverWritten: return WatchL10n.t("watch.waiting", language)
case .incompatible: return WatchL10n.t("watch.update", language)
case .unreadable: return WatchL10n.t("watch.unreadable", language)
}
}
}