Files
wristcode/watch/WristCode/WristCodeApp.swift
T
gibandClaude Opus 5.5 0994fd7d5a Watch: waiting-count complication and multi-select questions
A WidgetKit extension (accessoryCircular, Rectangular, Inline, Corner) shows
GET /v1/summary. The device token moves to the App Group's Keychain access
group on launch so the extension can read it without re-pairing; the app
reloads the timeline when its feed counts change and on notifications.
Multi-select questions toggle options and send an array of values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 11:06:38 -05:00

61 lines
1.8 KiB
Swift

// App entry. Notification setup and APNs registration go through the WatchKit app delegate.
import SwiftUI
import WatchKit
@main
struct WristCodeApp: App {
@WKApplicationDelegateAdaptor(AppDelegate.self) private var delegate
@State private var model = AppModel.shared
var body: some Scene {
WindowGroup {
RootView()
.environment(model)
}
}
}
struct RootView: View {
@Environment(AppModel.self) private var model
var body: some View {
@Bindable var model = model
Group {
if model.mode == .unpaired {
PairView()
} else {
NavigationStack(path: $model.path) {
FeedView()
.navigationDestination(for: Route.self) { route in
switch route {
case let .thread(hostId, threadId):
ThreadView(hostId: hostId, threadId: threadId)
case .newThread:
NewThreadView()
}
}
}
}
}
.fontDesign(.rounded)
.tint(Theme.work)
.onOpenURL { model.open(url: $0) }
}
}
final class AppDelegate: NSObject, WKApplicationDelegate {
func applicationDidFinishLaunching() {
NotificationHandler.shared.install()
Task { await AppModel.shared.enableNotifications() }
}
func didRegisterForRemoteNotifications(withDeviceToken deviceToken: Data) {
AppModel.shared.didRegister(apnsToken: deviceToken)
}
func didFailToRegisterForRemoteNotificationsWithError(_ error: any Error) {
print("APNs registration failed: \(error.localizedDescription)")
}
}