2026-04-18 01:05:22 +02:00
|
|
|
import Foundation
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
private let watchAccent = AppTheme.accent
|
|
|
|
|
private let watchGold = AppTheme.warmAccent
|
|
|
|
|
|
|
|
|
|
struct WatchRootView: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
NavigationStack {
|
|
|
|
|
Group {
|
|
|
|
|
if model.session == nil {
|
|
|
|
|
WatchPairingView(model: model)
|
|
|
|
|
} else {
|
|
|
|
|
WatchDashboardView(model: model)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
|
|
|
}
|
|
|
|
|
.tint(watchAccent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchPairingView: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
ScrollView {
|
|
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
2026-04-18 06:11:07 +02:00
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
2026-04-18 01:05:22 +02:00
|
|
|
AppBadge(title: "Preview passport", tone: watchAccent)
|
|
|
|
|
|
|
|
|
|
Text("Prove identity from your wrist")
|
|
|
|
|
.font(.title3.weight(.semibold))
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
Text("Link this watch to the preview passport so identity checks and alerts stay visible on your wrist.")
|
2026-04-18 01:05:22 +02:00
|
|
|
.font(.footnote)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.72))
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
HStack(spacing: 8) {
|
|
|
|
|
AppStatusTag(title: "Wrist-ready", tone: watchAccent)
|
2026-04-18 06:11:07 +02:00
|
|
|
AppStatusTag(title: "Proof focus", tone: watchGold)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
if model.isBootstrapping {
|
2026-04-18 06:11:07 +02:00
|
|
|
HStack(spacing: 8) {
|
|
|
|
|
ProgressView()
|
|
|
|
|
.tint(watchAccent)
|
|
|
|
|
Text("Preparing preview passport...")
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.72))
|
|
|
|
|
}
|
|
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
Task {
|
|
|
|
|
await model.signInWithSuggestedPayload()
|
|
|
|
|
}
|
|
|
|
|
} label: {
|
|
|
|
|
if model.isAuthenticating {
|
|
|
|
|
ProgressView()
|
|
|
|
|
.frame(maxWidth: .infinity)
|
|
|
|
|
} else {
|
2026-04-18 06:11:07 +02:00
|
|
|
Label("Link Preview Passport", systemImage: "applewatch")
|
2026-04-18 01:05:22 +02:00
|
|
|
.frame(maxWidth: .infinity)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.buttonStyle(.borderedProminent)
|
2026-04-18 06:11:07 +02:00
|
|
|
.tint(watchAccent)
|
2026-04-18 01:05:22 +02:00
|
|
|
.disabled(model.isBootstrapping || model.suggestedPairingPayload.isEmpty || model.isAuthenticating)
|
|
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
|
|
|
Text("What this watch does")
|
2026-04-18 01:05:22 +02:00
|
|
|
.font(.headline)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
|
|
|
|
|
|
|
|
|
WatchSetupFeatureRow(
|
|
|
|
|
systemImage: "checkmark.shield",
|
|
|
|
|
title: "Review identity checks",
|
|
|
|
|
subtitle: "See pending proof prompts quickly."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
WatchSetupFeatureRow(
|
|
|
|
|
systemImage: "bell.badge",
|
|
|
|
|
title: "Surface important alerts",
|
|
|
|
|
subtitle: "Keep passport activity visible at a glance."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
WatchSetupFeatureRow(
|
|
|
|
|
systemImage: "iphone.radiowaves.left.and.right",
|
|
|
|
|
title: "Stay in sync with the phone preview",
|
|
|
|
|
subtitle: "Use the same mocked passport context."
|
|
|
|
|
)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
.padding(.horizontal, 8)
|
2026-04-18 06:11:07 +02:00
|
|
|
.padding(.top, 6)
|
2026-04-18 01:05:22 +02:00
|
|
|
.padding(.bottom, 20)
|
|
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.background(Color.black.ignoresSafeArea())
|
|
|
|
|
.navigationTitle("Link Watch")
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
private struct WatchSetupFeatureRow: View {
|
|
|
|
|
let systemImage: String
|
2026-04-18 01:05:22 +02:00
|
|
|
let title: String
|
2026-04-18 06:11:07 +02:00
|
|
|
let subtitle: String
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
var body: some View {
|
2026-04-18 06:11:07 +02:00
|
|
|
HStack(alignment: .top, spacing: 10) {
|
|
|
|
|
Image(systemName: systemImage)
|
|
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(watchAccent)
|
|
|
|
|
.frame(width: 18, height: 18)
|
|
|
|
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
|
|
|
Text(title)
|
|
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(.white)
|
|
|
|
|
|
|
|
|
|
Text(subtitle)
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
|
|
|
|
}
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private extension View {
|
|
|
|
|
func watchCard() -> some View {
|
|
|
|
|
padding(14)
|
|
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
|
.background(Color.white.opacity(0.08), in: RoundedRectangle(cornerRadius: 22, style: .continuous))
|
|
|
|
|
.overlay(
|
|
|
|
|
RoundedRectangle(cornerRadius: 22, style: .continuous)
|
|
|
|
|
.stroke(Color.white.opacity(0.10), lineWidth: 1)
|
|
|
|
|
)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchDashboardView: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
2026-04-18 06:11:07 +02:00
|
|
|
ScrollView {
|
|
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
2026-04-18 01:05:22 +02:00
|
|
|
WatchPassportCard(model: model)
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
WatchSectionHeader(
|
|
|
|
|
title: "Pending",
|
|
|
|
|
detail: model.pendingRequests.isEmpty ? nil : "\(model.pendingRequests.count)"
|
|
|
|
|
)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
if model.pendingRequests.isEmpty {
|
|
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
|
|
|
Text("No checks waiting.")
|
|
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(.white)
|
|
|
|
|
|
|
|
|
|
Text("New identity checks will appear here when a site or device asks you to prove it is really you.")
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
|
|
|
|
|
|
|
|
|
Button("Seed Identity Check") {
|
|
|
|
|
Task {
|
|
|
|
|
await model.simulateIncomingRequest()
|
|
|
|
|
}
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.buttonStyle(.bordered)
|
|
|
|
|
.tint(watchAccent)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
} else {
|
|
|
|
|
ForEach(model.pendingRequests) { request in
|
|
|
|
|
NavigationLink {
|
|
|
|
|
WatchRequestDetailView(model: model, requestID: request.id)
|
|
|
|
|
} label: {
|
|
|
|
|
WatchRequestRow(request: request)
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.buttonStyle(.plain)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
WatchSectionHeader(title: "Activity")
|
|
|
|
|
|
2026-04-18 01:05:22 +02:00
|
|
|
if model.notifications.isEmpty {
|
2026-04-18 06:11:07 +02:00
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
|
|
|
Text("No recent alerts.")
|
|
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(.white)
|
|
|
|
|
|
|
|
|
|
Text("Passport activity and security events will show up here.")
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
|
|
|
|
}
|
|
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
} else {
|
|
|
|
|
ForEach(model.notifications.prefix(3)) { notification in
|
|
|
|
|
NavigationLink {
|
|
|
|
|
WatchNotificationDetailView(model: model, notificationID: notification.id)
|
|
|
|
|
} label: {
|
|
|
|
|
WatchNotificationRow(notification: notification)
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.buttonStyle(.plain)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
WatchSectionHeader(title: "Actions")
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
|
|
|
Button("Refresh") {
|
|
|
|
|
Task {
|
|
|
|
|
await model.refreshDashboard()
|
|
|
|
|
}
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.buttonStyle(.bordered)
|
|
|
|
|
.tint(watchAccent)
|
|
|
|
|
.disabled(model.isRefreshing)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
Button("Send Test Alert") {
|
2026-04-18 01:05:22 +02:00
|
|
|
Task {
|
2026-04-18 06:11:07 +02:00
|
|
|
await model.sendTestNotification()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.buttonStyle(.bordered)
|
|
|
|
|
|
|
|
|
|
if model.notificationPermission == .unknown || model.notificationPermission == .denied {
|
|
|
|
|
Button("Enable Alerts") {
|
|
|
|
|
Task {
|
|
|
|
|
await model.requestNotificationAccess()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.buttonStyle(.bordered)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button("Sign Out", role: .destructive) {
|
|
|
|
|
model.signOut()
|
|
|
|
|
}
|
|
|
|
|
.buttonStyle(.bordered)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
if let profile = model.profile {
|
2026-04-18 06:11:07 +02:00
|
|
|
WatchSectionHeader(title: "Identity")
|
|
|
|
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
2026-04-18 01:05:22 +02:00
|
|
|
Text(profile.handle)
|
2026-04-18 06:11:07 +02:00
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
Text(profile.organization)
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
2026-04-18 01:05:22 +02:00
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
Text("Notifications: \(model.notificationPermission.title)")
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
|
|
|
|
}
|
|
|
|
|
.watchCard()
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.padding(.horizontal, 8)
|
|
|
|
|
.padding(.top, 12)
|
|
|
|
|
.padding(.bottom, 20)
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
2026-04-18 06:11:07 +02:00
|
|
|
.background(Color.black.ignoresSafeArea())
|
2026-04-18 01:05:22 +02:00
|
|
|
.navigationTitle("Passport")
|
|
|
|
|
.refreshable {
|
|
|
|
|
await model.refreshDashboard()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 06:11:07 +02:00
|
|
|
private struct WatchSectionHeader: View {
|
|
|
|
|
let title: String
|
|
|
|
|
var detail: String? = nil
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
|
|
|
|
Text(title)
|
|
|
|
|
.font(.headline)
|
|
|
|
|
.foregroundStyle(.white)
|
|
|
|
|
|
|
|
|
|
if let detail, !detail.isEmpty {
|
|
|
|
|
Text(detail)
|
|
|
|
|
.font(.caption2.weight(.semibold))
|
|
|
|
|
.foregroundStyle(.white.opacity(0.58))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.padding(.horizontal, 2)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 01:05:22 +02:00
|
|
|
private struct WatchPassportCard: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
VStack(alignment: .leading, spacing: 10) {
|
2026-04-18 06:11:07 +02:00
|
|
|
AppBadge(title: "Passport active", tone: watchAccent)
|
|
|
|
|
|
2026-04-18 01:05:22 +02:00
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
|
|
|
Text(model.profile?.name ?? "Preview Session")
|
|
|
|
|
.font(.headline)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
Text(model.pairedDeviceSummary)
|
|
|
|
|
.font(.footnote)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.72))
|
2026-04-18 01:05:22 +02:00
|
|
|
if let session = model.session {
|
|
|
|
|
Text("Via \(session.pairingTransport.title)")
|
|
|
|
|
.font(.caption2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.58))
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HStack(spacing: 8) {
|
|
|
|
|
WatchMetricPill(title: "Pending", value: "\(model.pendingRequests.count)", accent: watchAccent)
|
|
|
|
|
WatchMetricPill(title: "Unread", value: "\(model.unreadNotificationCount)", accent: watchGold)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.padding(.vertical, 6)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchMetricPill: View {
|
|
|
|
|
let title: String
|
|
|
|
|
let value: String
|
|
|
|
|
let accent: Color
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
|
|
|
Text(value)
|
|
|
|
|
.font(.headline.monospacedDigit())
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
Text(title)
|
|
|
|
|
.font(.caption2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.68))
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
.padding(.horizontal, 10)
|
|
|
|
|
.padding(.vertical, 8)
|
|
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
|
.background(accent.opacity(0.14), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchRequestRow: View {
|
|
|
|
|
let request: ApprovalRequest
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
|
|
|
HStack(alignment: .top, spacing: 6) {
|
|
|
|
|
Text(request.title)
|
|
|
|
|
.font(.headline)
|
|
|
|
|
.lineLimit(2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
Spacer(minLength: 6)
|
|
|
|
|
|
|
|
|
|
Image(systemName: request.risk == .elevated ? "exclamationmark.shield.fill" : "checkmark.shield.fill")
|
|
|
|
|
.foregroundStyle(request.risk == .elevated ? .orange : watchAccent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text(request.source)
|
|
|
|
|
.font(.footnote)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.72))
|
|
|
|
|
|
|
|
|
|
HStack(spacing: 8) {
|
|
|
|
|
AppStatusTag(title: request.risk.title, tone: request.risk == .routine ? watchAccent : .orange)
|
|
|
|
|
AppStatusTag(title: request.status.title, tone: request.status == .pending ? .orange : watchAccent)
|
|
|
|
|
}
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
Text(request.createdAt.watchRelativeString)
|
|
|
|
|
.font(.caption2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.58))
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchNotificationRow: View {
|
|
|
|
|
let notification: AppNotification
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
|
|
|
HStack(alignment: .top, spacing: 6) {
|
|
|
|
|
Text(notification.title)
|
|
|
|
|
.font(.headline)
|
|
|
|
|
.lineLimit(2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white)
|
2026-04-18 01:05:22 +02:00
|
|
|
|
|
|
|
|
Spacer(minLength: 6)
|
|
|
|
|
|
|
|
|
|
if notification.isUnread {
|
|
|
|
|
Circle()
|
|
|
|
|
.fill(watchAccent)
|
|
|
|
|
.frame(width: 8, height: 8)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text(notification.message)
|
|
|
|
|
.font(.footnote)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.72))
|
2026-04-18 01:05:22 +02:00
|
|
|
.lineLimit(2)
|
|
|
|
|
|
|
|
|
|
Text(notification.sentAt.watchRelativeString)
|
|
|
|
|
.font(.caption2)
|
2026-04-18 06:11:07 +02:00
|
|
|
.foregroundStyle(.white.opacity(0.58))
|
2026-04-18 01:05:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchRequestDetailView: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
let requestID: ApprovalRequest.ID
|
|
|
|
|
|
|
|
|
|
private var request: ApprovalRequest? {
|
|
|
|
|
model.requests.first(where: { $0.id == requestID })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
Group {
|
|
|
|
|
if let request {
|
|
|
|
|
ScrollView {
|
|
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
|
|
detailHeader(
|
|
|
|
|
title: request.title,
|
|
|
|
|
subtitle: request.source,
|
|
|
|
|
badge: request.status.title
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Text(request.subtitle)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
|
|
Text("Trust Summary")
|
|
|
|
|
.font(.headline)
|
|
|
|
|
Text(request.trustHeadline)
|
|
|
|
|
.font(.subheadline.weight(.semibold))
|
|
|
|
|
Text(request.trustDetail)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
Text(request.risk.guidance)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
}
|
|
|
|
|
.padding(10)
|
|
|
|
|
.background(.thinMaterial, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
|
|
|
|
|
|
|
|
|
|
if !request.scopes.isEmpty {
|
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
|
|
|
Text("Scopes")
|
|
|
|
|
.font(.headline)
|
|
|
|
|
|
|
|
|
|
ForEach(request.scopes, id: \.self) { scope in
|
|
|
|
|
Label(scope, systemImage: "checkmark.seal.fill")
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if request.status == .pending {
|
|
|
|
|
if model.activeRequestID == request.id {
|
|
|
|
|
ProgressView("Updating proof...")
|
|
|
|
|
} else {
|
|
|
|
|
Button("Verify") {
|
|
|
|
|
Task {
|
|
|
|
|
await model.approve(request)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.buttonStyle(.borderedProminent)
|
|
|
|
|
|
|
|
|
|
Button("Decline", role: .destructive) {
|
|
|
|
|
Task {
|
|
|
|
|
await model.reject(request)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.padding(.horizontal, 8)
|
|
|
|
|
.padding(.bottom, 20)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Text("This request is no longer available.")
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.navigationTitle("Identity Check")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func detailHeader(title: String, subtitle: String, badge: String) -> some View {
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
|
|
Text(title)
|
|
|
|
|
.font(.headline)
|
|
|
|
|
|
|
|
|
|
Text(subtitle)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
|
|
|
|
|
Text(badge)
|
|
|
|
|
.font(.caption.weight(.semibold))
|
|
|
|
|
.padding(.horizontal, 8)
|
|
|
|
|
.padding(.vertical, 4)
|
|
|
|
|
.background(watchAccent.opacity(0.14), in: Capsule())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private struct WatchNotificationDetailView: View {
|
|
|
|
|
@ObservedObject var model: AppViewModel
|
|
|
|
|
let notificationID: AppNotification.ID
|
|
|
|
|
|
|
|
|
|
private var notification: AppNotification? {
|
|
|
|
|
model.notifications.first(where: { $0.id == notificationID })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
Group {
|
|
|
|
|
if let notification {
|
|
|
|
|
ScrollView {
|
|
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
|
|
Text(notification.title)
|
|
|
|
|
.font(.headline)
|
|
|
|
|
Text(notification.kind.title)
|
|
|
|
|
.font(.footnote.weight(.semibold))
|
|
|
|
|
.foregroundStyle(watchAccent)
|
|
|
|
|
Text(notification.sentAt.watchRelativeString)
|
|
|
|
|
.font(.caption2)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text(notification.message)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
|
|
Text("Alert posture")
|
|
|
|
|
.font(.headline)
|
|
|
|
|
Text(model.notificationPermission.summary)
|
|
|
|
|
.font(.footnote)
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
}
|
|
|
|
|
.padding(10)
|
|
|
|
|
.background(.thinMaterial, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
|
|
|
|
|
|
|
|
|
|
if notification.isUnread {
|
|
|
|
|
Button("Mark Read") {
|
|
|
|
|
Task {
|
|
|
|
|
await model.markNotificationRead(notification)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.padding(.horizontal, 8)
|
|
|
|
|
.padding(.bottom, 20)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Text("This activity item has already been cleared.")
|
|
|
|
|
.foregroundStyle(.secondary)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.navigationTitle("Activity")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private extension Date {
|
|
|
|
|
var watchRelativeString: String {
|
|
|
|
|
WatchFormatters.relative.localizedString(for: self, relativeTo: .now)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private enum WatchFormatters {
|
|
|
|
|
static let relative: RelativeDateTimeFormatter = {
|
|
|
|
|
let formatter = RelativeDateTimeFormatter()
|
|
|
|
|
formatter.unitsStyle = .abbreviated
|
|
|
|
|
return formatter
|
|
|
|
|
}()
|
|
|
|
|
}
|