Commit ee19a31ad8

ee19a31ad88a13bb79f0c7f5d75ade4b027a1e43

parent: 0ab6464250

Unsigned

cmc <hello@cleberg.net> · 2026-10-26 02:09 UTC

Put the palette in a Theme carried in the environment (!46)

W13's customization axis, as the plan describes it: all **455** `Color(.appX)`
call sites in the app target resolve through a `Theme` in the environment, and
Settings → Display gains a Pro+ accent picker.

I argued for scoping this to the accent and you chose the full refactor, so this
is the full refactor — but built so the palette keeps the one job the narrower
version was meant to protect. The default theme resolves every token from
`Shared/Colors.xcassets`, so the catalog stays the single definition of every
default colour, and an accent overrides individual tokens rather than replacing
the set.

**How the whole palette moves, not just the part inside `body`.** `ThemeToken`
names a colour without resolving it. That matters because `AppStatusBadgeModel`
and `AppStatusTone` are built by plain functions — `AppStatusFactory` and the
per-row helpers — which cannot read the environment at all. They carry tokens
and `AppStatusBadgeView` resolves them when it draws.

**How this avoids 28 new `@Environment` properties.** A token conforms to
`ShapeStyle`, and `resolve(in:)` gets the environment, so in a style position it
needs nobody to resolve it. Exactly two kinds of site read the theme directly:
`listRowBackground`, which takes a view rather than a style and so has its own
small modifier, and the Dashboard's selected-card gradient, which needs real
`Color` values.

Helpers that mixed palette colours with SwiftUI's `.secondary`/`.primary` return
`AnyShapeStyle` now — wrapping a token keeps it resolving through the
environment, so those paths are themed rather than opted out.

**What the accent deliberately does not touch.** Only the accent tokens are
overridden. Status colours keep their palette values, because "critical" means
one thing and letting an accent recolour it would undo #21's phases 1–5 and
leave the palette no longer answerable for its own contrast.
`testAnAccentOverridesOnlyTheAccentTokens` enforces that.

**The one safety given up, and what replaces it.** Colours are looked up by name
rather than through the generated `ColorResource` symbols, because those are
MainActor-isolated and `ShapeStyle.resolve(in:)` is not. That loses compile-time
checking of the names, so `testEveryTokenHasAColorset` and
`testNoColorsetIsMissingAToken` read the colorsets off disk and check both
directions.

**Verification.** Rendering is unchanged where it must be: the default-theme
Dashboard screenshot is identical to the pre-refactor one in both appearances,
and `testTheDefaultThemeResolvesEveryTokenFromTheCatalog` asserts it token by
token. A launch with `forest` selected shows the Run button, toolbar icon and
caret green while every status colour stays put. 353 tests green on iOS 18.6 and
27.0. Ratchet unchanged at 280.

The widget target is untouched — a separate process with no access to the app's
environment, so its 28 sites stay on the asset catalog.

W13's other half, alternate app icons, still needs `CFBundleIcons` plus artwork
the project does not have.

`ThemeTests.swift` needed no `project.pbxproj` edit, which is !40's synchronized
group earning its keep.

Layout: unified · split

DomainDig/AppInfoView.swift +3 −3
@@ -163,7 +163,7 @@ private struct WhatsNewView: View {
163 } else { 163 } else {
164 Section { 164 Section {
165 Text("Release notes are unavailable.") 165 Text("Release notes are unavailable.")
166 .foregroundStyle(Color(.appTextSecondary)) 166 .foregroundStyle(ThemeToken.textSecondary)
167 } 167 }
168 } 168 }
169 } 169 }
@@ -188,7 +188,7 @@ private struct AcknowledgementsView: View {
188 Section("License") { 188 Section("License") {
189 Text("DomainDig is released under the MIT License.") 189 Text("DomainDig is released under the MIT License.")
190 Text(AppLinks.copyright) 190 Text(AppLinks.copyright)
191 .foregroundStyle(Color(.appTextSecondary)) 191 .foregroundStyle(ThemeToken.textSecondary)
192 } 192 }
193 } 193 }
194 .navigationTitle("Acknowledgements") 194 .navigationTitle("Acknowledgements")
@@ -211,7 +211,7 @@ private struct ReportIssueView: View {
211 Form { 211 Form {
212 Section { 212 Section {
213 Text("These details are included so issues can be reproduced. They are only added when you send a report — nothing is collected in the background.") 213 Text("These details are included so issues can be reproduced. They are only added when you send a report — nothing is collected in the background.")
214 .foregroundStyle(Color(.appTextSecondary)) 214 .foregroundStyle(ThemeToken.textSecondary)
215 } 215 }
216 216
217 Section("Included Diagnostics") { 217 Section("Included Diagnostics") {
DomainDig/AuditViews.swift +40 −40
@@ -27,7 +27,7 @@ struct AuditListView: View {
27 showsCardBackground: false 27 showsCardBackground: false
28 ) 28 )
29 } 29 }
30 .listRowBackground(Color(.appSurface)) 30 .themedListRowBackground(.surface)
31 } else { 31 } else {
32 Section("Audit Domains") { 32 Section("Audit Domains") {
33 ForEach(groupedSessions, id: \.domain) { group in 33 ForEach(groupedSessions, id: \.domain) { group in
@@ -41,13 +41,13 @@ struct AuditListView: View {
41 Spacer() 41 Spacer()
42 Text("\(group.sessions.count) audit\(group.sessions.count == 1 ? "" : "s")") 42 Text("\(group.sessions.count) audit\(group.sessions.count == 1 ? "" : "s")")
43 .font(appDensity.font(.caption2)) 43 .font(appDensity.font(.caption2))
44 .foregroundStyle(Color(.appTextSecondary)) 44 .foregroundStyle(ThemeToken.textSecondary)
45 } 45 }
46 46
47 if let latest = group.sessions.first { 47 if let latest = group.sessions.first {
48 Text(latest.findings.isEmpty ? "No findings recorded yet" : latest.findings.map(\.title).prefix(2).joined(separator: " • ")) 48 Text(latest.findings.isEmpty ? "No findings recorded yet" : latest.findings.map(\.title).prefix(2).joined(separator: " • "))
49 .font(appDensity.font(.caption)) 49 .font(appDensity.font(.caption))
50 .foregroundStyle(Color(.appTextSecondary)) 50 .foregroundStyle(ThemeToken.textSecondary)
51 .lineLimit(2) 51 .lineLimit(2)
52 52
53 HStack(spacing: 8) { 53 HStack(spacing: 8) {
@@ -57,7 +57,7 @@ struct AuditListView: View {
57 } 57 }
58 Text("Checklist \(latest.completedChecklistCount)/\(latest.checklist.count)") 58 Text("Checklist \(latest.completedChecklistCount)/\(latest.checklist.count)")
59 .font(appDensity.font(.caption2)) 59 .font(appDensity.font(.caption2))
60 .foregroundStyle(Color(.appTextSecondary)) 60 .foregroundStyle(ThemeToken.textSecondary)
61 } 61 }
62 } 62 }
63 } 63 }
@@ -65,11 +65,11 @@ struct AuditListView: View {
65 } 65 }
66 } 66 }
67 } 67 }
68 .listRowBackground(Color(.appSurface)) 68 .themedListRowBackground(.surface)
69 } 69 }
70 } 70 }
71 .scrollContentBackground(.hidden) 71 .scrollContentBackground(.hidden)
72 .background(Color(.appBackground)) 72 .background(ThemeToken.background)
73 .navigationTitle("Audit Mode") 73 .navigationTitle("Audit Mode")
74 .toolbar { 74 .toolbar {
75 if !viewModel.searchedDomain.isEmpty { 75 if !viewModel.searchedDomain.isEmpty {
@@ -115,7 +115,7 @@ struct AuditDomainTimelineView: View {
115 115
116 Text("Reviewer: \(session.reviewer)") 116 Text("Reviewer: \(session.reviewer)")
117 .font(appDensity.font(.caption)) 117 .font(appDensity.font(.caption))
118 .foregroundStyle(Color(.appTextSecondary)) 118 .foregroundStyle(ThemeToken.textSecondary)
119 119
120 HStack(spacing: 8) { 120 HStack(spacing: 8) {
121 Text("\(session.findings.count) findings") 121 Text("\(session.findings.count) findings")
@@ -125,13 +125,13 @@ struct AuditDomainTimelineView: View {
125 } 125 }
126 } 126 }
127 .font(appDensity.font(.caption2)) 127 .font(appDensity.font(.caption2))
128 .foregroundStyle(Color(.appTextSecondary)) 128 .foregroundStyle(ThemeToken.textSecondary)
129 } 129 }
130 .padding(.vertical, 4) 130 .padding(.vertical, 4)
131 } 131 }
132 } 132 }
133 } 133 }
134 .listRowBackground(Color(.appSurface)) 134 .themedListRowBackground(.surface)
135 135
136 Section("Trend") { 136 Section("Trend") {
137 ForEach(viewModel.auditTimeline(for: domain)) { point in 137 ForEach(viewModel.auditTimeline(for: domain)) { point in
@@ -142,19 +142,19 @@ struct AuditDomainTimelineView: View {
142 Spacer() 142 Spacer()
143 Text("\(point.findingCount) findings") 143 Text("\(point.findingCount) findings")
144 .font(appDensity.font(.caption2)) 144 .font(appDensity.font(.caption2))
145 .foregroundStyle(Color(.appTextSecondary)) 145 .foregroundStyle(ThemeToken.textSecondary)
146 } 146 }
147 Text("Open high severity: \(point.openHighSeverityCount) • Repeated issues: \(point.repeatedIssueCount)") 147 Text("Open high severity: \(point.openHighSeverityCount) • Repeated issues: \(point.repeatedIssueCount)")
148 .font(appDensity.font(.caption2)) 148 .font(appDensity.font(.caption2))
149 .foregroundStyle(Color(.appTextSecondary)) 149 .foregroundStyle(ThemeToken.textSecondary)
150 } 150 }
151 .padding(.vertical, 2) 151 .padding(.vertical, 2)
152 } 152 }
153 } 153 }
154 .listRowBackground(Color(.appSurface)) 154 .themedListRowBackground(.surface)
155 } 155 }
156 .scrollContentBackground(.hidden) 156 .scrollContentBackground(.hidden)
157 .background(Color(.appBackground)) 157 .background(ThemeToken.background)
158 .navigationTitle(domain) 158 .navigationTitle(domain)
159 .toolbar { 159 .toolbar {
160 ToolbarItem(placement: .topBarTrailing) { 160 ToolbarItem(placement: .topBarTrailing) {
@@ -196,7 +196,7 @@ struct AuditSessionDetailView: View {
196 .font(appDensity.font(.headline, design: .default, weight: .semibold)) 196 .font(appDensity.font(.headline, design: .default, weight: .semibold))
197 Text("Reviewer: \(session.reviewer)") 197 Text("Reviewer: \(session.reviewer)")
198 .font(appDensity.font(.caption)) 198 .font(appDensity.font(.caption))
199 .foregroundStyle(Color(.appTextSecondary)) 199 .foregroundStyle(ThemeToken.textSecondary)
200 } 200 }
201 Spacer() 201 Spacer()
202 auditStatusBadge(session.status) 202 auditStatusBadge(session.status)
@@ -214,10 +214,10 @@ struct AuditSessionDetailView: View {
214 214
215 Text("Captured \(session.evidence.capturedAt.formatted(date: .abbreviated, time: .shortened))") 215 Text("Captured \(session.evidence.capturedAt.formatted(date: .abbreviated, time: .shortened))")
216 .font(appDensity.font(.caption2)) 216 .font(appDensity.font(.caption2))
217 .foregroundStyle(Color(.appTextSecondary)) 217 .foregroundStyle(ThemeToken.textSecondary)
218 } 218 }
219 } 219 }
220 .listRowBackground(Color(.appSurface)) 220 .themedListRowBackground(.surface)
221 221
222 Section("Audit Summary") { 222 Section("Audit Summary") {
223 LabeledContent("Findings", value: "\(session.findings.count)") 223 LabeledContent("Findings", value: "\(session.findings.count)")
@@ -227,7 +227,7 @@ struct AuditSessionDetailView: View {
227 LabeledContent("Highest Severity", value: severity.title) 227 LabeledContent("Highest Severity", value: severity.title)
228 } 228 }
229 } 229 }
230 .listRowBackground(Color(.appSurface)) 230 .themedListRowBackground(.surface)
231 231
232 Section("Reviewer Notes") { 232 Section("Reviewer Notes") {
233 TextEditor(text: $notesDraft) 233 TextEditor(text: $notesDraft)
@@ -239,7 +239,7 @@ struct AuditSessionDetailView: View {
239 viewModel.updateAuditNotes(notesDraft, sessionID: session.id) 239 viewModel.updateAuditNotes(notesDraft, sessionID: session.id)
240 } 240 }
241 } 241 }
242 .listRowBackground(Color(.appSurface)) 242 .themedListRowBackground(.surface)
243 243
244 Section("Checklist") { 244 Section("Checklist") {
245 ForEach(session.checklist) { item in 245 ForEach(session.checklist) { item in
@@ -248,14 +248,14 @@ struct AuditSessionDetailView: View {
248 } label: { 248 } label: {
249 HStack(alignment: .top, spacing: 10) { 249 HStack(alignment: .top, spacing: 10) {
250 Image(systemName: item.isComplete ? "checkmark.circle.fill" : "circle") 250 Image(systemName: item.isComplete ? "checkmark.circle.fill" : "circle")
251 .foregroundStyle(item.isComplete ? Color(.statusPositive) : .secondary) 251 .foregroundStyle(item.isComplete ? AnyShapeStyle(ThemeToken.positive) : AnyShapeStyle(.secondary))
252 VStack(alignment: .leading, spacing: 4) { 252 VStack(alignment: .leading, spacing: 4) {
253 Text(item.title) 253 Text(item.title)
254 .font(appDensity.font(.callout)) 254 .font(appDensity.font(.callout))
255 .foregroundStyle(.primary) 255 .foregroundStyle(.primary)
256 Text(item.detail) 256 Text(item.detail)
257 .font(appDensity.font(.caption)) 257 .font(appDensity.font(.caption))
258 .foregroundStyle(Color(.appTextSecondary)) 258 .foregroundStyle(ThemeToken.textSecondary)
259 } 259 }
260 Spacer() 260 Spacer()
261 } 261 }
@@ -265,13 +265,13 @@ struct AuditSessionDetailView: View {
265 .accessibilityHint(item.isComplete ? "Marks incomplete" : "Marks complete") 265 .accessibilityHint(item.isComplete ? "Marks incomplete" : "Marks complete")
266 } 266 }
267 } 267 }
268 .listRowBackground(Color(.appSurface)) 268 .themedListRowBackground(.surface)
269 269
270 Section("Findings") { 270 Section("Findings") {
271 if session.findings.isEmpty { 271 if session.findings.isEmpty {
272 Text("No findings recorded.") 272 Text("No findings recorded.")
273 .font(appDensity.font(.caption)) 273 .font(appDensity.font(.caption))
274 .foregroundStyle(Color(.appTextSecondary)) 274 .foregroundStyle(ThemeToken.textSecondary)
275 } else { 275 } else {
276 ForEach(session.findings) { finding in 276 ForEach(session.findings) { finding in
277 Button { 277 Button {
@@ -287,11 +287,11 @@ struct AuditSessionDetailView: View {
287 } 287 }
288 Text(finding.summary) 288 Text(finding.summary)
289 .font(appDensity.font(.caption)) 289 .font(appDensity.font(.caption))
290 .foregroundStyle(Color(.appTextSecondary)) 290 .foregroundStyle(ThemeToken.textSecondary)
291 .lineLimit(2) 291 .lineLimit(2)
292 Text("\(finding.status.title) • \(finding.evidenceReferences.count) evidence refs") 292 Text("\(finding.status.title) • \(finding.evidenceReferences.count) evidence refs")
293 .font(appDensity.font(.caption2)) 293 .font(appDensity.font(.caption2))
294 .foregroundStyle(Color(.appTextSecondary)) 294 .foregroundStyle(ThemeToken.textSecondary)
295 } 295 }
296 .padding(.vertical, 2) 296 .padding(.vertical, 2)
297 } 297 }
@@ -302,7 +302,7 @@ struct AuditSessionDetailView: View {
302 } 302 }
303 } 303 }
304 } 304 }
305 .listRowBackground(Color(.appSurface)) 305 .themedListRowBackground(.surface)
306 306
307 Section("Evidence Snapshot") { 307 Section("Evidence Snapshot") {
308 LabeledContent("Availability", value: availabilityTitle(session.evidence.report.availability)) 308 LabeledContent("Availability", value: availabilityTitle(session.evidence.report.availability))
@@ -312,7 +312,7 @@ struct AuditSessionDetailView: View {
312 LabeledContent("Reachability", value: session.evidence.report.network.reachabilitySummary) 312 LabeledContent("Reachability", value: session.evidence.report.network.reachabilitySummary)
313 LabeledContent("Registrar", value: session.evidence.report.ownership?.registrar ?? "Unavailable") 313 LabeledContent("Registrar", value: session.evidence.report.ownership?.registrar ?? "Unavailable")
314 } 314 }
315 .listRowBackground(Color(.appSurface)) 315 .themedListRowBackground(.surface)
316 316
317 if !session.evidence.historicalContext.isEmpty { 317 if !session.evidence.historicalContext.isEmpty {
318 Section("Historical Context") { 318 Section("Historical Context") {
@@ -322,11 +322,11 @@ struct AuditSessionDetailView: View {
322 .font(appDensity.font(.caption, weight: .semibold)) 322 .font(appDensity.font(.caption, weight: .semibold))
323 Text(entry.changeSummaryMessage ?? "No change summary") 323 Text(entry.changeSummaryMessage ?? "No change summary")
324 .font(appDensity.font(.caption2)) 324 .font(appDensity.font(.caption2))
325 .foregroundStyle(Color(.appTextSecondary)) 325 .foregroundStyle(ThemeToken.textSecondary)
326 } 326 }
327 } 327 }
328 } 328 }
329 .listRowBackground(Color(.appSurface)) 329 .themedListRowBackground(.surface)
330 } 330 }
331 331
332 Section("Audit Timeline") { 332 Section("Audit Timeline") {
@@ -338,18 +338,18 @@ struct AuditSessionDetailView: View {
338 Spacer() 338 Spacer()
339 Text(point.status.title) 339 Text(point.status.title)
340 .font(appDensity.font(.caption2)) 340 .font(appDensity.font(.caption2))
341 .foregroundStyle(Color(.appTextSecondary)) 341 .foregroundStyle(ThemeToken.textSecondary)
342 } 342 }
343 Text("Findings \(point.findingCount) • Open high \(point.openHighSeverityCount) • Repeated \(point.repeatedIssueCount)") 343 Text("Findings \(point.findingCount) • Open high \(point.openHighSeverityCount) • Repeated \(point.repeatedIssueCount)")
344 .font(appDensity.font(.caption2)) 344 .font(appDensity.font(.caption2))
345 .foregroundStyle(Color(.appTextSecondary)) 345 .foregroundStyle(ThemeToken.textSecondary)
346 } 346 }
347 } 347 }
348 } 348 }
349 .listRowBackground(Color(.appSurface)) 349 .themedListRowBackground(.surface)
350 } 350 }
351 .scrollContentBackground(.hidden) 351 .scrollContentBackground(.hidden)
352 .background(Color(.appBackground)) 352 .background(ThemeToken.background)
353 .navigationTitle("Audit Session") 353 .navigationTitle("Audit Session")
354 .toolbar { 354 .toolbar {
355 ToolbarItemGroup(placement: .topBarTrailing) { 355 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -399,7 +399,7 @@ struct AuditSessionDetailView: View {
399 } 399 }
400 } else { 400 } else {
401 ContentUnavailableView("Audit Session Missing", systemImage: "exclamationmark.triangle") 401 ContentUnavailableView("Audit Session Missing", systemImage: "exclamationmark.triangle")
402 .background(Color(.appBackground)) 402 .background(ThemeToken.background)
403 } 403 }
404 } 404 }
405 } 405 }
@@ -459,7 +459,7 @@ private struct AuditFindingEditorView: View {
459 ForEach(session.evidence.screenshots) { asset in 459 ForEach(session.evidence.screenshots) { asset in
460 Text("\(asset.title): \(asset.reference)") 460 Text("\(asset.title): \(asset.reference)")
461 .font(.caption) 461 .font(.caption)
462 .foregroundStyle(Color(.appTextSecondary)) 462 .foregroundStyle(ThemeToken.textSecondary)
463 } 463 }
464 } 464 }
465 } 465 }
@@ -477,7 +477,7 @@ private struct AuditFindingEditorView: View {
477 Text(area.title) 477 Text(area.title)
478 Spacer() 478 Spacer()
479 Image(systemName: selectedAreas.contains(area) ? "checkmark.circle.fill" : "circle") 479 Image(systemName: selectedAreas.contains(area) ? "checkmark.circle.fill" : "circle")
480 .foregroundStyle(selectedAreas.contains(area) ? Color(.statusPositive) : .secondary) 480 .foregroundStyle(selectedAreas.contains(area) ? AnyShapeStyle(ThemeToken.positive) : AnyShapeStyle(.secondary))
481 } 481 }
482 } 482 }
483 .buttonStyle(.plain) 483 .buttonStyle(.plain)
@@ -529,11 +529,11 @@ private func auditStatusBadge(_ status: AuditStatus) -> some View {
529 let model: AppStatusBadgeModel 529 let model: AppStatusBadgeModel
530 switch status { 530 switch status {
531 case .draft: 531 case .draft:
532 model = .init(title: "Draft", systemImage: "square.and.pencil", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 532 model = .init(title: "Draft", systemImage: "square.and.pencil", foreground: .warning, background: .warningSurface)
533 case .inReview: 533 case .inReview:
534 model = .init(title: "In Review", systemImage: "doc.text.magnifyingglass", foregroundColor: Color(.statusInfo), backgroundColor: Color(.statusInfoSurface)) 534 model = .init(title: "In Review", systemImage: "doc.text.magnifyingglass", foreground: .info, background: .infoSurface)
535 case .complete: 535 case .complete:
536 model = .init(title: "Complete", systemImage: "checkmark.seal.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 536 model = .init(title: "Complete", systemImage: "checkmark.seal.fill", foreground: .positive, background: .positiveSurface)
537 } 537 }
538 return AppStatusBadgeView(model: model) 538 return AppStatusBadgeView(model: model)
539} 539}
@@ -554,8 +554,8 @@ private func findingSeverityBadge(_ severity: AuditFindingSeverity) -> some View
554 model: .init( 554 model: .init(
555 title: severity.title, 555 title: severity.title,
556 systemImage: "exclamationmark.circle.fill", 556 systemImage: "exclamationmark.circle.fill",
557 foregroundColor: tone.foreground, 557 foreground: tone.foreground,
558 backgroundColor: tone.surface 558 background: tone.surface
559 ) 559 )
560 ) 560 )
561} 561}
DomainDig/BatchResultsView.swift +17 −17
@@ -13,16 +13,16 @@ struct BatchResultsView: View {
13 if viewModel.batchLookupRunning { 13 if viewModel.batchLookupRunning {
14 VStack(alignment: .trailing, spacing: 4) { 14 VStack(alignment: .trailing, spacing: 4) {
15 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1))) 15 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1)))
16 .tint(Color(.statusInfo)) 16 .tint(ThemeToken.info)
17 .frame(width: 120) 17 .frame(width: 120)
18 Text(viewModel.batchProgressLabel) 18 Text(viewModel.batchProgressLabel)
19 .font(appDensity.font(.caption2)) 19 .font(appDensity.font(.caption2))
20 .foregroundStyle(Color(.appTextSecondary)) 20 .foregroundStyle(ThemeToken.textSecondary)
21 } 21 }
22 } else if !viewModel.batchResults.isEmpty { 22 } else if !viewModel.batchResults.isEmpty {
23 Text("\(viewModel.batchResults.count) domains") 23 Text("\(viewModel.batchResults.count) domains")
24 .font(appDensity.font(.caption2)) 24 .font(appDensity.font(.caption2))
25 .foregroundStyle(Color(.appTextSecondary)) 25 .foregroundStyle(ThemeToken.textSecondary)
26 } 26 }
27 } 27 }
28 28
@@ -86,7 +86,7 @@ struct BatchResultRowView: View {
86 } 86 }
87 } 87 }
88 .font(appDensity.font(.caption2)) 88 .font(appDensity.font(.caption2))
89 .foregroundStyle(Color(.appTextSecondary)) 89 .foregroundStyle(ThemeToken.textSecondary)
90 90
91 HStack(spacing: 10) { 91 HStack(spacing: 10) {
92 Text(result.primaryIP ?? "No IP") 92 Text(result.primaryIP ?? "No IP")
@@ -99,12 +99,12 @@ struct BatchResultRowView: View {
99 .lineLimit(1) 99 .lineLimit(1)
100 } 100 }
101 .font(appDensity.font(.caption2)) 101 .font(appDensity.font(.caption2))
102 .foregroundStyle(Color(.appTextSecondary)) 102 .foregroundStyle(ThemeToken.textSecondary)
103 103
104 if let summaryMessage = result.summaryMessage { 104 if let summaryMessage = result.summaryMessage {
105 Text(summaryMessage) 105 Text(summaryMessage)
106 .font(appDensity.font(.caption2)) 106 .font(appDensity.font(.caption2))
107 .foregroundStyle(Color(.appTextSecondary)) 107 .foregroundStyle(ThemeToken.textSecondary)
108 } 108 }
109 109
110 if let changeClassification = result.changeClassification { 110 if let changeClassification = result.changeClassification {
@@ -116,7 +116,7 @@ struct BatchResultRowView: View {
116 if let errorMessage = result.errorMessage { 116 if let errorMessage = result.errorMessage {
117 Text(errorMessage) 117 Text(errorMessage)
118 .font(appDensity.font(.caption2)) 118 .font(appDensity.font(.caption2))
119 .foregroundStyle(result.status == .failed ? Color(.statusCritical) : Color(.appTextSecondary)) 119 .foregroundStyle(result.status == .failed ? ThemeToken.critical : ThemeToken.textSecondary)
120 } 120 }
121 } 121 }
122 .frame(maxWidth: .infinity, alignment: .leading) 122 .frame(maxWidth: .infinity, alignment: .leading)
@@ -151,7 +151,7 @@ struct BatchResultRowView: View {
151 private var sourceLabel: some View { 151 private var sourceLabel: some View {
152 Text(result.resultSource.label.lowercased()) 152 Text(result.resultSource.label.lowercased())
153 .font(appDensity.font(.caption2)) 153 .font(appDensity.font(.caption2))
154 .foregroundStyle(Color(.appTextSecondary)) 154 .foregroundStyle(ThemeToken.textSecondary)
155 } 155 }
156 156
157 private var changeContentLabel: String { 157 private var changeContentLabel: String {
@@ -191,30 +191,30 @@ struct BatchResultRowView: View {
191 return .init( 191 return .init(
192 title: availabilityText, 192 title: availabilityText,
193 systemImage: "exclamationmark.circle", 193 systemImage: "exclamationmark.circle",
194 foregroundColor: Color(.appTextSecondary), 194 foreground: .textSecondary,
195 backgroundColor: Color(.appSurfaceElevated) 195 background: .surfaceElevated
196 ) 196 )
197 } 197 }
198 198
199 private var quickStatusBadge: AppStatusBadgeModel { 199 private var quickStatusBadge: AppStatusBadgeModel {
200 switch result.status { 200 switch result.status {
201 case .pending: 201 case .pending:
202 return .init(title: "Pending", systemImage: "clock", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 202 return .init(title: "Pending", systemImage: "clock", foreground: .textSecondary, background: .surfaceElevated)
203 case .running: 203 case .running:
204 return .init(title: "Running", systemImage: "arrow.clockwise", foregroundColor: Color(.statusInfo), backgroundColor: Color(.statusInfoSurface)) 204 return .init(title: "Running", systemImage: "arrow.clockwise", foreground: .info, background: .infoSurface)
205 case .completed: 205 case .completed:
206 if result.changeClassification == .critical || result.certificateWarningLevel == .critical || result.riskLevel == .high { 206 if result.changeClassification == .critical || result.certificateWarningLevel == .critical || result.riskLevel == .high {
207 return .init(title: "Critical", systemImage: "exclamationmark.octagon.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 207 return .init(title: "Critical", systemImage: "exclamationmark.octagon.fill", foreground: .critical, background: .criticalSurface)
208 } 208 }
209 if result.changeClassification == .warning || result.changeSeverity == .medium || result.certificateWarningLevel == .warning { 209 if result.changeClassification == .warning || result.changeSeverity == .medium || result.certificateWarningLevel == .warning {
210 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 210 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
211 } 211 }
212 if result.quickStatus == "Changed" { 212 if result.quickStatus == "Changed" {
213 return .init(title: "Changed", systemImage: "arrow.triangle.2.circlepath", foregroundColor: Color(.statusInfo), backgroundColor: Color(.statusInfoSurface)) 213 return .init(title: "Changed", systemImage: "arrow.triangle.2.circlepath", foreground: .info, background: .infoSurface)
214 } 214 }
215 return .init(title: "Stable", systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 215 return .init(title: "Stable", systemImage: "checkmark.circle.fill", foreground: .positive, background: .positiveSurface)
216 case .failed: 216 case .failed:
217 return .init(title: "Failed", systemImage: "xmark.circle.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 217 return .init(title: "Failed", systemImage: "xmark.circle.fill", foreground: .critical, background: .criticalSurface)
218 } 218 }
219 } 219 }
220} 220}
DomainDig/BatchSweepSummaryView.swift +2 −2
@@ -43,7 +43,7 @@ struct BatchSweepSummaryView: View {
43 HStack { 43 HStack {
44 Text(label) 44 Text(label)
45 .font(.system(.caption, design: .monospaced)) 45 .font(.system(.caption, design: .monospaced))
46 .foregroundStyle(Color(.appTextSecondary)) 46 .foregroundStyle(ThemeToken.textSecondary)
47 Spacer() 47 Spacer()
48 Text(value) 48 Text(value)
49 .font(.system(.callout, design: .monospaced)) 49 .font(.system(.callout, design: .monospaced))
@@ -65,7 +65,7 @@ struct BatchResultsSection: View {
65 if results.isEmpty { 65 if results.isEmpty {
66 Text(emptyText) 66 Text(emptyText)
67 .font(.system(.caption, design: .monospaced)) 67 .font(.system(.caption, design: .monospaced))
68 .foregroundStyle(Color(.appTextSecondary)) 68 .foregroundStyle(ThemeToken.textSecondary)
69 } else { 69 } else {
70 ForEach(results) { result in 70 ForEach(results) { result in
71 if let entry = viewModel.historyEntry(for: result) { 71 if let entry = viewModel.historyEntry(for: result) {
DomainDig/ContentView.swift +18 −18
@@ -120,10 +120,10 @@ struct ContentView: View {
120 Section { recentSearchesSection } 120 Section { recentSearchesSection }
121 } 121 }
122 } 122 }
123 .listRowBackground(Color(.appSurface)) 123 .themedListRowBackground(.surface)
124 .environment(\.cardProvidesSurface, false) 124 .environment(\.cardProvidesSurface, false)
125 .scrollContentBackground(.hidden) 125 .scrollContentBackground(.hidden)
126 .background(Color(.appBackground)) 126 .background(ThemeToken.background)
127 .navigationTitle("DomainDig") 127 .navigationTitle("DomainDig")
128 .toolbar { 128 .toolbar {
129 ToolbarItem(placement: .topBarTrailing) { 129 ToolbarItem(placement: .topBarTrailing) {
@@ -140,7 +140,7 @@ struct ContentView: View {
140 viewModel.reset() 140 viewModel.reset()
141 } label: { 141 } label: {
142 Image(systemName: "xmark.circle") 142 Image(systemName: "xmark.circle")
143 .foregroundStyle(Color(.appTextSecondary)) 143 .foregroundStyle(ThemeToken.textSecondary)
144 } 144 }
145 .accessibilityLabel("Clear results") 145 .accessibilityLabel("Clear results")
146 } 146 }
@@ -280,7 +280,7 @@ struct ContentView: View {
280 .keyboardType(.URL) 280 .keyboardType(.URL)
281 .padding(.horizontal, 12) 281 .padding(.horizontal, 12)
282 .padding(.vertical, appDensity.metrics.controlVerticalPadding) 282 .padding(.vertical, appDensity.metrics.controlVerticalPadding)
283 .background(Color(.appSurfaceElevated)) 283 .background(ThemeToken.surfaceElevated)
284 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 284 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
285 .focused($focusedInputField, equals: .singleDomain) 285 .focused($focusedInputField, equals: .singleDomain)
286 .onSubmit { 286 .onSubmit {
@@ -291,7 +291,7 @@ struct ContentView: View {
291 if let domainInputError = viewModel.domainInputError { 291 if let domainInputError = viewModel.domainInputError {
292 Text(domainInputError) 292 Text(domainInputError)
293 .font(appDensity.font(.caption)) 293 .font(appDensity.font(.caption))
294 .foregroundStyle(Color(.statusCritical)) 294 .foregroundStyle(ThemeToken.critical)
295 .frame(maxWidth: .infinity, alignment: .leading) 295 .frame(maxWidth: .infinity, alignment: .leading)
296 } 296 }
297 297
@@ -305,19 +305,19 @@ struct ContentView: View {
305 .frame(minHeight: appDensity.metrics.controlMinHeight) 305 .frame(minHeight: appDensity.metrics.controlMinHeight)
306 } 306 }
307 .buttonStyle(.borderedProminent) 307 .buttonStyle(.borderedProminent)
308 .tint(Color(.accentFill)) 308 .tint(ThemeToken.accent)
309 .disabled(viewModel.trimmedDomain.isEmpty) 309 .disabled(viewModel.trimmedDomain.isEmpty)
310 } else { 310 } else {
311 if FeatureAccessService.hasAccess(to: .batchOperations) { 311 if FeatureAccessService.hasAccess(to: .batchOperations) {
312 VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) { 312 VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) {
313 Text("Paste domains separated by new lines or commas.") 313 Text("Paste domains separated by new lines or commas.")
314 .font(appDensity.font(.caption)) 314 .font(appDensity.font(.caption))
315 .foregroundStyle(Color(.appTextSecondary)) 315 .foregroundStyle(ThemeToken.textSecondary)
316 316
317 if let batchAllowanceSummary = FeatureAccessService.batchAllowanceSummary() { 317 if let batchAllowanceSummary = FeatureAccessService.batchAllowanceSummary() {
318 Text(batchAllowanceSummary) 318 Text(batchAllowanceSummary)
319 .font(appDensity.font(.caption2)) 319 .font(appDensity.font(.caption2))
320 .foregroundStyle(Color(.appTextSecondary)) 320 .foregroundStyle(ThemeToken.textSecondary)
321 } 321 }
322 322
323 TextField( 323 TextField(
@@ -332,14 +332,14 @@ struct ContentView: View {
332 .lineLimit(4...10) 332 .lineLimit(4...10)
333 .padding(.horizontal, 12) 333 .padding(.horizontal, 12)
334 .padding(.vertical, appDensity.metrics.controlVerticalPadding) 334 .padding(.vertical, appDensity.metrics.controlVerticalPadding)
335 .background(Color(.appSurfaceElevated)) 335 .background(ThemeToken.surfaceElevated)
336 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 336 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
337 .focused($focusedInputField, equals: .bulkDomains) 337 .focused($focusedInputField, equals: .bulkDomains)
338 338
339 if let bulkInputError = viewModel.bulkInputError { 339 if let bulkInputError = viewModel.bulkInputError {
340 Text(bulkInputError) 340 Text(bulkInputError)
341 .font(appDensity.font(.caption)) 341 .font(appDensity.font(.caption))
342 .foregroundStyle(Color(.statusCritical)) 342 .foregroundStyle(ThemeToken.critical)
343 .frame(maxWidth: .infinity, alignment: .leading) 343 .frame(maxWidth: .infinity, alignment: .leading)
344 } 344 }
345 345
@@ -353,7 +353,7 @@ struct ContentView: View {
353 .frame(minHeight: appDensity.metrics.controlMinHeight) 353 .frame(minHeight: appDensity.metrics.controlMinHeight)
354 } 354 }
355 .buttonStyle(.borderedProminent) 355 .buttonStyle(.borderedProminent)
356 .tint(Color(.accentFill)) 356 .tint(ThemeToken.accent)
357 .disabled(viewModel.bulkInput.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || viewModel.batchLookupRunning) 357 .disabled(viewModel.bulkInput.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || viewModel.batchLookupRunning)
358 } 358 }
359 } else { 359 } else {
@@ -529,7 +529,7 @@ struct ContentView: View {
529 } label: { 529 } label: {
530 Image(systemName: "bolt.circle") 530 Image(systemName: "bolt.circle")
531 .font(appDensity.font(.body, design: .default)) 531 .font(appDensity.font(.body, design: .default))
532 .foregroundStyle(Color(.appTextSecondary)) 532 .foregroundStyle(ThemeToken.textSecondary)
533 } 533 }
534 .accessibilityLabel("Actions") 534 .accessibilityLabel("Actions")
535 Menu { 535 Menu {
@@ -537,7 +537,7 @@ struct ContentView: View {
537 } label: { 537 } label: {
538 Image(systemName: "square.and.arrow.up") 538 Image(systemName: "square.and.arrow.up")
539 .font(appDensity.font(.body, design: .default)) 539 .font(appDensity.font(.body, design: .default))
540 .foregroundStyle(Color(.appTextSecondary)) 540 .foregroundStyle(ThemeToken.textSecondary)
541 } 541 }
542 .accessibilityLabel("Export") 542 .accessibilityLabel("Export")
543 } 543 }
@@ -582,13 +582,13 @@ struct ContentView: View {
582 HStack { 582 HStack {
583 Text("RECENT") 583 Text("RECENT")
584 .font(appDensity.font(.caption2)) 584 .font(appDensity.font(.caption2))
585 .foregroundStyle(Color(.appTextSecondary)) 585 .foregroundStyle(ThemeToken.textSecondary)
586 Spacer() 586 Spacer()
587 Button("Clear") { 587 Button("Clear") {
588 viewModel.clearRecentSearches() 588 viewModel.clearRecentSearches()
589 } 589 }
590 .font(appDensity.font(.caption2)) 590 .font(appDensity.font(.caption2))
591 .foregroundStyle(Color(.appTextSecondary)) 591 .foregroundStyle(ThemeToken.textSecondary)
592 } 592 }
593 593
594 ForEach(viewModel.recentSearches, id: \.self) { domain in 594 ForEach(viewModel.recentSearches, id: \.self) { domain in
@@ -603,7 +603,7 @@ struct ContentView: View {
603 .frame(maxWidth: .infinity, alignment: .leading) 603 .frame(maxWidth: .infinity, alignment: .leading)
604 .padding(.vertical, 8) 604 .padding(.vertical, 8)
605 .padding(.horizontal, 10) 605 .padding(.horizontal, 10)
606 .background(Color(.appSurface)) 606 .background(ThemeToken.surface)
607 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 607 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
608 } 608 }
609 } 609 }
@@ -624,11 +624,11 @@ struct ContentView: View {
624 .font(appDensity.font(.headline, design: .default, weight: .semibold)) 624 .font(appDensity.font(.headline, design: .default, weight: .semibold))
625 Text(message) 625 Text(message)
626 .font(appDensity.font(.callout, design: .default)) 626 .font(appDensity.font(.callout, design: .default))
627 .foregroundStyle(Color(.appTextSecondary)) 627 .foregroundStyle(ThemeToken.textSecondary)
628 } 628 }
629 .frame(maxWidth: .infinity, alignment: .leading) 629 .frame(maxWidth: .infinity, alignment: .leading)
630 .padding(appDensity.metrics.cardPadding) 630 .padding(appDensity.metrics.cardPadding)
631 .background(Color(.appSurfaceElevated)) 631 .background(ThemeToken.surfaceElevated)
632 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 632 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
633 } 633 }
634 634
DomainDig/DNSSectionView.swift +7 −7
@@ -64,7 +64,7 @@ struct DNSSectionView: View {
64 Text(section.title) 64 Text(section.title)
65 .font(.system(.subheadline, design: .monospaced)) 65 .font(.system(.subheadline, design: .monospaced))
66 .fontWeight(.semibold) 66 .fontWeight(.semibold)
67 .foregroundStyle(Color(.statusInfo)) 67 .foregroundStyle(ThemeToken.info)
68 68
69 if let message = section.message { 69 if let message = section.message {
70 MessageRowView(text: message.text, isError: message.isError) 70 MessageRowView(text: message.text, isError: message.isError)
@@ -77,7 +77,7 @@ struct DNSSectionView: View {
77 if let wildcardTitle = section.wildcardTitle { 77 if let wildcardTitle = section.wildcardTitle {
78 Text(wildcardTitle) 78 Text(wildcardTitle)
79 .font(.system(.caption, design: .monospaced)) 79 .font(.system(.caption, design: .monospaced))
80 .foregroundStyle(Color(.appTextSecondary)) 80 .foregroundStyle(ThemeToken.textSecondary)
81 .padding(.top, 4) 81 .padding(.top, 4)
82 ForEach(section.wildcardRows) { row in 82 ForEach(section.wildcardRows) { row in
83 LabeledValueRow(row: row) 83 LabeledValueRow(row: row)
@@ -91,7 +91,7 @@ struct DNSSectionView: View {
91 Text("PTR") 91 Text("PTR")
92 .font(.system(.subheadline, design: .monospaced)) 92 .font(.system(.subheadline, design: .monospaced))
93 .fontWeight(.semibold) 93 .fontWeight(.semibold)
94 .foregroundStyle(Color(.statusInfo)) 94 .foregroundStyle(ThemeToken.info)
95 SectionTrustMetadataView(provenance: ptrProvenance, confidence: nil) 95 SectionTrustMetadataView(provenance: ptrProvenance, confidence: nil)
96 MessageRowView(text: ptrMessage.text, isError: ptrMessage.isError) 96 MessageRowView(text: ptrMessage.text, isError: ptrMessage.isError)
97 } 97 }
@@ -101,7 +101,7 @@ struct DNSSectionView: View {
101 HStack { 101 HStack {
102 Text("History") 102 Text("History")
103 .font(appDensity.font(.subheadline, weight: .semibold)) 103 .font(appDensity.font(.subheadline, weight: .semibold))
104 .foregroundStyle(Color(.statusInfo)) 104 .foregroundStyle(ThemeToken.info)
105 Spacer() 105 Spacer()
106 if let onLoadHistory, history.isEmpty, !historyLoading { 106 if let onLoadHistory, history.isEmpty, !historyLoading {
107 Button("Load") { 107 Button("Load") {
@@ -127,18 +127,18 @@ struct DNSSectionView: View {
127 VStack(alignment: .leading, spacing: 3) { 127 VStack(alignment: .leading, spacing: 3) {
128 Text(event.date.formatted(date: .abbreviated, time: .omitted)) 128 Text(event.date.formatted(date: .abbreviated, time: .omitted))
129 .font(appDensity.font(.caption2)) 129 .font(appDensity.font(.caption2))
130 .foregroundStyle(Color(.appTextSecondary)) 130 .foregroundStyle(ThemeToken.textSecondary)
131 Text(event.summary) 131 Text(event.summary)
132 .font(appDensity.font(.caption)) 132 .font(appDensity.font(.caption))
133 if !event.aRecords.isEmpty { 133 if !event.aRecords.isEmpty {
134 Text("A: \(event.aRecords.joined(separator: ", "))") 134 Text("A: \(event.aRecords.joined(separator: ", "))")
135 .font(appDensity.font(.caption2)) 135 .font(appDensity.font(.caption2))
136 .foregroundStyle(Color(.appTextSecondary)) 136 .foregroundStyle(ThemeToken.textSecondary)
137 } 137 }
138 if !event.nameservers.isEmpty { 138 if !event.nameservers.isEmpty {
139 Text("NS: \(event.nameservers.joined(separator: ", "))") 139 Text("NS: \(event.nameservers.joined(separator: ", "))")
140 .font(appDensity.font(.caption2)) 140 .font(appDensity.font(.caption2))
141 .foregroundStyle(Color(.appTextSecondary)) 141 .foregroundStyle(ThemeToken.textSecondary)
142 } 142 }
143 } 143 }
144 } 144 }
DomainDig/DashboardView.swift +41 −38
@@ -2,6 +2,9 @@ import SwiftUI
2 2
3struct DashboardView: View { 3struct DashboardView: View {
4 @Environment(\.appDensity) private var appDensity 4 @Environment(\.appDensity) private var appDensity
5 // Read directly because the selected card's gradient needs `Color` values
6 // rather than styles.
7 @Environment(\.theme) private var theme
5 @Environment(\.accessibilityDifferentiateWithoutColor) private var differentiateWithoutColor 8 @Environment(\.accessibilityDifferentiateWithoutColor) private var differentiateWithoutColor
6 @Bindable var viewModel: DomainViewModel 9 @Bindable var viewModel: DomainViewModel
7 @State private var collapsedGroups = Set<String>() 10 @State private var collapsedGroups = Set<String>()
@@ -31,20 +34,20 @@ struct DashboardView: View {
31 showsCardBackground: false 34 showsCardBackground: false
32 ) 35 )
33 } 36 }
34 .listRowBackground(Color(.appSurface)) 37 .themedListRowBackground(.surface)
35 } else { 38 } else {
36 Section { 39 Section {
37 LazyVGrid(columns: summaryColumns, spacing: 10) { 40 LazyVGrid(columns: summaryColumns, spacing: 10) {
38 summaryCard(title: "Total Domains", value: dashboard.snapshot.totalDomains, filter: .all, tint: Color(.statusInfo)) 41 summaryCard(title: "Total Domains", value: dashboard.snapshot.totalDomains, filter: .all, tint: .info)
39 summaryCard(title: "Healthy", value: dashboard.snapshot.healthyCount, filter: .healthy, tint: Color(.statusPositive)) 42 summaryCard(title: "Healthy", value: dashboard.snapshot.healthyCount, filter: .healthy, tint: .positive)
40 summaryCard(title: "Warning", value: dashboard.snapshot.warningCount, filter: .warning, tint: Color(.statusWarning)) 43 summaryCard(title: "Warning", value: dashboard.snapshot.warningCount, filter: .warning, tint: .warning)
41 summaryCard(title: "Critical", value: dashboard.snapshot.criticalCount, filter: .critical, tint: Color(.statusCritical)) 44 summaryCard(title: "Critical", value: dashboard.snapshot.criticalCount, filter: .critical, tint: .critical)
42 summaryCard(title: "Changes (24h)", value: dashboard.snapshot.changedLast24h, filter: .changed, tint: Color(.statusWarning)) 45 summaryCard(title: "Changes (24h)", value: dashboard.snapshot.changedLast24h, filter: .changed, tint: .warning)
43 summaryCard(title: "Unreachable", value: dashboard.snapshot.unreachableCount, filter: .unreachable, tint: Color(.statusCritical)) 46 summaryCard(title: "Unreachable", value: dashboard.snapshot.unreachableCount, filter: .unreachable, tint: .critical)
44 } 47 }
45 .padding(.vertical, 4) 48 .padding(.vertical, 4)
46 } 49 }
47 .listRowBackground(Color(.appSurface)) 50 .themedListRowBackground(.surface)
48 51
49 Section("Quick Filters") { 52 Section("Quick Filters") {
50 ScrollView(.horizontal, showsIndicators: false) { 53 ScrollView(.horizontal, showsIndicators: false) {
@@ -66,10 +69,10 @@ struct DashboardView: View {
66 Text(filter.title) 69 Text(filter.title)
67 .font(appDensity.font(.caption, weight: .semibold)) 70 .font(appDensity.font(.caption, weight: .semibold))
68 } 71 }
69 .foregroundStyle(isSelected ? Color(.appOnAccent) : Color.primary) 72 .foregroundStyle(isSelected ? AnyShapeStyle(ThemeToken.onAccent) : AnyShapeStyle(.primary))
70 .padding(.horizontal, 12) 73 .padding(.horizontal, 12)
71 .padding(.vertical, 8) 74 .padding(.vertical, 8)
72 .background(isSelected ? Color(.statusInfo) : Color(.appSurfaceElevated)) 75 .background(isSelected ? ThemeToken.info : ThemeToken.surfaceElevated)
73 .overlay( 76 .overlay(
74 Capsule().strokeBorder( 77 Capsule().strokeBorder(
75 Color.primary, 78 Color.primary,
@@ -85,7 +88,7 @@ struct DashboardView: View {
85 .padding(.vertical, 4) 88 .padding(.vertical, 4)
86 } 89 }
87 } 90 }
88 .listRowBackground(Color(.appSurface)) 91 .themedListRowBackground(.surface)
89 92
90 Section("Recent Activity") { 93 Section("Recent Activity") {
91 if visible.recentActivity.isEmpty { 94 if visible.recentActivity.isEmpty {
@@ -98,7 +101,7 @@ struct DashboardView: View {
98 } 101 }
99 } 102 }
100 } 103 }
101 .listRowBackground(Color(.appSurface)) 104 .themedListRowBackground(.surface)
102 105
103 Section("Attention Required") { 106 Section("Attention Required") {
104 if visible.attentionRequired.isEmpty { 107 if visible.attentionRequired.isEmpty {
@@ -111,7 +114,7 @@ struct DashboardView: View {
111 } 114 }
112 } 115 }
113 } 116 }
114 .listRowBackground(Color(.appSurface)) 117 .themedListRowBackground(.surface)
115 118
116 Section("Expiring Soon") { 119 Section("Expiring Soon") {
117 if visible.expiringSoon.isEmpty { 120 if visible.expiringSoon.isEmpty {
@@ -127,7 +130,7 @@ struct DashboardView: View {
127 } 130 }
128 } 131 }
129 } 132 }
130 .listRowBackground(Color(.appSurface)) 133 .themedListRowBackground(.surface)
131 134
132 Section("Portfolio List") { 135 Section("Portfolio List") {
133 if visible.groups.isEmpty { 136 if visible.groups.isEmpty {
@@ -156,7 +159,7 @@ struct DashboardView: View {
156 .font(appDensity.font(.headline, design: .default, weight: .semibold)) 159 .font(appDensity.font(.headline, design: .default, weight: .semibold))
157 Text("\(group.domains.count) domain\(group.domains.count == 1 ? "" : "s")") 160 Text("\(group.domains.count) domain\(group.domains.count == 1 ? "" : "s")")
158 .font(appDensity.font(.caption)) 161 .font(appDensity.font(.caption))
159 .foregroundStyle(Color(.appTextSecondary)) 162 .foregroundStyle(ThemeToken.textSecondary)
160 } 163 }
161 Spacer() 164 Spacer()
162 groupBadge(for: group.domains) 165 groupBadge(for: group.domains)
@@ -167,11 +170,11 @@ struct DashboardView: View {
167 } 170 }
168 } 171 }
169 } 172 }
170 .listRowBackground(Color(.appSurface)) 173 .themedListRowBackground(.surface)
171 } 174 }
172 } 175 }
173 .scrollContentBackground(.hidden) 176 .scrollContentBackground(.hidden)
174 .background(Color(.appBackground)) 177 .background(ThemeToken.background)
175 .navigationTitle("Dashboard") 178 .navigationTitle("Dashboard")
176 .searchable(text: $viewModel.dashboardSearchText, prompt: "Search portfolio") 179 .searchable(text: $viewModel.dashboardSearchText, prompt: "Search portfolio")
177 .toolbar { 180 .toolbar {
@@ -213,14 +216,14 @@ struct DashboardView: View {
213 ) 216 )
214 } 217 }
215 218
216 private func summaryCard(title: String, value: Int, filter: PortfolioFilterOption, tint: Color) -> some View { 219 private func summaryCard(title: String, value: Int, filter: PortfolioFilterOption, tint: ThemeToken) -> some View {
217 Button { 220 Button {
218 viewModel.dashboardFilter = filter 221 viewModel.dashboardFilter = filter
219 } label: { 222 } label: {
220 VStack(alignment: .leading, spacing: 8) { 223 VStack(alignment: .leading, spacing: 8) {
221 Text(title) 224 Text(title)
222 .font(appDensity.font(.caption, design: .default, weight: .semibold)) 225 .font(appDensity.font(.caption, design: .default, weight: .semibold))
223 .foregroundStyle(Color(.appTextSecondary)) 226 .foregroundStyle(ThemeToken.textSecondary)
224 Text("\(value)") 227 Text("\(value)")
225 // Was a fixed 28pt, which ignored Dynamic Type entirely. 228 // Was a fixed 28pt, which ignored Dynamic Type entirely.
226 .font(.system(.title, design: .rounded, weight: .bold)) 229 .font(.system(.title, design: .rounded, weight: .bold))
@@ -270,13 +273,13 @@ struct DashboardView: View {
270 // trick into light mode. 273 // trick into light mode.
271 return AnyShapeStyle( 274 return AnyShapeStyle(
272 LinearGradient( 275 LinearGradient(
273 colors: [Color(.statusInfoSurface), Color(.appSurface)], 276 colors: [theme[.infoSurface], theme[.surface]],
274 startPoint: .topLeading, 277 startPoint: .topLeading,
275 endPoint: .bottomTrailing 278 endPoint: .bottomTrailing
276 ) 279 )
277 ) 280 )
278 } 281 }
279 return AnyShapeStyle(Color(.appSurfaceElevated)) 282 return AnyShapeStyle(ThemeToken.surfaceElevated)
280 } 283 }
281 284
282 /// `label`, opening the tracked domain's detail; nothing for a domain no longer tracked. 285 /// `label`, opening the tracked domain's detail; nothing for a domain no longer tracked.
@@ -295,7 +298,7 @@ struct DashboardView: View {
295 private func dashboardEmptyRow(_ message: String) -> some View { 298 private func dashboardEmptyRow(_ message: String) -> some View {
296 Text(message) 299 Text(message)
297 .font(appDensity.font(.caption)) 300 .font(appDensity.font(.caption))
298 .foregroundStyle(Color(.appTextSecondary)) 301 .foregroundStyle(ThemeToken.textSecondary)
299 .padding(.vertical, 4) 302 .padding(.vertical, 4)
300 } 303 }
301 304
@@ -324,8 +327,8 @@ struct DashboardView: View {
324 model: .init( 327 model: .init(
325 title: title, 328 title: title,
326 systemImage: systemImage, 329 systemImage: systemImage,
327 foregroundColor: tone.foreground, 330 foreground: tone.foreground,
328 backgroundColor: tone.surface 331 background: tone.surface
329 ) 332 )
330 ) 333 )
331 } 334 }
@@ -353,20 +356,20 @@ private struct PortfolioActivityRow: View {
353 Text(relativeTimestamp(item.timestamp)) 356 Text(relativeTimestamp(item.timestamp))
354 } 357 }
355 .font(appDensity.font(.caption2)) 358 .font(appDensity.font(.caption2))
356 .foregroundStyle(Color(.appTextSecondary)) 359 .foregroundStyle(ThemeToken.textSecondary)
357 } 360 }
358 } 361 }
359 .padding(.vertical, 4) 362 .padding(.vertical, 4)
360 } 363 }
361 364
362 private var iconColor: Color { 365 private var iconColor: AnyShapeStyle {
363 switch item.health { 366 switch item.health {
364 case .healthy: 367 case .healthy:
365 return Color(.statusInfo) 368 return AnyShapeStyle(ThemeToken.info)
366 case .warning: 369 case .warning:
367 return Color(.statusWarning) 370 return AnyShapeStyle(ThemeToken.warning)
368 case .critical: 371 case .critical:
369 return Color(.statusCritical) 372 return AnyShapeStyle(ThemeToken.critical)
370 } 373 }
371 } 374 }
372} 375}
@@ -385,10 +388,10 @@ private struct PortfolioAttentionRow: View {
385 .foregroundStyle(.primary) 388 .foregroundStyle(.primary)
386 Text(item.reason) 389 Text(item.reason)
387 .font(appDensity.font(.caption, design: .default)) 390 .font(appDensity.font(.caption, design: .default))
388 .foregroundStyle(Color(.appTextSecondary)) 391 .foregroundStyle(ThemeToken.textSecondary)
389 Text(relativeTimestamp(item.timestamp)) 392 Text(relativeTimestamp(item.timestamp))
390 .font(appDensity.font(.caption2)) 393 .font(appDensity.font(.caption2))
391 .foregroundStyle(Color(.appTextSecondary)) 394 .foregroundStyle(ThemeToken.textSecondary)
392 } 395 }
393 } 396 }
394 .padding(.vertical, 4) 397 .padding(.vertical, 4)
@@ -397,11 +400,11 @@ private struct PortfolioAttentionRow: View {
397 private var badgeModel: AppStatusBadgeModel { 400 private var badgeModel: AppStatusBadgeModel {
398 switch item.health { 401 switch item.health {
399 case .healthy: 402 case .healthy:
400 return .init(title: "Healthy", systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 403 return .init(title: "Healthy", systemImage: "checkmark.circle.fill", foreground: .positive, background: .positiveSurface)
401 case .warning: 404 case .warning:
402 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 405 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
403 case .critical: 406 case .critical:
404 return .init(title: "Critical", systemImage: "exclamationmark.octagon.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 407 return .init(title: "Critical", systemImage: "exclamationmark.octagon.fill", foreground: .critical, background: .criticalSurface)
405 } 408 }
406 } 409 }
407} 410}
@@ -434,7 +437,7 @@ private struct PortfolioExpiryRow: View {
434 .foregroundStyle(.primary) 437 .foregroundStyle(.primary)
435 Text(expirySubtitle) 438 Text(expirySubtitle)
436 .font(appDensity.font(.caption)) 439 .font(appDensity.font(.caption))
437 .foregroundStyle(Color(.appTextSecondary)) 440 .foregroundStyle(ThemeToken.textSecondary)
438 } 441 }
439 } 442 }
440 443
@@ -448,11 +451,11 @@ private struct PortfolioExpiryRow: View {
448 private var badgeModel: AppStatusBadgeModel { 451 private var badgeModel: AppStatusBadgeModel {
449 switch state.certificateExpiryState { 452 switch state.certificateExpiryState {
450 case .none: 453 case .none:
451 return .init(title: "Healthy", systemImage: "lock.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 454 return .init(title: "Healthy", systemImage: "lock.fill", foreground: .positive, background: .positiveSurface)
452 case .warning: 455 case .warning:
453 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 456 return .init(title: "Warning", systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
454 case .critical: 457 case .critical:
455 return .init(title: "Critical", systemImage: "xmark.octagon.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 458 return .init(title: "Critical", systemImage: "xmark.octagon.fill", foreground: .critical, background: .criticalSurface)
456 } 459 }
457 } 460 }
458} 461}
DomainDig/DomainCompareView.swift +3 −3
@@ -38,7 +38,7 @@ struct DomainCompareView: View {
38 Section { 38 Section {
39 Text("Choose two different domains to compare.") 39 Text("Choose two different domains to compare.")
40 .font(.callout) 40 .font(.callout)
41 .foregroundStyle(Color(.appTextSecondary)) 41 .foregroundStyle(ThemeToken.textSecondary)
42 } 42 }
43 } 43 }
44 44
@@ -63,11 +63,11 @@ struct DomainCompareView: View {
63 showsCardBackground: false 63 showsCardBackground: false
64 ) 64 )
65 } 65 }
66 .listRowBackground(Color(.appSurface)) 66 .themedListRowBackground(.surface)
67 } 67 }
68 } 68 }
69 .scrollContentBackground(.hidden) 69 .scrollContentBackground(.hidden)
70 .background(Color(.appBackground)) 70 .background(ThemeToken.background)
71 .navigationTitle("Compare Domains") 71 .navigationTitle("Compare Domains")
72 } 72 }
73 73
DomainDig/DomainDiffViews.swift +17 −17
@@ -13,11 +13,11 @@ struct DomainChangeSummaryView: View {
13 HStack { 13 HStack {
14 Label(summary.hasChanges ? "Changed" : "Stable", systemImage: summary.hasChanges ? "arrow.triangle.2.circlepath" : "checkmark.circle") 14 Label(summary.hasChanges ? "Changed" : "Stable", systemImage: summary.hasChanges ? "arrow.triangle.2.circlepath" : "checkmark.circle")
15 .font(appDensity.font(.caption)) 15 .font(appDensity.font(.caption))
16 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : Color(.statusPositive)) 16 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : ThemeToken.positive)
17 Spacer() 17 Spacer()
18 Text(summary.severity.title.uppercased()) 18 Text(summary.severity.title.uppercased())
19 .font(appDensity.font(.caption2)) 19 .font(appDensity.font(.caption2))
20 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : Color(.appTextSecondary)) 20 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : ThemeToken.textSecondary)
21 .padding(.horizontal, 8) 21 .padding(.horizontal, 8)
22 .padding(.vertical, 4) 22 .padding(.vertical, 4)
23 .background((summary.hasChanges ? severityTone(summary.severity) : AppStatusTone.neutral).surface) 23 .background((summary.hasChanges ? severityTone(summary.severity) : AppStatusTone.neutral).surface)
@@ -31,13 +31,13 @@ struct DomainChangeSummaryView: View {
31 .clipShape(Capsule()) 31 .clipShape(Capsule())
32 Text(summary.generatedAt, style: .time) 32 Text(summary.generatedAt, style: .time)
33 .font(appDensity.font(.caption2)) 33 .font(appDensity.font(.caption2))
34 .foregroundStyle(Color(.appTextSecondary)) 34 .foregroundStyle(ThemeToken.textSecondary)
35 } 35 }
36 36
37 VStack(alignment: .leading, spacing: 4) { 37 VStack(alignment: .leading, spacing: 4) {
38 Text("Inference") 38 Text("Inference")
39 .font(appDensity.font(.caption2)) 39 .font(appDensity.font(.caption2))
40 .foregroundStyle(Color(.appTextSecondary)) 40 .foregroundStyle(ThemeToken.textSecondary)
41 Text(summary.message) 41 Text(summary.message)
42 .font(appDensity.font(.caption)) 42 .font(appDensity.font(.caption))
43 .foregroundStyle(.primary) 43 .foregroundStyle(.primary)
@@ -51,7 +51,7 @@ struct DomainChangeSummaryView: View {
51 VStack(alignment: .leading, spacing: 4) { 51 VStack(alignment: .leading, spacing: 4) {
52 Text("Observed") 52 Text("Observed")
53 .font(appDensity.font(.caption2)) 53 .font(appDensity.font(.caption2))
54 .foregroundStyle(Color(.appTextSecondary)) 54 .foregroundStyle(ThemeToken.textSecondary)
55 ForEach(Array(summary.observedFacts.enumerated()), id: \.offset) { _, fact in 55 ForEach(Array(summary.observedFacts.enumerated()), id: \.offset) { _, fact in
56 Text(fact) 56 Text(fact)
57 .font(appDensity.font(.caption)) 57 .font(appDensity.font(.caption))
@@ -63,13 +63,13 @@ struct DomainChangeSummaryView: View {
63 if let riskScoreDelta = summary.riskScoreDelta { 63 if let riskScoreDelta = summary.riskScoreDelta {
64 Text("Risk delta: \(riskScoreDelta >= 0 ? "+" : "")\(riskScoreDelta)") 64 Text("Risk delta: \(riskScoreDelta >= 0 ? "+" : "")\(riskScoreDelta)")
65 .font(appDensity.font(.caption2)) 65 .font(appDensity.font(.caption2))
66 .foregroundStyle(riskScoreDelta > 0 ? Color(.statusWarning) : .secondary) 66 .foregroundStyle(riskScoreDelta > 0 ? AnyShapeStyle(ThemeToken.warning) : AnyShapeStyle(.secondary))
67 } 67 }
68 68
69 if let contextNote = summary.contextNote { 69 if let contextNote = summary.contextNote {
70 Text(contextNote) 70 Text(contextNote)
71 .font(appDensity.font(.caption2)) 71 .font(appDensity.font(.caption2))
72 .foregroundStyle(Color(.statusWarning)) 72 .foregroundStyle(ThemeToken.warning)
73 } 73 }
74 } 74 }
75 .padding(.top, 4) 75 .padding(.top, 4)
@@ -153,7 +153,7 @@ struct DomainDiffView: View {
153 HStack { 153 HStack {
154 Text(item.label) 154 Text(item.label)
155 .font(.system(.caption, design: .monospaced)) 155 .font(.system(.caption, design: .monospaced))
156 .foregroundStyle(Color(.appTextSecondary)) 156 .foregroundStyle(ThemeToken.textSecondary)
157 Spacer() 157 Spacer()
158 Text("\(item.changeType.marker) \(item.severity.title) • \(changeLabel(for: item.changeType))") 158 Text("\(item.changeType.marker) \(item.severity.title) • \(changeLabel(for: item.changeType))")
159 .font(.system(.caption2, design: .monospaced)) 159 .font(.system(.caption2, design: .monospaced))
@@ -168,10 +168,10 @@ struct DomainDiffView: View {
168 VStack(alignment: .leading, spacing: 2) { 168 VStack(alignment: .leading, spacing: 2) {
169 Text("Old") 169 Text("Old")
170 .font(.system(.caption2, design: .monospaced)) 170 .font(.system(.caption2, design: .monospaced))
171 .foregroundStyle(Color(.appTextSecondary)) 171 .foregroundStyle(ThemeToken.textSecondary)
172 Text(oldValue) 172 Text(oldValue)
173 .font(.system(.caption2, design: .monospaced)) 173 .font(.system(.caption2, design: .monospaced))
174 .foregroundStyle(Color(.appTextSecondary)) 174 .foregroundStyle(ThemeToken.textSecondary)
175 .textSelection(.enabled) 175 .textSelection(.enabled)
176 } 176 }
177 } 177 }
@@ -180,7 +180,7 @@ struct DomainDiffView: View {
180 VStack(alignment: .leading, spacing: 2) { 180 VStack(alignment: .leading, spacing: 2) {
181 Text("New") 181 Text("New")
182 .font(.system(.caption2, design: .monospaced)) 182 .font(.system(.caption2, design: .monospaced))
183 .foregroundStyle(Color(.appTextSecondary)) 183 .foregroundStyle(ThemeToken.textSecondary)
184 Text(newValue) 184 Text(newValue)
185 .font(.system(.caption, design: .monospaced)) 185 .font(.system(.caption, design: .monospaced))
186 .foregroundStyle(item.hasChanges ? .primary : .secondary) 186 .foregroundStyle(item.hasChanges ? .primary : .secondary)
@@ -189,7 +189,7 @@ struct DomainDiffView: View {
189 } 189 }
190 } 190 }
191 .padding(10) 191 .padding(10)
192 .background(item.hasChanges ? changeTone(for: item).surface : Color(.appSurface)) 192 .background(item.hasChanges ? changeTone(for: item).surface : ThemeToken.surface)
193 .cornerRadius(8) 193 .cornerRadius(8)
194 } 194 }
195 } label: { 195 } label: {
@@ -209,7 +209,7 @@ struct DomainDiffView: View {
209 .overlay { 209 .overlay {
210 if highlightedSectionID == section.id { 210 if highlightedSectionID == section.id {
211 RoundedRectangle(cornerRadius: 12) 211 RoundedRectangle(cornerRadius: 12)
212 .stroke(Color(.statusInfo).opacity(0.55), lineWidth: 1) 212 .stroke(ThemeToken.info.opacity(0.55), lineWidth: 1)
213 } 213 }
214 } 214 }
215 } 215 }
@@ -248,14 +248,14 @@ struct DomainDiffView: View {
248 } 248 }
249 } 249 }
250 250
251 private func sectionColor(_ section: DomainDiffSection) -> Color { 251 private func sectionColor(_ section: DomainDiffSection) -> AnyShapeStyle {
252 switch section.severity { 252 switch section.severity {
253 case .low: 253 case .low:
254 return .blue 254 return AnyShapeStyle(.blue)
255 case .medium: 255 case .medium:
256 return Color(.statusWarning) 256 return AnyShapeStyle(ThemeToken.warning)
257 case .high: 257 case .high:
258 return Color(.statusCritical) 258 return AnyShapeStyle(ThemeToken.critical)
259 } 259 }
260 } 260 }
261 261
DomainDig/DomainDigApp.swift +13
@@ -13,11 +13,20 @@ struct DomainDigApp: App {
13 @Environment(\.scenePhase) private var scenePhase 13 @Environment(\.scenePhase) private var scenePhase
14 @AppStorage(AppDensity.userDefaultsKey) private var density = AppDensity.compact.rawValue 14 @AppStorage(AppDensity.userDefaultsKey) private var density = AppDensity.compact.rawValue
15 @AppStorage(AppAppearance.userDefaultsKey) private var appearance = AppAppearance.system.rawValue 15 @AppStorage(AppAppearance.userDefaultsKey) private var appearance = AppAppearance.system.rawValue
16 @AppStorage(AccentTheme.userDefaultsKey) private var accent = AccentTheme.default.rawValue
16 @State private var viewModel = DomainViewModel() 17 @State private var viewModel = DomainViewModel()
17 @State private var purchaseService = PurchaseService.shared 18 @State private var purchaseService = PurchaseService.shared
18 @State private var cloudSyncService = CloudSyncService.shared 19 @State private var cloudSyncService = CloudSyncService.shared
19 @State private var localAPIService = LocalAPIService.shared 20 @State private var localAPIService = LocalAPIService.shared
20 21
22 /// Falls back to the default when the tier does not include themes, so a
23 /// lapsed subscriber sees the stock palette rather than a theme they can no
24 /// longer change.
25 private var selectedAccent: AccentTheme {
26 guard FeatureAccessService.hasAccess(to: .accentTheme) else { return .default }
27 return AccentTheme(rawValue: accent) ?? .default
28 }
29
21 init() { 30 init() {
22 LocalNotificationService.shared.configureForegroundPresentation() 31 LocalNotificationService.shared.configureForegroundPresentation()
23 DomainMonitoringScheduler.shared.registerBackgroundTask() 32 DomainMonitoringScheduler.shared.registerBackgroundTask()
@@ -28,6 +37,10 @@ struct DomainDigApp: App {
28 WindowGroup { 37 WindowGroup {
29 RootTabView(viewModel: viewModel) 38 RootTabView(viewModel: viewModel)
30 .environment(\.appDensity, AppDensity(rawValue: density) ?? .compact) 39 .environment(\.appDensity, AppDensity(rawValue: density) ?? .compact)
40 .environment(\.theme, selectedAccent.theme)
41 // So standard controls pick the accent up too, not only the
42 // views that name a token.
43 .tint(selectedAccent == .default ? nil : selectedAccent.theme.accentFill)
31 // The single place appearance is applied. Keep it that way. 44 // The single place appearance is applied. Keep it that way.
32 .preferredColorScheme((AppAppearance(rawValue: appearance) ?? .system).colorScheme) 45 .preferredColorScheme((AppAppearance(rawValue: appearance) ?? .system).colorScheme)
33 .task { 46 .task {
DomainDig/DomainDigUI.swift +46 −39
@@ -145,95 +145,102 @@ enum AppStatusTone {
145 case info 145 case info
146 case neutral 146 case neutral
147 147
148 var foreground: Color { 148 var foreground: ThemeToken {
149 switch self { 149 switch self {
150 case .positive: 150 case .positive:
151 return Color(.statusPositive) 151 return .positive
152 case .warning: 152 case .warning:
153 return Color(.statusWarning) 153 return .warning
154 case .critical: 154 case .critical:
155 return Color(.statusCritical) 155 return .critical
156 case .info: 156 case .info:
157 return Color(.statusInfo) 157 return .info
158 case .neutral: 158 case .neutral:
159 return Color(.statusNeutral) 159 return .neutral
160 } 160 }
161 } 161 }
162 162
163 var surface: Color { 163 var surface: ThemeToken {
164 switch self { 164 switch self {
165 case .positive: 165 case .positive:
166 return Color(.statusPositiveSurface) 166 return .positiveSurface
167 case .warning: 167 case .warning:
168 return Color(.statusWarningSurface) 168 return .warningSurface
169 case .critical: 169 case .critical:
170 return Color(.statusCriticalSurface) 170 return .criticalSurface
171 case .info: 171 case .info:
172 return Color(.statusInfoSurface) 172 return .infoSurface
173 case .neutral: 173 case .neutral:
174 return Color(.statusNeutralSurface) 174 return .neutralSurface
175 } 175 }
176 } 176 }
177} 177}
178 178
179/// A badge's appearance, named rather than resolved.
180///
181/// The colours are `ThemeToken`s because every one of these is built outside a
182/// view body — `AppStatusFactory` and the per-row helpers are plain functions —
183/// so they cannot read the environment. `AppStatusBadgeView` resolves them when
184/// it draws.
179struct AppStatusBadgeModel: Equatable { 185struct AppStatusBadgeModel: Equatable {
180 let title: String 186 let title: String
181 let systemImage: String? 187 let systemImage: String?
182 let foregroundColor: Color 188 let foreground: ThemeToken
183 let backgroundColor: Color 189 let background: ThemeToken
184} 190}
185 191
186enum AppStatusFactory { 192enum AppStatusFactory {
187 static func availability(_ status: DomainAvailabilityStatus?) -> AppStatusBadgeModel { 193 static func availability(_ status: DomainAvailabilityStatus?) -> AppStatusBadgeModel {
188 switch status { 194 switch status {
189 case .available: 195 case .available:
190 return .init(title: "Available", systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 196 return .init(title: "Available", systemImage: "checkmark.circle.fill", foreground: .positive, background: .positiveSurface)
191 case .registered: 197 case .registered:
192 return .init(title: "Registered", systemImage: "circle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 198 return .init(title: "Registered", systemImage: "circle.fill", foreground: .warning, background: .warningSurface)
193 case .unknown, .none: 199 case .unknown, .none:
194 return .init(title: "Unknown", systemImage: "questionmark.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 200 return .init(title: "Unknown", systemImage: "questionmark.circle", foreground: .textSecondary, background: .surfaceElevated)
195 } 201 }
196 } 202 }
197 203
198 static func tls(sslInfo: SSLCertificateInfo?, error: String?) -> AppStatusBadgeModel { 204 static func tls(sslInfo: SSLCertificateInfo?, error: String?) -> AppStatusBadgeModel {
199 if error != nil || sslInfo == nil { 205 if error != nil || sslInfo == nil {
200 return .init(title: "Invalid", systemImage: "xmark.octagon.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 206 return .init(title: "Invalid", systemImage: "xmark.octagon.fill", foreground: .critical, background: .criticalSurface)
201 } 207 }
202 if let sslInfo, sslInfo.daysUntilExpiry <= 14 { 208 if let sslInfo, sslInfo.daysUntilExpiry <= 14 {
203 return .init(title: "Expiring", systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 209 return .init(title: "Expiring", systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
204 } 210 }
205 return .init(title: "Valid", systemImage: "lock.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 211 return .init(title: "Valid", systemImage: "lock.fill", foreground: .positive, background: .positiveSurface)
206 } 212 }
207 213
208 static func email(_ result: EmailSecurityResult?, error: String?) -> AppStatusBadgeModel { 214 static func email(_ result: EmailSecurityResult?, error: String?) -> AppStatusBadgeModel {
209 guard error == nil, let result else { 215 guard error == nil, let result else {
210 return .init(title: "Missing", systemImage: "minus.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 216 return .init(title: "Missing", systemImage: "minus.circle", foreground: .textSecondary, background: .surfaceElevated)
211 } 217 }
212 218
213 let foundCount = [result.spf.found, result.dmarc.found, result.dkim.found].filter { $0 }.count 219 let foundCount = [result.spf.found, result.dmarc.found, result.dkim.found].filter { $0 }.count
214 switch foundCount { 220 switch foundCount {
215 case 3: 221 case 3:
216 return .init(title: "Secure", systemImage: "checkmark.shield.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 222 return .init(title: "Secure", systemImage: "checkmark.shield.fill", foreground: .positive, background: .positiveSurface)
217 case 1, 2: 223 case 1, 2:
218 return .init(title: "Partial", systemImage: "shield.lefthalf.filled", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 224 return .init(title: "Partial", systemImage: "shield.lefthalf.filled", foreground: .warning, background: .warningSurface)
219 default: 225 default:
220 return .init(title: "Missing", systemImage: "minus.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 226 return .init(title: "Missing", systemImage: "minus.circle", foreground: .textSecondary, background: .surfaceElevated)
221 } 227 }
222 } 228 }
223 229
224 static func change(_ summary: DomainChangeSummary?) -> AppStatusBadgeModel { 230 static func change(_ summary: DomainChangeSummary?) -> AppStatusBadgeModel {
225 guard let summary else { 231 guard let summary else {
226 return .init(title: "Unchanged", systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 232 return .init(title: "Unchanged", systemImage: "circle", foreground: .textSecondary, background: .surfaceElevated)
227 } 233 }
228 if summary.hasChanges { 234 if summary.hasChanges {
229 return .init(title: "Changed", systemImage: "arrow.triangle.2.circlepath", foregroundColor: Color(.statusInfo), backgroundColor: Color(.statusInfoSurface)) 235 return .init(title: "Changed", systemImage: "arrow.triangle.2.circlepath", foreground: .info, background: .infoSurface)
230 } 236 }
231 return .init(title: "Unchanged", systemImage: "checkmark.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 237 return .init(title: "Unchanged", systemImage: "checkmark.circle", foreground: .textSecondary, background: .surfaceElevated)
232 } 238 }
233} 239}
234 240
235struct AppStatusBadgeView: View { 241struct AppStatusBadgeView: View {
236 @Environment(\.appDensity) private var appDensity 242 @Environment(\.appDensity) private var appDensity
243 @Environment(\.theme) private var theme
237 244
238 let model: AppStatusBadgeModel 245 let model: AppStatusBadgeModel
239 246
@@ -251,10 +258,10 @@ struct AppStatusBadgeView: View {
251 // ViewThatFits onto its stacked layout, which is the intended fallback. 258 // ViewThatFits onto its stacked layout, which is the intended fallback.
252 .fixedSize() 259 .fixedSize()
253 .font(appDensity.font(.caption, weight: .semibold)) 260 .font(appDensity.font(.caption, weight: .semibold))
254 .foregroundStyle(model.foregroundColor) 261 .foregroundStyle(theme[model.foreground])
255 .padding(.horizontal, 9) 262 .padding(.horizontal, 9)
256 .padding(.vertical, 5) 263 .padding(.vertical, 5)
257 .background(model.backgroundColor) 264 .background(theme[model.background])
258 .clipShape(Capsule()) 265 .clipShape(Capsule())
259 // Read as one word ("Critical"), not "icon, Critical". The symbol 266 // Read as one word ("Critical"), not "icon, Critical". The symbol
260 // duplicates the title for VoiceOver. 267 // duplicates the title for VoiceOver.
@@ -294,9 +301,9 @@ struct AppCopyButton: View {
294 } label: { 301 } label: {
295 Image(systemName: didCopy ? "checkmark" : "doc.on.doc") 302 Image(systemName: didCopy ? "checkmark" : "doc.on.doc")
296 .font(appDensity.font(.caption)) 303 .font(appDensity.font(.caption))
297 .foregroundStyle(didCopy ? Color(.statusPositive) : Color(.appTextSecondary)) 304 .foregroundStyle(didCopy ? ThemeToken.positive : ThemeToken.textSecondary)
298 .frame(width: max(size, AppLayout.minimumTapTarget), height: max(size, AppLayout.minimumTapTarget)) 305 .frame(width: max(size, AppLayout.minimumTapTarget), height: max(size, AppLayout.minimumTapTarget))
299 .background(Color(.appSurfaceElevated)) 306 .background(ThemeToken.surfaceElevated)
300 .clipShape(RoundedRectangle(cornerRadius: 8)) 307 .clipShape(RoundedRectangle(cornerRadius: 8))
301 } 308 }
302 .buttonStyle(.plain) 309 .buttonStyle(.plain)
@@ -400,17 +407,17 @@ struct EmptyStateCardView: View {
400 407
401 Text(message) 408 Text(message)
402 .font(appDensity.font(.body)) 409 .font(appDensity.font(.body))
403 .foregroundStyle(Color(.appTextSecondary)) 410 .foregroundStyle(ThemeToken.textSecondary)
404 .fixedSize(horizontal: false, vertical: true) 411 .fixedSize(horizontal: false, vertical: true)
405 412
406 Text(suggestion) 413 Text(suggestion)
407 .font(appDensity.font(.caption)) 414 .font(appDensity.font(.caption))
408 .foregroundStyle(Color(.statusInfo)) 415 .foregroundStyle(ThemeToken.info)
409 .fixedSize(horizontal: false, vertical: true) 416 .fixedSize(horizontal: false, vertical: true)
410 } 417 }
411 .frame(maxWidth: .infinity, alignment: .leading) 418 .frame(maxWidth: .infinity, alignment: .leading)
412 .padding(appDensity.metrics.cardPadding) 419 .padding(appDensity.metrics.cardPadding)
413 .background(showsCardBackground ? Color(.appSurface) : Color.clear) 420 .background(showsCardBackground ? AnyShapeStyle(ThemeToken.surface) : AnyShapeStyle(.clear))
414 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 421 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
415 } 422 }
416} 423}
@@ -503,7 +510,7 @@ struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View {
503 if let subtitle { 510 if let subtitle {
504 Text(subtitle) 511 Text(subtitle)
505 .font(appDensity.font(.caption)) 512 .font(appDensity.font(.caption))
506 .foregroundStyle(Color(.appTextSecondary)) 513 .foregroundStyle(ThemeToken.textSecondary)
507 .fixedSize(horizontal: false, vertical: true) 514 .fixedSize(horizontal: false, vertical: true)
508 } 515 }
509 } 516 }
@@ -512,7 +519,7 @@ struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View {
512 private var chevron: some View { 519 private var chevron: some View {
513 Image(systemName: isCollapsed ? "chevron.down" : "chevron.up") 520 Image(systemName: isCollapsed ? "chevron.down" : "chevron.up")
514 .font(.caption.weight(.semibold)) 521 .font(.caption.weight(.semibold))
515 .foregroundStyle(Color(.appTextSecondary)) 522 .foregroundStyle(ThemeToken.textSecondary)
516 .accessibilityHidden(true) 523 .accessibilityHidden(true)
517 } 524 }
518} 525}
@@ -530,7 +537,7 @@ struct TagChipRowView: View {
530 .font(.caption) 537 .font(.caption)
531 .padding(.horizontal, 10) 538 .padding(.horizontal, 10)
532 .padding(.vertical, 5) 539 .padding(.vertical, 5)
533 .background(Color(.appSurfaceElevated), in: Capsule()) 540 .background(ThemeToken.surfaceElevated, in: Capsule())
534 } 541 }
535 } 542 }
536 } 543 }
@@ -564,8 +571,8 @@ struct TagFilterChipRowView: View {
564 .font(.caption) 571 .font(.caption)
565 .padding(.horizontal, 10) 572 .padding(.horizontal, 10)
566 .padding(.vertical, 5) 573 .padding(.vertical, 5)
567 .background(isSelected ? Color(.statusInfoSurface) : Color(.appSurfaceElevated), in: Capsule()) 574 .background(isSelected ? ThemeToken.infoSurface : ThemeToken.surfaceElevated, in: Capsule())
568 .foregroundStyle(isSelected ? Color(.statusInfo) : Color.primary) 575 .foregroundStyle(isSelected ? AnyShapeStyle(ThemeToken.info) : AnyShapeStyle(.primary))
569 } 576 }
570 .buttonStyle(.plain) 577 .buttonStyle(.plain)
571 } 578 }
DomainDig/DomainSectionView.swift +4 −4
@@ -35,9 +35,9 @@ struct DomainSectionView: View {
35 // VoiceOver still hears the word via the label. 35 // VoiceOver still hears the word via the label.
36 Image(systemName: "eye.fill") 36 Image(systemName: "eye.fill")
37 .font(appDensity.font(.caption)) 37 .font(appDensity.font(.caption))
38 .foregroundStyle(Color(.statusPositive)) 38 .foregroundStyle(ThemeToken.positive)
39 .padding(6) 39 .padding(6)
40 .background(Color(.statusPositiveSurface), in: Circle()) 40 .background(ThemeToken.positiveSurface, in: Circle())
41 .fixedSize() 41 .fixedSize()
42 .accessibilityLabel("Tracked") 42 .accessibilityLabel("Tracked")
43 Button { 43 Button {
@@ -100,7 +100,7 @@ struct DomainSectionView: View {
100 VStack(alignment: .leading, spacing: 8) { 100 VStack(alignment: .leading, spacing: 8) {
101 Text("Part of workflow") 101 Text("Part of workflow")
102 .font(appDensity.font(.caption)) 102 .font(appDensity.font(.caption))
103 .foregroundStyle(Color(.appTextSecondary)) 103 .foregroundStyle(ThemeToken.textSecondary)
104 104
105 ForEach(workflows) { workflow in 105 ForEach(workflows) { workflow in
106 HStack { 106 HStack {
@@ -135,7 +135,7 @@ struct DomainSectionView: View {
135 if showSuggestions { 135 if showSuggestions {
136 Text("Suggestions") 136 Text("Suggestions")
137 .font(appDensity.font(.caption)) 137 .font(appDensity.font(.caption))
138 .foregroundStyle(Color(.appTextSecondary)) 138 .foregroundStyle(ThemeToken.textSecondary)
139 .padding(.top, 4) 139 .padding(.top, 4)
140 if suggestionsLoading { 140 if suggestionsLoading {
141 ProgressView("Checking alternatives…") 141 ProgressView("Checking alternatives…")
DomainDig/EmailSectionView.swift +7 −7
@@ -29,7 +29,7 @@ struct EmailSectionView: View {
29 if !assessment.reasons.isEmpty { 29 if !assessment.reasons.isEmpty {
30 Text(assessment.reasons.joined(separator: " | ")) 30 Text(assessment.reasons.joined(separator: " | "))
31 .font(appDensity.font(.caption2)) 31 .font(appDensity.font(.caption2))
32 .foregroundStyle(Color(.appTextSecondary)) 32 .foregroundStyle(ThemeToken.textSecondary)
33 } 33 }
34 } 34 }
35 if loading { 35 if loading {
@@ -45,7 +45,7 @@ struct EmailSectionView: View {
45 HStack(spacing: 8) { 45 HStack(spacing: 8) {
46 Text(row.label) 46 Text(row.label)
47 .font(appDensity.font(.caption)) 47 .font(appDensity.font(.caption))
48 .foregroundStyle(Color(.statusInfo)) 48 .foregroundStyle(ThemeToken.info)
49 .frame(width: 76, alignment: .leading) 49 .frame(width: 76, alignment: .leading)
50 AppStatusBadgeView(model: emailRowBadge(row)) 50 AppStatusBadgeView(model: emailRowBadge(row))
51 } 51 }
@@ -56,7 +56,7 @@ struct EmailSectionView: View {
56 if let auxiliaryDetail = row.auxiliaryDetail { 56 if let auxiliaryDetail = row.auxiliaryDetail {
57 Text(auxiliaryDetail) 57 Text(auxiliaryDetail)
58 .font(appDensity.font(.caption2)) 58 .font(appDensity.font(.caption2))
59 .foregroundStyle(Color(.appTextSecondary)) 59 .foregroundStyle(ThemeToken.textSecondary)
60 } 60 }
61 } 61 }
62 } 62 }
@@ -68,13 +68,13 @@ struct EmailSectionView: View {
68 private func emailRowBadge(_ row: EmailRowViewData) -> AppStatusBadgeModel { 68 private func emailRowBadge(_ row: EmailRowViewData) -> AppStatusBadgeModel {
69 switch row.statusTone { 69 switch row.statusTone {
70 case .success: 70 case .success:
71 return .init(title: row.status, systemImage: "checkmark.shield.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 71 return .init(title: row.status, systemImage: "checkmark.shield.fill", foreground: .positive, background: .positiveSurface)
72 case .warning: 72 case .warning:
73 return .init(title: row.status, systemImage: "shield.lefthalf.filled", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 73 return .init(title: row.status, systemImage: "shield.lefthalf.filled", foreground: .warning, background: .warningSurface)
74 case .failure: 74 case .failure:
75 return .init(title: row.status, systemImage: "minus.circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 75 return .init(title: row.status, systemImage: "minus.circle", foreground: .textSecondary, background: .surfaceElevated)
76 case .primary, .secondary: 76 case .primary, .secondary:
77 return .init(title: row.status, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 77 return .init(title: row.status, systemImage: "circle", foreground: .textSecondary, background: .surfaceElevated)
78 } 78 }
79 } 79 }
80} 80}
DomainDig/FeatureAccessService.swift +5 −2
@@ -33,6 +33,7 @@ enum FeatureCapability: String, CaseIterable, Identifiable {
33 case auditDepth 33 case auditDepth
34 case intelligenceDetail 34 case intelligenceDetail
35 case bucketExport 35 case bucketExport
36 case accentTheme
36 37
37 var id: String { rawValue } 38 var id: String { rawValue }
38 39
@@ -64,6 +65,8 @@ enum FeatureCapability: String, CaseIterable, Identifiable {
64 return "Intelligence detail" 65 return "Intelligence detail"
65 case .bucketExport: 66 case .bucketExport:
66 return "Export to your own bucket" 67 return "Export to your own bucket"
68 case .accentTheme:
69 return "Accent themes"
67 } 70 }
68 } 71 }
69} 72}
@@ -194,7 +197,7 @@ enum FeatureAccessService {
194 case .workflows, .batchOperations, .automatedMonitoring, .localAlerts, .advancedExports, 197 case .workflows, .batchOperations, .automatedMonitoring, .localAlerts, .advancedExports,
195 .extendedSubdomains: 198 .extendedSubdomains:
196 return "Available in Pro" 199 return "Available in Pro"
197 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport: 200 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport, .accentTheme:
198 return "Available in Pro+" 201 return "Available in Pro+"
199 case .limitedTracking: 202 case .limitedTracking:
200 return "Tracking is limited on Free" 203 return "Tracking is limited on Free"
@@ -256,7 +259,7 @@ enum FeatureAccessService {
256 static func upgradePrompt(for capability: FeatureCapability) -> UpgradePromptContext { 259 static func upgradePrompt(for capability: FeatureCapability) -> UpgradePromptContext {
257 let title: String 260 let title: String
258 switch capability { 261 switch capability {
259 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport: 262 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport, .accentTheme:
260 title = "Available in Pro+" 263 title = "Available in Pro+"
261 default: 264 default:
262 title = "Available in Pro" 265 title = "Available in Pro"
DomainDig/HistoryView.swift +15 −15
@@ -25,7 +25,7 @@ struct HistoryView: View {
25 systemImage: "clock.arrow.trianglehead.counterclockwise.rotate.90", 25 systemImage: "clock.arrow.trianglehead.counterclockwise.rotate.90",
26 showsCardBackground: false 26 showsCardBackground: false
27 ) 27 )
28 .listRowBackground(Color(.appSurface)) 28 .themedListRowBackground(.surface)
29 } else { 29 } else {
30 Section("Domains") { 30 Section("Domains") {
31 ForEach(domainSummaries, id: \.domain) { item in 31 ForEach(domainSummaries, id: \.domain) { item in
@@ -40,12 +40,12 @@ struct HistoryView: View {
40 Spacer() 40 Spacer()
41 Text("\(item.count) snapshots") 41 Text("\(item.count) snapshots")
42 .font(appDensity.font(.caption2)) 42 .font(appDensity.font(.caption2))
43 .foregroundStyle(Color(.appTextSecondary)) 43 .foregroundStyle(ThemeToken.textSecondary)
44 } 44 }
45 45
46 Text(item.latest.changeSummaryMessage ?? "No change summary") 46 Text(item.latest.changeSummaryMessage ?? "No change summary")
47 .font(appDensity.font(.caption)) 47 .font(appDensity.font(.caption))
48 .foregroundStyle(Color(.appTextSecondary)) 48 .foregroundStyle(ThemeToken.textSecondary)
49 .lineLimit(2) 49 .lineLimit(2)
50 50
51 HStack(spacing: 8) { 51 HStack(spacing: 8) {
@@ -55,21 +55,21 @@ struct HistoryView: View {
55 model: .init( 55 model: .init(
56 title: severity.title, 56 title: severity.title,
57 systemImage: "arrow.triangle.2.circlepath", 57 systemImage: "arrow.triangle.2.circlepath",
58 foregroundColor: severity == .high ? Color(.statusCritical) : Color(.statusWarning), 58 foreground: severity == .high ? .critical : .warning,
59 backgroundColor: (severity == .high ? AppStatusTone.critical : .warning).surface 59 background: (severity == .high ? AppStatusTone.critical : .warning).surface
60 ) 60 )
61 ) 61 )
62 } 62 }
63 } 63 }
64 } 64 }
65 } 65 }
66 .listRowBackground(Color(.appSurface)) 66 .themedListRowBackground(.surface)
67 } 67 }
68 } 68 }
69 } 69 }
70 } 70 }
71 .scrollContentBackground(.hidden) 71 .scrollContentBackground(.hidden)
72 .background(Color(.appBackground)) 72 .background(ThemeToken.background)
73 .navigationTitle("History") 73 .navigationTitle("History")
74 .searchable(text: $viewModel.timelineDomainFilter, prompt: "Search domains") 74 .searchable(text: $viewModel.timelineDomainFilter, prompt: "Search domains")
75 .toolbar { 75 .toolbar {
@@ -296,10 +296,10 @@ struct HistoryDetailView: View {
296 ) 296 )
297 } 297 }
298 } 298 }
299 .listRowBackground(Color(.appSurface)) 299 .themedListRowBackground(.surface)
300 .environment(\.cardProvidesSurface, false) 300 .environment(\.cardProvidesSurface, false)
301 .scrollContentBackground(.hidden) 301 .scrollContentBackground(.hidden)
302 .background(Color(.appBackground)) 302 .background(ThemeToken.background)
303 .navigationTitle(entry.domain) 303 .navigationTitle(entry.domain)
304 .toolbar { 304 .toolbar {
305 ToolbarItemGroup(placement: .topBarTrailing) { 305 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -362,28 +362,28 @@ struct HistoryDetailView: View {
362 Spacer() 362 Spacer()
363 Text("Live re-run available") 363 Text("Live re-run available")
364 .font(appDensity.font(.caption2)) 364 .font(appDensity.font(.caption2))
365 .foregroundStyle(Color(.appTextSecondary)) 365 .foregroundStyle(ThemeToken.textSecondary)
366 } 366 }
367 if let mismatchNote = viewModel.resolverMismatchNote(for: entry) { 367 if let mismatchNote = viewModel.resolverMismatchNote(for: entry) {
368 Text(mismatchNote) 368 Text(mismatchNote)
369 .font(appDensity.font(.caption2)) 369 .font(appDensity.font(.caption2))
370 .foregroundStyle(Color(.statusWarning)) 370 .foregroundStyle(ThemeToken.warning)
371 } 371 }
372 if entry.isPartialSnapshot { 372 if entry.isPartialSnapshot {
373 Text("Partial snapshot: \(entry.validationIssues.joined(separator: " | "))") 373 Text("Partial snapshot: \(entry.validationIssues.joined(separator: " | "))")
374 .font(appDensity.font(.caption2)) 374 .font(appDensity.font(.caption2))
375 .foregroundStyle(Color(.statusWarning)) 375 .foregroundStyle(ThemeToken.warning)
376 } 376 }
377 if let note = entry.note, !note.isEmpty { 377 if let note = entry.note, !note.isEmpty {
378 Text(note) 378 Text(note)
379 .font(appDensity.font(.caption2)) 379 .font(appDensity.font(.caption2))
380 .foregroundStyle(Color(.appTextSecondary)) 380 .foregroundStyle(ThemeToken.textSecondary)
381 } 381 }
382 } 382 }
383 .foregroundStyle(Color(.appTextSecondary)) 383 .foregroundStyle(ThemeToken.textSecondary)
384 .padding(8) 384 .padding(8)
385 .frame(maxWidth: .infinity, alignment: .leading) 385 .frame(maxWidth: .infinity, alignment: .leading)
386 .background(Color(.appSurface)) 386 .background(ThemeToken.surface)
387 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 387 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
388 .padding(.vertical, 12) 388 .padding(.vertical, 12)
389 } 389 }
DomainDig/IntegrationsView.swift +22 −22
@@ -15,7 +15,7 @@ struct IntegrationsSettingsView: View {
15 if let statusMessage = integrationService.statusMessage { 15 if let statusMessage = integrationService.statusMessage {
16 Text(statusMessage) 16 Text(statusMessage)
17 .font(.caption) 17 .font(.caption)
18 .foregroundStyle(Color(.appTextSecondary)) 18 .foregroundStyle(ThemeToken.textSecondary)
19 } 19 }
20 20
21 Button("Process Queue Now") { 21 Button("Process Queue Now") {
@@ -26,7 +26,7 @@ struct IntegrationsSettingsView: View {
26 Section("Targets") { 26 Section("Targets") {
27 if integrationService.targets.isEmpty { 27 if integrationService.targets.isEmpty {
28 Text("No integrations configured.") 28 Text("No integrations configured.")
29 .foregroundStyle(Color(.appTextSecondary)) 29 .foregroundStyle(ThemeToken.textSecondary)
30 } else { 30 } else {
31 ForEach(integrationService.targets) { target in 31 ForEach(integrationService.targets) { target in
32 NavigationLink { 32 NavigationLink {
@@ -42,17 +42,17 @@ struct IntegrationsSettingsView: View {
42 Text(target.name) 42 Text(target.name)
43 Spacer() 43 Spacer()
44 Text(target.type.title) 44 Text(target.type.title)
45 .foregroundStyle(Color(.appTextSecondary)) 45 .foregroundStyle(ThemeToken.textSecondary)
46 } 46 }
47 47
48 Text(summary(for: target)) 48 Text(summary(for: target))
49 .font(.caption) 49 .font(.caption)
50 .foregroundStyle(Color(.appTextSecondary)) 50 .foregroundStyle(ThemeToken.textSecondary)
51 51
52 if !target.isEnabled { 52 if !target.isEnabled {
53 Text("Disabled") 53 Text("Disabled")
54 .font(.caption2) 54 .font(.caption2)
55 .foregroundStyle(Color(.statusWarning)) 55 .foregroundStyle(ThemeToken.warning)
56 } 56 }
57 } 57 }
58 } 58 }
@@ -140,7 +140,7 @@ private struct IntegrationDetailView: View {
140 Section("Delivery Log") { 140 Section("Delivery Log") {
141 if integrationService.deliveryRecords(for: target.id).isEmpty { 141 if integrationService.deliveryRecords(for: target.id).isEmpty {
142 Text("No deliveries yet.") 142 Text("No deliveries yet.")
143 .foregroundStyle(Color(.appTextSecondary)) 143 .foregroundStyle(ThemeToken.textSecondary)
144 } else { 144 } else {
145 ForEach(integrationService.deliveryRecords(for: target.id), id: \.id) { record in 145 ForEach(integrationService.deliveryRecords(for: target.id), id: \.id) { record in
146 VStack(alignment: .leading, spacing: 4) { 146 VStack(alignment: .leading, spacing: 4) {
@@ -149,7 +149,7 @@ private struct IntegrationDetailView: View {
149 Spacer() 149 Spacer()
150 Text(record.timestamp.formatted(date: .abbreviated, time: .shortened)) 150 Text(record.timestamp.formatted(date: .abbreviated, time: .shortened))
151 .font(.caption) 151 .font(.caption)
152 .foregroundStyle(Color(.appTextSecondary)) 152 .foregroundStyle(ThemeToken.textSecondary)
153 } 153 }
154 154
155 Text(record.summary) 155 Text(record.summary)
@@ -157,13 +157,13 @@ private struct IntegrationDetailView: View {
157 157
158 Text(record.destination) 158 Text(record.destination)
159 .font(.caption) 159 .font(.caption)
160 .foregroundStyle(Color(.appTextSecondary)) 160 .foregroundStyle(ThemeToken.textSecondary)
161 161
162 if let failureReason = record.failureReason { 162 if let failureReason = record.failureReason {
163 let failureColor: Color = record.status == .skipped ? .secondary : Color(.statusCritical) 163 let failureStyle = record.status == .skipped ? AnyShapeStyle(.secondary) : AnyShapeStyle(ThemeToken.critical)
164 Text(failureReason) 164 Text(failureReason)
165 .font(.caption) 165 .font(.caption)
166 .foregroundStyle(failureColor) 166 .foregroundStyle(failureStyle)
167 } 167 }
168 } 168 }
169 } 169 }
@@ -171,7 +171,7 @@ private struct IntegrationDetailView: View {
171 } 171 }
172 } else { 172 } else {
173 Text("Integration not found.") 173 Text("Integration not found.")
174 .foregroundStyle(Color(.appTextSecondary)) 174 .foregroundStyle(ThemeToken.textSecondary)
175 } 175 }
176 } 176 }
177 .navigationTitle(target?.name ?? "Integration") 177 .navigationTitle(target?.name ?? "Integration")
@@ -238,7 +238,7 @@ private struct IntegrationEditorView: View {
238 if !FeatureAccessService.hasAccess(to: .bucketExport) { 238 if !FeatureAccessService.hasAccess(to: .bucketExport) {
239 Text("Export to your own bucket is \(FeatureAccessService.upgradeMessage(for: .bucketExport)).") 239 Text("Export to your own bucket is \(FeatureAccessService.upgradeMessage(for: .bucketExport)).")
240 .font(.caption) 240 .font(.caption)
241 .foregroundStyle(Color(.appTextSecondary)) 241 .foregroundStyle(ThemeToken.textSecondary)
242 } 242 }
243 243
244 TextField("Name", text: $name) 244 TextField("Name", text: $name)
@@ -284,7 +284,7 @@ private struct IntegrationEditorView: View {
284 if existingTarget != nil { 284 if existingTarget != nil {
285 Text("Saved webhook URL remains in Keychain unless you replace it.") 285 Text("Saved webhook URL remains in Keychain unless you replace it.")
286 .font(.caption) 286 .font(.caption)
287 .foregroundStyle(Color(.appTextSecondary)) 287 .foregroundStyle(ThemeToken.textSecondary)
288 } 288 }
289 } 289 }
290 case .slack: 290 case .slack:
@@ -297,7 +297,7 @@ private struct IntegrationEditorView: View {
297 if existingTarget != nil { 297 if existingTarget != nil {
298 Text("Saved Slack webhook remains in Keychain unless you replace it.") 298 Text("Saved Slack webhook remains in Keychain unless you replace it.")
299 .font(.caption) 299 .font(.caption)
300 .foregroundStyle(Color(.appTextSecondary)) 300 .foregroundStyle(ThemeToken.textSecondary)
301 } 301 }
302 } 302 }
303 case .email: 303 case .email:
@@ -311,7 +311,7 @@ private struct IntegrationEditorView: View {
311 311
312 Text("Port 465 with Direct TLS is supported. Port 587 (STARTTLS) is not.") 312 Text("Port 465 with Direct TLS is supported. Port 587 (STARTTLS) is not.")
313 .font(.caption) 313 .font(.caption)
314 .foregroundStyle(Color(.appTextSecondary)) 314 .foregroundStyle(ThemeToken.textSecondary)
315 315
316 TextField("Username", text: $emailUsername) 316 TextField("Username", text: $emailUsername)
317 .textInputAutocapitalization(.never) 317 .textInputAutocapitalization(.never)
@@ -338,7 +338,7 @@ private struct IntegrationEditorView: View {
338 if existingTarget != nil { 338 if existingTarget != nil {
339 Text("Saved SMTP password remains in Keychain unless you replace it.") 339 Text("Saved SMTP password remains in Keychain unless you replace it.")
340 .font(.caption) 340 .font(.caption)
341 .foregroundStyle(Color(.appTextSecondary)) 341 .foregroundStyle(ThemeToken.textSecondary)
342 } 342 }
343 } 343 }
344 case .s3: 344 case .s3:
@@ -350,7 +350,7 @@ private struct IntegrationEditorView: View {
350 350
351 Text("Must be https. Signing puts your access key ID on the wire, and the signature with it.") 351 Text("Must be https. Signing puts your access key ID on the wire, and the signature with it.")
352 .font(.caption) 352 .font(.caption)
353 .foregroundStyle(Color(.appTextSecondary)) 353 .foregroundStyle(ThemeToken.textSecondary)
354 354
355 TextField("Bucket", text: $s3Bucket) 355 TextField("Bucket", text: $s3Bucket)
356 .textInputAutocapitalization(.never) 356 .textInputAutocapitalization(.never)
@@ -368,7 +368,7 @@ private struct IntegrationEditorView: View {
368 368
369 Text("Addresses the bucket as endpoint/bucket/key. MinIO needs this, and so do R2 custom domains.") 369 Text("Addresses the bucket as endpoint/bucket/key. MinIO needs this, and so do R2 custom domains.")
370 .font(.caption) 370 .font(.caption)
371 .foregroundStyle(Color(.appTextSecondary)) 371 .foregroundStyle(ThemeToken.textSecondary)
372 } 372 }
373 373
374 Section("Credentials") { 374 Section("Credentials") {
@@ -384,7 +384,7 @@ private struct IntegrationEditorView: View {
384 if existingTarget != nil { 384 if existingTarget != nil {
385 Text("Saved secret access key remains in Keychain unless you replace it.") 385 Text("Saved secret access key remains in Keychain unless you replace it.")
386 .font(.caption) 386 .font(.caption)
387 .foregroundStyle(Color(.appTextSecondary)) 387 .foregroundStyle(ThemeToken.textSecondary)
388 } 388 }
389 } 389 }
390 390
@@ -407,7 +407,7 @@ private struct IntegrationEditorView: View {
407 if let detail = trigger.detail { 407 if let detail = trigger.detail {
408 Text(detail) 408 Text(detail)
409 .font(.caption) 409 .font(.caption)
410 .foregroundStyle(Color(.appTextSecondary)) 410 .foregroundStyle(ThemeToken.textSecondary)
411 } 411 }
412 } 412 }
413 } 413 }
@@ -417,7 +417,7 @@ private struct IntegrationEditorView: View {
417 Section("Formats") { 417 Section("Formats") {
418 Text("JSON always uploads. The others are renderings of it.") 418 Text("JSON always uploads. The others are renderings of it.")
419 .font(.caption) 419 .font(.caption)
420 .foregroundStyle(Color(.appTextSecondary)) 420 .foregroundStyle(ThemeToken.textSecondary)
421 421
422 ForEach([DomainExportFormat.pdf, .csv]) { format in 422 ForEach([DomainExportFormat.pdf, .csv]) { format in
423 Toggle( 423 Toggle(
@@ -441,7 +441,7 @@ private struct IntegrationEditorView: View {
441 Section { 441 Section {
442 Text(validationMessage) 442 Text(validationMessage)
443 .font(.caption) 443 .font(.caption)
444 .foregroundStyle(Color(.statusCritical)) 444 .foregroundStyle(ThemeToken.critical)
445 } 445 }
446 } 446 }
447 } 447 }
DomainDig/IntelligenceSectionView.swift +5 −5
@@ -44,7 +44,7 @@ struct IntelligenceSectionView: View {
44 .font(appDensity.font(.caption, weight: .semibold)) 44 .font(appDensity.font(.caption, weight: .semibold))
45 Text(signal.detail) 45 Text(signal.detail)
46 .font(appDensity.font(.caption2)) 46 .font(appDensity.font(.caption2))
47 .foregroundStyle(Color(.appTextSecondary)) 47 .foregroundStyle(ThemeToken.textSecondary)
48 } 48 }
49 } 49 }
50 } 50 }
@@ -80,12 +80,12 @@ struct IntelligenceSectionView: View {
80 if item.isEphemeral { 80 if item.isEphemeral {
81 Text("Ephemeral") 81 Text("Ephemeral")
82 .font(appDensity.font(.caption2)) 82 .font(appDensity.font(.caption2))
83 .foregroundStyle(Color(.statusWarning)) 83 .foregroundStyle(ThemeToken.warning)
84 } 84 }
85 } 85 }
86 Text("First \(item.firstSeen.formatted(date: .abbreviated, time: .omitted)) • Last \(item.lastSeen.formatted(date: .abbreviated, time: .omitted)) • Seen \(item.recurrenceCount)x") 86 Text("First \(item.firstSeen.formatted(date: .abbreviated, time: .omitted)) • Last \(item.lastSeen.formatted(date: .abbreviated, time: .omitted)) • Seen \(item.recurrenceCount)x")
87 .font(appDensity.font(.caption2)) 87 .font(appDensity.font(.caption2))
88 .foregroundStyle(Color(.appTextSecondary)) 88 .foregroundStyle(ThemeToken.textSecondary)
89 } 89 }
90 } 90 }
91 } 91 }
@@ -109,7 +109,7 @@ struct IntelligenceSectionView: View {
109 VStack(alignment: .leading, spacing: 8) { 109 VStack(alignment: .leading, spacing: 8) {
110 Text(title) 110 Text(title)
111 .font(appDensity.font(.subheadline, weight: .semibold)) 111 .font(appDensity.font(.subheadline, weight: .semibold))
112 .foregroundStyle(Color(.statusInfo)) 112 .foregroundStyle(ThemeToken.info)
113 content() 113 content()
114 } 114 }
115 } 115 }
@@ -118,7 +118,7 @@ struct IntelligenceSectionView: View {
118 VStack(alignment: .leading, spacing: 3) { 118 VStack(alignment: .leading, spacing: 3) {
119 Text(date.formatted(date: .abbreviated, time: .omitted)) 119 Text(date.formatted(date: .abbreviated, time: .omitted))
120 .font(appDensity.font(.caption2)) 120 .font(appDensity.font(.caption2))
121 .foregroundStyle(Color(.appTextSecondary)) 121 .foregroundStyle(ThemeToken.textSecondary)
122 Text(title) 122 Text(title)
123 .font(appDensity.font(.caption)) 123 .font(appDensity.font(.caption))
124 } 124 }
DomainDig/LookupSummaryViews.swift +21 −21
@@ -15,7 +15,7 @@ struct SummaryView: View {
15 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing) { 15 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing) {
16 Text(field.label) 16 Text(field.label)
17 .font(appDensity.font(.caption2)) 17 .font(appDensity.font(.caption2))
18 .foregroundStyle(Color(.appTextSecondary)) 18 .foregroundStyle(ThemeToken.textSecondary)
19 Text(field.value) 19 Text(field.value)
20 .font(appDensity.font(.caption)) 20 .font(appDensity.font(.caption))
21 .foregroundStyle(ResultColors.color(for: field.tone)) 21 .foregroundStyle(ResultColors.color(for: field.tone))
@@ -25,7 +25,7 @@ struct SummaryView: View {
25 .frame(minHeight: appDensity.metrics.rowMinHeight + 12, alignment: .topLeading) 25 .frame(minHeight: appDensity.metrics.rowMinHeight + 12, alignment: .topLeading)
26 .frame(maxWidth: .infinity, alignment: .leading) 26 .frame(maxWidth: .infinity, alignment: .leading)
27 .padding(appDensity.metrics.cardPadding) 27 .padding(appDensity.metrics.cardPadding)
28 .background(Color(.appSurface)) 28 .background(ThemeToken.surface)
29 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 29 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
30 } 30 }
31 } 31 }
@@ -57,13 +57,13 @@ struct RiskSummaryCardView: View {
57 Spacer() 57 Spacer()
58 Text("Deterministic") 58 Text("Deterministic")
59 .font(appDensity.font(.caption2)) 59 .font(appDensity.font(.caption2))
60 .foregroundStyle(Color(.appTextSecondary)) 60 .foregroundStyle(ThemeToken.textSecondary)
61 } 61 }
62 62
63 if topFactors.isEmpty { 63 if topFactors.isEmpty {
64 Text("No major risk factors identified") 64 Text("No major risk factors identified")
65 .font(appDensity.font(.caption)) 65 .font(appDensity.font(.caption))
66 .foregroundStyle(Color(.appTextSecondary)) 66 .foregroundStyle(ThemeToken.textSecondary)
67 } else { 67 } else {
68 ForEach(Array(topFactors.enumerated()), id: \.offset) { _, factor in 68 ForEach(Array(topFactors.enumerated()), id: \.offset) { _, factor in
69 HStack(alignment: .top, spacing: 8) { 69 HStack(alignment: .top, spacing: 8) {
@@ -81,25 +81,25 @@ struct RiskSummaryCardView: View {
81 } 81 }
82 } 82 }
83 83
84 private var levelColor: Color { 84 private var levelColor: AnyShapeStyle {
85 switch report.riskAssessment.level { 85 switch report.riskAssessment.level {
86 case .low: 86 case .low:
87 return Color(.statusPositive) 87 return AnyShapeStyle(ThemeToken.positive)
88 case .medium: 88 case .medium:
89 return Color(.statusWarning) 89 return AnyShapeStyle(ThemeToken.warning)
90 case .high: 90 case .high:
91 return Color(.statusCritical) 91 return AnyShapeStyle(ThemeToken.critical)
92 } 92 }
93 } 93 }
94 94
95 private func factorColor(_ impact: RiskImpact) -> Color { 95 private func factorColor(_ impact: RiskImpact) -> AnyShapeStyle {
96 switch impact { 96 switch impact {
97 case .positive: 97 case .positive:
98 return Color(.statusPositive) 98 return AnyShapeStyle(ThemeToken.positive)
99 case .neutral: 99 case .neutral:
100 return .secondary 100 return AnyShapeStyle(.secondary)
101 case .negative: 101 case .negative:
102 return Color(.statusCritical) 102 return AnyShapeStyle(ThemeToken.critical)
103 } 103 }
104 } 104 }
105} 105}
@@ -115,13 +115,13 @@ struct InsightsSummaryCardView: View {
115 if insights.isEmpty { 115 if insights.isEmpty {
116 Text("No deterministic insights triggered") 116 Text("No deterministic insights triggered")
117 .font(appDensity.font(.caption)) 117 .font(appDensity.font(.caption))
118 .foregroundStyle(Color(.appTextSecondary)) 118 .foregroundStyle(ThemeToken.textSecondary)
119 } else { 119 } else {
120 ForEach(Array(insights.enumerated()), id: \.offset) { _, insight in 120 ForEach(Array(insights.enumerated()), id: \.offset) { _, insight in
121 HStack(alignment: .top, spacing: 8) { 121 HStack(alignment: .top, spacing: 8) {
122 Image(systemName: "chart.line.uptrend.xyaxis") 122 Image(systemName: "chart.line.uptrend.xyaxis")
123 .font(appDensity.font(.caption2)) 123 .font(appDensity.font(.caption2))
124 .foregroundStyle(Color(.statusInfo)) 124 .foregroundStyle(ThemeToken.info)
125 .padding(.top, 2) 125 .padding(.top, 2)
126 Text(insight) 126 Text(insight)
127 .font(appDensity.font(.caption)) 127 .font(appDensity.font(.caption))
@@ -171,7 +171,7 @@ struct StickyLookupSummaryView: View {
171 HStack(spacing: 8) { 171 HStack(spacing: 8) {
172 Label(primaryIP, systemImage: "network") 172 Label(primaryIP, systemImage: "network")
173 .font(appDensity.font(.caption)) 173 .font(appDensity.font(.caption))
174 .foregroundStyle(Color(.appTextSecondary)) 174 .foregroundStyle(ThemeToken.textSecondary)
175 Spacer(minLength: 6) 175 Spacer(minLength: 6)
176 AppCopyButton(value: primaryIP, label: "Copy IP") 176 AppCopyButton(value: primaryIP, label: "Copy IP")
177 } 177 }
@@ -197,7 +197,7 @@ struct LookupProgressOverviewView: View {
197 .foregroundStyle(.primary) 197 .foregroundStyle(.primary)
198 Text(steps.isEmpty ? "Preparing requests" : steps.joined(separator: " • ")) 198 Text(steps.isEmpty ? "Preparing requests" : steps.joined(separator: " • "))
199 .font(appDensity.font(.caption2)) 199 .font(appDensity.font(.caption2))
200 .foregroundStyle(Color(.appTextSecondary)) 200 .foregroundStyle(ThemeToken.textSecondary)
201 } 201 }
202 Spacer() 202 Spacer()
203 } 203 }
@@ -225,16 +225,16 @@ struct LookupStatusBannerView: View {
225 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 225 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
226 } 226 }
227 227
228 private var color: Color { 228 private var color: AnyShapeStyle {
229 switch resultSource { 229 switch resultSource {
230 case .live: 230 case .live:
231 return Color(.statusPositive) 231 return AnyShapeStyle(ThemeToken.positive)
232 case .cached: 232 case .cached:
233 return .secondary 233 return AnyShapeStyle(.secondary)
234 case .mixed: 234 case .mixed:
235 return Color(.statusWarning) 235 return AnyShapeStyle(ThemeToken.warning)
236 case .snapshot: 236 case .snapshot:
237 return Color(.statusWarning) 237 return AnyShapeStyle(ThemeToken.warning)
238 } 238 }
239 } 239 }
240 240
DomainDig/MonitoringView.swift +19 −19
@@ -31,7 +31,7 @@ struct MonitoringView: View {
31 !monitoringStatusMessage.isEmpty { 31 !monitoringStatusMessage.isEmpty {
32 Text(monitoringStatusMessage) 32 Text(monitoringStatusMessage)
33 .font(appDensity.font(.caption)) 33 .font(appDensity.font(.caption))
34 .foregroundStyle(Color(.appTextSecondary)) 34 .foregroundStyle(ThemeToken.textSecondary)
35 } 35 }
36 36
37 Button(viewModel.monitoringRunInProgress ? "Monitoring…" : "Run Now") { 37 Button(viewModel.monitoringRunInProgress ? "Monitoring…" : "Run Now") {
@@ -41,7 +41,7 @@ struct MonitoringView: View {
41 } 41 }
42 .padding(.vertical, 4) 42 .padding(.vertical, 4)
43 } 43 }
44 .listRowBackground(Color(.appSurface)) 44 .themedListRowBackground(.surface)
45 45
46 if viewModel.monitoringLogs.isEmpty { 46 if viewModel.monitoringLogs.isEmpty {
47 Section { 47 Section {
@@ -53,7 +53,7 @@ struct MonitoringView: View {
53 showsCardBackground: false 53 showsCardBackground: false
54 ) 54 )
55 } 55 }
56 .listRowBackground(Color(.appSurface)) 56 .themedListRowBackground(.surface)
57 } else { 57 } else {
58 Section("Recent Runs") { 58 Section("Recent Runs") {
59 ForEach(viewModel.monitoringLogs) { log in 59 ForEach(viewModel.monitoringLogs) { log in
@@ -68,12 +68,12 @@ struct MonitoringView: View {
68 Spacer() 68 Spacer()
69 Text(log.timestamp.formatted(date: .abbreviated, time: .shortened)) 69 Text(log.timestamp.formatted(date: .abbreviated, time: .shortened))
70 .font(appDensity.font(.caption2)) 70 .font(appDensity.font(.caption2))
71 .foregroundStyle(Color(.appTextSecondary)) 71 .foregroundStyle(ThemeToken.textSecondary)
72 } 72 }
73 73
74 Text(log.summary) 74 Text(log.summary)
75 .font(appDensity.font(.caption)) 75 .font(appDensity.font(.caption))
76 .foregroundStyle(Color(.appTextSecondary)) 76 .foregroundStyle(ThemeToken.textSecondary)
77 77
78 HStack(spacing: 8) { 78 HStack(spacing: 8) {
79 metricBadge(title: "\(log.domainsChecked) checked") 79 metricBadge(title: "\(log.domainsChecked) checked")
@@ -89,11 +89,11 @@ struct MonitoringView: View {
89 } 89 }
90 } 90 }
91 } 91 }
92 .listRowBackground(Color(.appSurface)) 92 .themedListRowBackground(.surface)
93 } 93 }
94 } 94 }
95 .scrollContentBackground(.hidden) 95 .scrollContentBackground(.hidden)
96 .background(Color(.appBackground)) 96 .background(ThemeToken.background)
97 .navigationTitle("Monitoring") 97 .navigationTitle("Monitoring")
98 .onAppear { 98 .onAppear {
99 viewModel.refreshMonitoringState() 99 viewModel.refreshMonitoringState()
@@ -132,7 +132,7 @@ struct MonitoringLogDetailView: View {
132 LabeledContent("Alerts", value: "\(log.alertsTriggered)") 132 LabeledContent("Alerts", value: "\(log.alertsTriggered)")
133 LabeledContent("Timestamp", value: log.timestamp.formatted(date: .abbreviated, time: .shortened)) 133 LabeledContent("Timestamp", value: log.timestamp.formatted(date: .abbreviated, time: .shortened))
134 } 134 }
135 .listRowBackground(Color(.appSurface)) 135 .themedListRowBackground(.surface)
136 136
137 Section("Domains") { 137 Section("Domains") {
138 ForEach(log.checkedDomains) { result in 138 ForEach(log.checkedDomains) { result in
@@ -151,7 +151,7 @@ struct MonitoringLogDetailView: View {
151 151
152 Text(result.summaryMessage) 152 Text(result.summaryMessage)
153 .font(appDensity.font(.caption)) 153 .font(appDensity.font(.caption))
154 .foregroundStyle(Color(.appTextSecondary)) 154 .foregroundStyle(ThemeToken.textSecondary)
155 155
156 HStack(spacing: 10) { 156 HStack(spacing: 10) {
157 Text(result.resultSource.label) 157 Text(result.resultSource.label)
@@ -161,12 +161,12 @@ struct MonitoringLogDetailView: View {
161 } 161 }
162 } 162 }
163 .font(appDensity.font(.caption2)) 163 .font(appDensity.font(.caption2))
164 .foregroundStyle(Color(.appTextSecondary)) 164 .foregroundStyle(ThemeToken.textSecondary)
165 165
166 if let errorMessage = result.errorMessage { 166 if let errorMessage = result.errorMessage {
167 Text(errorMessage) 167 Text(errorMessage)
168 .font(appDensity.font(.caption2)) 168 .font(appDensity.font(.caption2))
169 .foregroundStyle(Color(.statusWarning)) 169 .foregroundStyle(ThemeToken.warning)
170 } 170 }
171 171
172 if let historyEntryID = result.historyEntryID, 172 if let historyEntryID = result.historyEntryID,
@@ -180,32 +180,32 @@ struct MonitoringLogDetailView: View {
180 .padding(.vertical, 4) 180 .padding(.vertical, 4)
181 } 181 }
182 } 182 }
183 .listRowBackground(Color(.appSurface)) 183 .themedListRowBackground(.surface)
184 184
185 if !log.errors.isEmpty { 185 if !log.errors.isEmpty {
186 Section("Errors") { 186 Section("Errors") {
187 ForEach(log.errors, id: \.self) { error in 187 ForEach(log.errors, id: \.self) { error in
188 Text(error) 188 Text(error)
189 .font(appDensity.font(.caption)) 189 .font(appDensity.font(.caption))
190 .foregroundStyle(Color(.appTextSecondary)) 190 .foregroundStyle(ThemeToken.textSecondary)
191 } 191 }
192 } 192 }
193 .listRowBackground(Color(.appSurface)) 193 .themedListRowBackground(.surface)
194 } 194 }
195 } 195 }
196 .scrollContentBackground(.hidden) 196 .scrollContentBackground(.hidden)
197 .background(Color(.appBackground)) 197 .background(ThemeToken.background)
198 .navigationTitle("Run Details") 198 .navigationTitle("Run Details")
199 } 199 }
200 200
201 private func color(for severity: MonitoringAlertSeverity) -> Color { 201 private func color(for severity: MonitoringAlertSeverity) -> AnyShapeStyle {
202 switch severity { 202 switch severity {
203 case .info: 203 case .info:
204 return .secondary 204 return AnyShapeStyle(.secondary)
205 case .warning: 205 case .warning:
206 return Color(.statusWarning) 206 return AnyShapeStyle(ThemeToken.warning)
207 case .critical: 207 case .critical:
208 return Color(.statusCritical) 208 return AnyShapeStyle(ThemeToken.critical)
209 } 209 }
210 } 210 }
211} 211}
DomainDig/NetworkSectionView.swift +18 −18
@@ -68,7 +68,7 @@ struct NetworkSectionView: View {
68 CardView { 68 CardView {
69 Text("Reachability") 69 Text("Reachability")
70 .font(appDensity.font(.subheadline, weight: .semibold)) 70 .font(appDensity.font(.subheadline, weight: .semibold))
71 .foregroundStyle(Color(.statusInfo)) 71 .foregroundStyle(ThemeToken.info)
72 SectionTrustMetadataView(provenance: reachabilityProvenance, confidence: nil) 72 SectionTrustMetadataView(provenance: reachabilityProvenance, confidence: nil)
73 if reachabilityLoading { 73 if reachabilityLoading {
74 ProgressView("Checking ports…") 74 ProgressView("Checking ports…")
@@ -83,7 +83,7 @@ struct NetworkSectionView: View {
83 Spacer() 83 Spacer()
84 Text(row.latencyLabel) 84 Text(row.latencyLabel)
85 .font(appDensity.font(.caption2)) 85 .font(appDensity.font(.caption2))
86 .foregroundStyle(Color(.appTextSecondary)) 86 .foregroundStyle(ThemeToken.textSecondary)
87 AppStatusBadgeView(model: reachabilityBadge(row)) 87 AppStatusBadgeView(model: reachabilityBadge(row))
88 } 88 }
89 } 89 }
@@ -93,7 +93,7 @@ struct NetworkSectionView: View {
93 CardView(allowsHorizontalScroll: false) { 93 CardView(allowsHorizontalScroll: false) {
94 Text("Location") 94 Text("Location")
95 .font(appDensity.font(.subheadline, weight: .semibold)) 95 .font(appDensity.font(.subheadline, weight: .semibold))
96 .foregroundStyle(Color(.statusInfo)) 96 .foregroundStyle(ThemeToken.info)
97 SectionTrustMetadataView(provenance: geolocationProvenance, confidence: geolocationConfidence) 97 SectionTrustMetadataView(provenance: geolocationProvenance, confidence: geolocationConfidence)
98 if geolocationLoading { 98 if geolocationLoading {
99 ProgressView("Looking up location…") 99 ProgressView("Looking up location…")
@@ -125,13 +125,13 @@ struct NetworkSectionView: View {
125 CardView(allowsHorizontalScroll: false) { 125 CardView(allowsHorizontalScroll: false) {
126 Text("Port Scan") 126 Text("Port Scan")
127 .font(appDensity.font(.subheadline, weight: .semibold)) 127 .font(appDensity.font(.subheadline, weight: .semibold))
128 .foregroundStyle(Color(.statusInfo)) 128 .foregroundStyle(ThemeToken.info)
129 SectionTrustMetadataView(provenance: portScanProvenance, confidence: nil) 129 SectionTrustMetadataView(provenance: portScanProvenance, confidence: nil)
130 130
131 if isCloudflareProxied { 131 if isCloudflareProxied {
132 Text("Domain is behind Cloudflare's proxy. Results reflect the edge, not the origin.") 132 Text("Domain is behind Cloudflare's proxy. Results reflect the edge, not the origin.")
133 .font(appDensity.font(.caption2)) 133 .font(appDensity.font(.caption2))
134 .foregroundStyle(Color(.statusWarning)) 134 .foregroundStyle(ThemeToken.warning)
135 .fixedSize(horizontal: false, vertical: true) 135 .fixedSize(horizontal: false, vertical: true)
136 } 136 }
137 137
@@ -143,7 +143,7 @@ struct NetworkSectionView: View {
143 } else { 143 } else {
144 Text("Standard Ports") 144 Text("Standard Ports")
145 .font(.system(.caption, design: .monospaced)) 145 .font(.system(.caption, design: .monospaced))
146 .foregroundStyle(Color(.appTextSecondary)) 146 .foregroundStyle(ThemeToken.textSecondary)
147 PortRowsView(rows: standardPortRows) 147 PortRowsView(rows: standardPortRows)
148 } 148 }
149 149
@@ -155,7 +155,7 @@ struct NetworkSectionView: View {
155 .autocorrectionDisabled() 155 .autocorrectionDisabled()
156 .keyboardType(.numberPad) 156 .keyboardType(.numberPad)
157 .padding(10) 157 .padding(10)
158 .background(Color(.appSurface)) 158 .background(ThemeToken.surface)
159 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 159 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
160 160
161 Button("Scan") { 161 Button("Scan") {
@@ -163,7 +163,7 @@ struct NetworkSectionView: View {
163 onScanCustomPorts() 163 onScanCustomPorts()
164 } 164 }
165 .buttonStyle(.borderedProminent) 165 .buttonStyle(.borderedProminent)
166 .tint(Color(.accentFill)) 166 .tint(ThemeToken.accent)
167 .disabled(customPortScanLoading) 167 .disabled(customPortScanLoading)
168 168
169 if customPortScanLoading { 169 if customPortScanLoading {
@@ -186,13 +186,13 @@ struct NetworkSectionView: View {
186 private func reachabilityBadge(_ row: ReachabilityRowViewData) -> AppStatusBadgeModel { 186 private func reachabilityBadge(_ row: ReachabilityRowViewData) -> AppStatusBadgeModel {
187 switch row.statusTone { 187 switch row.statusTone {
188 case .success: 188 case .success:
189 return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 189 return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foreground: .positive, background: .positiveSurface)
190 case .warning: 190 case .warning:
191 return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 191 return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
192 case .failure: 192 case .failure:
193 return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 193 return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foreground: .critical, background: .criticalSurface)
194 case .primary, .secondary: 194 case .primary, .secondary:
195 return .init(title: row.statusLabel, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 195 return .init(title: row.statusLabel, systemImage: "circle", foreground: .textSecondary, background: .surfaceElevated)
196 } 196 }
197 } 197 }
198} 198}
@@ -218,14 +218,14 @@ struct PortRowsView: View {
218 if let durationLabel = row.durationLabel { 218 if let durationLabel = row.durationLabel {
219 Text(durationLabel) 219 Text(durationLabel)
220 .font(appDensity.font(.caption2)) 220 .font(appDensity.font(.caption2))
221 .foregroundStyle(Color(.appTextSecondary)) 221 .foregroundStyle(ThemeToken.textSecondary)
222 } 222 }
223 AppStatusBadgeView(model: portBadge(row)) 223 AppStatusBadgeView(model: portBadge(row))
224 } 224 }
225 if let banner = row.banner { 225 if let banner = row.banner {
226 Text(banner) 226 Text(banner)
227 .font(appDensity.font(.caption2)) 227 .font(appDensity.font(.caption2))
228 .foregroundStyle(Color(.appTextSecondary)) 228 .foregroundStyle(ThemeToken.textSecondary)
229 .padding(.leading, 8) 229 .padding(.leading, 8)
230 } 230 }
231 } 231 }
@@ -237,13 +237,13 @@ struct PortRowsView: View {
237 private func portBadge(_ row: PortScanRowViewData) -> AppStatusBadgeModel { 237 private func portBadge(_ row: PortScanRowViewData) -> AppStatusBadgeModel {
238 switch row.statusTone { 238 switch row.statusTone {
239 case .success: 239 case .success:
240 return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 240 return .init(title: row.statusLabel, systemImage: "checkmark.circle.fill", foreground: .positive, background: .positiveSurface)
241 case .warning: 241 case .warning:
242 return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 242 return .init(title: row.statusLabel, systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
243 case .failure: 243 case .failure:
244 return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 244 return .init(title: row.statusLabel, systemImage: "xmark.circle.fill", foreground: .critical, background: .criticalSurface)
245 case .primary, .secondary: 245 case .primary, .secondary:
246 return .init(title: row.statusLabel, systemImage: "circle", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated)) 246 return .init(title: row.statusLabel, systemImage: "circle", foreground: .textSecondary, background: .surfaceElevated)
247 } 247 }
248 } 248 }
249} 249}
DomainDig/OwnershipSectionView.swift +3 −3
@@ -69,7 +69,7 @@ struct OwnershipSectionView: View {
69 HStack { 69 HStack {
70 Text("History") 70 Text("History")
71 .font(appDensity.font(.caption)) 71 .font(appDensity.font(.caption))
72 .foregroundStyle(Color(.appTextSecondary)) 72 .foregroundStyle(ThemeToken.textSecondary)
73 Spacer() 73 Spacer()
74 if let onLoadHistory, history.isEmpty, !historyLoading { 74 if let onLoadHistory, history.isEmpty, !historyLoading {
75 Button("Load") { 75 Button("Load") {
@@ -87,12 +87,12 @@ struct OwnershipSectionView: View {
87 VStack(alignment: .leading, spacing: 3) { 87 VStack(alignment: .leading, spacing: 3) {
88 Text(event.date.formatted(date: .abbreviated, time: .omitted)) 88 Text(event.date.formatted(date: .abbreviated, time: .omitted))
89 .font(appDensity.font(.caption2)) 89 .font(appDensity.font(.caption2))
90 .foregroundStyle(Color(.appTextSecondary)) 90 .foregroundStyle(ThemeToken.textSecondary)
91 Text(event.summary) 91 Text(event.summary)
92 .font(appDensity.font(.caption)) 92 .font(appDensity.font(.caption))
93 Text(event.source) 93 Text(event.source)
94 .font(appDensity.font(.caption2)) 94 .font(appDensity.font(.caption2))
95 .foregroundStyle(Color(.appTextSecondary)) 95 .foregroundStyle(ThemeToken.textSecondary)
96 } 96 }
97 } 97 }
98 } else if let historyError { 98 } else if let historyError {
DomainDig/PaywallView.swift +5 −5
@@ -12,7 +12,7 @@ struct PaywallView: View {
12 Section { 12 Section {
13 Text("Pro unlocks scale, background monitoring, alerts, exports, and extended subdomain discovery. Pro+ adds shared portfolios, unlimited audits, and the full intelligence breakdown.") 13 Text("Pro unlocks scale, background monitoring, alerts, exports, and extended subdomain discovery. Pro+ adds shared portfolios, unlimited audits, and the full intelligence breakdown.")
14 .font(appDensity.font(.body, design: .default)) 14 .font(appDensity.font(.body, design: .default))
15 .foregroundStyle(Color(.appTextSecondary)) 15 .foregroundStyle(ThemeToken.textSecondary)
16 .fixedSize(horizontal: false, vertical: true) 16 .fixedSize(horizontal: false, vertical: true)
17 } 17 }
18 18
@@ -38,7 +38,7 @@ struct PaywallView: View {
38 } else if purchaseService.products.isEmpty { 38 } else if purchaseService.products.isEmpty {
39 Text("Pricing is unavailable right now.") 39 Text("Pricing is unavailable right now.")
40 .font(appDensity.font(.caption, design: .default)) 40 .font(appDensity.font(.caption, design: .default))
41 .foregroundStyle(Color(.appTextSecondary)) 41 .foregroundStyle(ThemeToken.textSecondary)
42 42
43 Button("Retry") { 43 Button("Retry") {
44 Task { 44 Task {
@@ -58,7 +58,7 @@ struct PaywallView: View {
58 .foregroundStyle(.primary) 58 .foregroundStyle(.primary)
59 Text(product.displayPrice) 59 Text(product.displayPrice)
60 .font(appDensity.font(.callout, design: .default)) 60 .font(appDensity.font(.callout, design: .default))
61 .foregroundStyle(Color(.appTextSecondary)) 61 .foregroundStyle(ThemeToken.textSecondary)
62 } 62 }
63 .frame(maxWidth: .infinity, alignment: .leading) 63 .frame(maxWidth: .infinity, alignment: .leading)
64 } 64 }
@@ -69,13 +69,13 @@ struct PaywallView: View {
69 if let statusMessage = purchaseService.statusMessage { 69 if let statusMessage = purchaseService.statusMessage {
70 Text(statusMessage) 70 Text(statusMessage)
71 .font(appDensity.font(.caption, design: .default)) 71 .font(appDensity.font(.caption, design: .default))
72 .foregroundStyle(Color(.appTextSecondary)) 72 .foregroundStyle(ThemeToken.textSecondary)
73 } 73 }
74 74
75 if let errorMessage = purchaseService.errorMessage { 75 if let errorMessage = purchaseService.errorMessage {
76 Text(errorMessage) 76 Text(errorMessage)
77 .font(appDensity.font(.caption, design: .default)) 77 .font(appDensity.font(.caption, design: .default))
78 .foregroundStyle(Color(.statusCritical)) 78 .foregroundStyle(ThemeToken.critical)
79 } 79 }
80 } 80 }
81 81
DomainDig/ResultPrimitives.swift +14 −14
@@ -19,7 +19,7 @@ struct TrackedDomainDetailHeaderView: View {
19 Text("Last refresh \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))") 19 Text("Last refresh \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))")
20 } 20 }
21 .font(.system(.caption2, design: .monospaced)) 21 .font(.system(.caption2, design: .monospaced))
22 .foregroundStyle(Color(.appTextSecondary)) 22 .foregroundStyle(ThemeToken.textSecondary)
23 } 23 }
24 } 24 }
25} 25}
@@ -93,7 +93,7 @@ struct CardView<Content: View>: View {
93 } 93 }
94 .frame(maxWidth: .infinity, alignment: .leading) 94 .frame(maxWidth: .infinity, alignment: .leading)
95 .padding(providesSurface ? appDensity.metrics.cardPadding : 0) 95 .padding(providesSurface ? appDensity.metrics.cardPadding : 0)
96 .background(providesSurface ? Color(.appSurface) : Color.clear) 96 .background(providesSurface ? AnyShapeStyle(ThemeToken.surface) : AnyShapeStyle(.clear))
97 .clipShape( 97 .clipShape(
98 RoundedRectangle(cornerRadius: providesSurface ? appDensity.metrics.cardCornerRadius : 0) 98 RoundedRectangle(cornerRadius: providesSurface ? appDensity.metrics.cardCornerRadius : 0)
99 ) 99 )
@@ -139,7 +139,7 @@ struct MessageRowView: View {
139 var body: some View { 139 var body: some View {
140 Label(text, systemImage: isError ? "exclamationmark.triangle.fill" : "info.circle") 140 Label(text, systemImage: isError ? "exclamationmark.triangle.fill" : "info.circle")
141 .font(appDensity.font(.caption)) 141 .font(appDensity.font(.caption))
142 .foregroundStyle(isError ? Color(.statusCritical) : .secondary) 142 .foregroundStyle(isError ? AnyShapeStyle(ThemeToken.critical) : AnyShapeStyle(.secondary))
143 .lineLimit(nil) 143 .lineLimit(nil)
144 .fixedSize(horizontal: false, vertical: true) 144 .fixedSize(horizontal: false, vertical: true)
145 } 145 }
@@ -164,15 +164,15 @@ struct SectionTrustMetadataView: View {
164 if let confidence { 164 if let confidence {
165 Text("Confidence \(confidence.title)") 165 Text("Confidence \(confidence.title)")
166 .font(appDensity.font(.caption2)) 166 .font(appDensity.font(.caption2))
167 .foregroundStyle(Color(.appTextSecondary)) 167 .foregroundStyle(ThemeToken.textSecondary)
168 } 168 }
169 if let provenance { 169 if let provenance {
170 Text(provenance.provider ?? provenance.source) 170 Text(provenance.provider ?? provenance.source)
171 .font(appDensity.font(.caption2)) 171 .font(appDensity.font(.caption2))
172 .foregroundStyle(Color(.appTextSecondary)) 172 .foregroundStyle(ThemeToken.textSecondary)
173 Text(provenance.resultSource.label) 173 Text(provenance.resultSource.label)
174 .font(appDensity.font(.caption2)) 174 .font(appDensity.font(.caption2))
175 .foregroundStyle(Color(.appTextSecondary)) 175 .foregroundStyle(ThemeToken.textSecondary)
176 } 176 }
177 } 177 }
178 DisclosureGroup("Details") { 178 DisclosureGroup("Details") {
@@ -212,7 +212,7 @@ struct LabeledValueRow: View {
212 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing - 1) { 212 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing - 1) {
213 Text(row.label) 213 Text(row.label)
214 .font(appDensity.font(.caption2)) 214 .font(appDensity.font(.caption2))
215 .foregroundStyle(Color(.appTextSecondary)) 215 .foregroundStyle(ThemeToken.textSecondary)
216 HStack(alignment: .firstTextBaseline, spacing: 4) { 216 HStack(alignment: .firstTextBaseline, spacing: 4) {
217 if differentiateWithoutColor, let symbol = toneSymbol { 217 if differentiateWithoutColor, let symbol = toneSymbol {
218 Image(systemName: symbol) 218 Image(systemName: symbol)
@@ -274,21 +274,21 @@ struct LabeledValueRow: View {
274/// Maps a row's semantic tone onto the app palette. 274/// Maps a row's semantic tone onto the app palette.
275/// 275///
276/// See `Docs/ACCESSIBILITY.md` for the measured contrast ratios behind these 276/// See `Docs/ACCESSIBILITY.md` for the measured contrast ratios behind these
277/// colours. Never reach for a literal (`Color(.statusCritical)`, `Color(.statusWarning)`, …) — the system 277/// colours. Never reach for a system literal (`Color.red`, `Color.yellow`, …) — the system
278/// palette fails WCAG AA badly in light mode (systemYellow is 1.28:1 on white). 278/// palette fails WCAG AA badly in light mode (systemYellow is 1.28:1 on white).
279enum ResultColors { 279enum ResultColors {
280 static func color(for tone: ResultTone) -> Color { 280 static func color(for tone: ResultTone) -> AnyShapeStyle {
281 switch tone { 281 switch tone {
282 case .primary: 282 case .primary:
283 return .primary 283 return AnyShapeStyle(.primary)
284 case .secondary: 284 case .secondary:
285 return .secondary 285 return AnyShapeStyle(.secondary)
286 case .success: 286 case .success:
287 return Color(.statusPositive) 287 return AnyShapeStyle(ThemeToken.positive)
288 case .warning: 288 case .warning:
289 return Color(.statusWarning) 289 return AnyShapeStyle(ThemeToken.warning)
290 case .failure: 290 case .failure:
291 return Color(.statusCritical) 291 return AnyShapeStyle(ThemeToken.critical)
292 } 292 }
293 } 293 }
294} 294}
DomainDig/ScheduledReportsView.swift +7 −7
@@ -13,7 +13,7 @@ struct ScheduledReportsView: View {
13 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { 13 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) {
14 Text("Scheduled reports require Pro.") 14 Text("Scheduled reports require Pro.")
15 .font(appDensity.font(.caption)) 15 .font(appDensity.font(.caption))
16 .foregroundStyle(Color(.appTextSecondary)) 16 .foregroundStyle(ThemeToken.textSecondary)
17 } 17 }
18 18
19 Toggle("Scheduled Reports", isOn: Binding( 19 Toggle("Scheduled Reports", isOn: Binding(
@@ -59,7 +59,7 @@ struct ScheduledReportsView: View {
59 if let statusMessage { 59 if let statusMessage {
60 Text(statusMessage) 60 Text(statusMessage)
61 .font(appDensity.font(.caption)) 61 .font(appDensity.font(.caption))
62 .foregroundStyle(Color(.appTextSecondary)) 62 .foregroundStyle(ThemeToken.textSecondary)
63 } 63 }
64 64
65 Button(isGenerating ? "Generating…" : "Generate Now") { 65 Button(isGenerating ? "Generating…" : "Generate Now") {
@@ -67,7 +67,7 @@ struct ScheduledReportsView: View {
67 } 67 }
68 .disabled(isGenerating || !FeatureAccessService.hasAccess(to: .automatedMonitoring)) 68 .disabled(isGenerating || !FeatureAccessService.hasAccess(to: .automatedMonitoring))
69 } 69 }
70 .listRowBackground(Color(.appSurface)) 70 .themedListRowBackground(.surface)
71 71
72 if logs.isEmpty { 72 if logs.isEmpty {
73 Section { 73 Section {
@@ -79,7 +79,7 @@ struct ScheduledReportsView: View {
79 showsCardBackground: false 79 showsCardBackground: false
80 ) 80 )
81 } 81 }
82 .listRowBackground(Color(.appSurface)) 82 .themedListRowBackground(.surface)
83 } else { 83 } else {
84 Section("Recent Reports") { 84 Section("Recent Reports") {
85 ForEach(logs) { log in 85 ForEach(logs) { log in
@@ -91,16 +91,16 @@ struct ScheduledReportsView: View {
91 .foregroundStyle(.primary) 91 .foregroundStyle(.primary)
92 Text(log.generatedAt.formatted(date: .abbreviated, time: .shortened)) 92 Text(log.generatedAt.formatted(date: .abbreviated, time: .shortened))
93 .font(.caption) 93 .font(.caption)
94 .foregroundStyle(Color(.appTextSecondary)) 94 .foregroundStyle(ThemeToken.textSecondary)
95 } 95 }
96 } 96 }
97 } 97 }
98 } 98 }
99 .listRowBackground(Color(.appSurface)) 99 .themedListRowBackground(.surface)
100 } 100 }
101 } 101 }
102 .scrollContentBackground(.hidden) 102 .scrollContentBackground(.hidden)
103 .background(Color(.appBackground)) 103 .background(ThemeToken.background)
104 .navigationTitle("Scheduled Reports") 104 .navigationTitle("Scheduled Reports")
105 } 105 }
106 106
DomainDig/SettingsViews.swift +41 −24
@@ -38,13 +38,13 @@ struct SettingsView: View {
38 if let statusMessage = purchaseService.statusMessage { 38 if let statusMessage = purchaseService.statusMessage {
39 Text(statusMessage) 39 Text(statusMessage)
40 .font(appDensity.font(.caption, design: .default)) 40 .font(appDensity.font(.caption, design: .default))
41 .foregroundStyle(Color(.appTextSecondary)) 41 .foregroundStyle(ThemeToken.textSecondary)
42 } 42 }
43 43
44 if let errorMessage = purchaseService.errorMessage { 44 if let errorMessage = purchaseService.errorMessage {
45 Text(errorMessage) 45 Text(errorMessage)
46 .font(appDensity.font(.caption, design: .default)) 46 .font(appDensity.font(.caption, design: .default))
47 .foregroundStyle(Color(.statusCritical)) 47 .foregroundStyle(ThemeToken.critical)
48 } 48 }
49 } 49 }
50 50
@@ -105,8 +105,10 @@ struct SettingsView: View {
105} 105}
106 106
107private struct DisplaySettingsView: View { 107private struct DisplaySettingsView: View {
108 @Environment(\.appDensity) private var appDensity
108 @AppStorage(AppDensity.userDefaultsKey) private var storedDensity = AppDensity.compact.rawValue 109 @AppStorage(AppDensity.userDefaultsKey) private var storedDensity = AppDensity.compact.rawValue
109 @AppStorage(AppAppearance.userDefaultsKey) private var storedAppearance = AppAppearance.system.rawValue 110 @AppStorage(AppAppearance.userDefaultsKey) private var storedAppearance = AppAppearance.system.rawValue
111 @AppStorage(AccentTheme.userDefaultsKey) private var storedAccent = AccentTheme.default.rawValue
110 112
111 var body: some View { 113 var body: some View {
112 Form { 114 Form {
@@ -117,6 +119,21 @@ private struct DisplaySettingsView: View {
117 } 119 }
118 } 120 }
119 121
122 Picker("Accent", selection: $storedAccent) {
123 ForEach(AccentTheme.allCases) { accent in
124 Text(accent.title).tag(accent.rawValue)
125 }
126 }
127 .disabled(!FeatureAccessService.hasAccess(to: .accentTheme))
128
129 Text(
130 FeatureAccessService.hasAccess(to: .accentTheme)
131 ? "Changes the accent only. Status colours keep their meaning."
132 : "Accent themes are \(FeatureAccessService.upgradeMessage(for: .accentTheme))."
133 )
134 .font(appDensity.font(.caption, design: .default))
135 .foregroundStyle(ThemeToken.textSecondary)
136
120 Picker("Density", selection: $storedDensity) { 137 Picker("Density", selection: $storedDensity) {
121 ForEach(AppDensity.allCases) { density in 138 ForEach(AppDensity.allCases) { density in
122 Text(density.title).tag(density.rawValue) 139 Text(density.title).tag(density.rawValue)
@@ -172,7 +189,7 @@ private struct HistoryNetworkSettingsView: View {
172 189
173 Text(viewModel.historyRetentionCaption) 190 Text(viewModel.historyRetentionCaption)
174 .font(appDensity.font(.caption, design: .default)) 191 .font(appDensity.font(.caption, design: .default))
175 .foregroundStyle(Color(.appTextSecondary)) 192 .foregroundStyle(ThemeToken.textSecondary)
176 } 193 }
177 194
178 Section("Network") { 195 Section("Network") {
@@ -191,7 +208,7 @@ private struct HistoryNetworkSettingsView: View {
191 if let customResolverError { 208 if let customResolverError {
192 Text(customResolverError) 209 Text(customResolverError)
193 .font(appDensity.font(.caption, design: .default)) 210 .font(appDensity.font(.caption, design: .default))
194 .foregroundStyle(Color(.statusCritical)) 211 .foregroundStyle(ThemeToken.critical)
195 } 212 }
196 } 213 }
197 214
@@ -203,13 +220,13 @@ private struct HistoryNetworkSettingsView: View {
203 220
204 Text(selectedProfile.detail) 221 Text(selectedProfile.detail)
205 .font(appDensity.font(.caption, design: .default)) 222 .font(appDensity.font(.caption, design: .default))
206 .foregroundStyle(Color(.appTextSecondary)) 223 .foregroundStyle(ThemeToken.textSecondary)
207 224
208 Toggle("Allow third-party enrichment", isOn: $allowsThirdPartyEnrichment) 225 Toggle("Allow third-party enrichment", isOn: $allowsThirdPartyEnrichment)
209 226
210 Text(Self.enrichmentCaption) 227 Text(Self.enrichmentCaption)
211 .font(appDensity.font(.caption, design: .default)) 228 .font(appDensity.font(.caption, design: .default))
212 .foregroundStyle(Color(.appTextSecondary)) 229 .foregroundStyle(ThemeToken.textSecondary)
213 } 230 }
214 } 231 }
215 .navigationTitle("History & Network") 232 .navigationTitle("History & Network")
@@ -280,16 +297,16 @@ private struct CloudSyncSettingsView: View {
280 297
281 Text("iCloud Sync stores DomainDig data in your private iCloud account. DomainDig does not operate a sync server. Disabling sync keeps local data on this device.") 298 Text("iCloud Sync stores DomainDig data in your private iCloud account. DomainDig does not operate a sync server. Disabling sync keeps local data on this device.")
282 .font(appDensity.font(.caption, design: .default)) 299 .font(appDensity.font(.caption, design: .default))
283 .foregroundStyle(Color(.appTextSecondary)) 300 .foregroundStyle(ThemeToken.textSecondary)
284 301
285 Text(cloudSyncService.detailMessage) 302 Text(cloudSyncService.detailMessage)
286 .font(appDensity.font(.caption, design: .default)) 303 .font(appDensity.font(.caption, design: .default))
287 .foregroundStyle(Color(.appTextSecondary)) 304 .foregroundStyle(ThemeToken.textSecondary)
288 305
289 if let lastErrorMessage = cloudSyncService.lastErrorMessage { 306 if let lastErrorMessage = cloudSyncService.lastErrorMessage {
290 Text(lastErrorMessage) 307 Text(lastErrorMessage)
291 .font(appDensity.font(.caption, design: .default)) 308 .font(appDensity.font(.caption, design: .default))
292 .foregroundStyle(Color(.statusCritical)) 309 .foregroundStyle(ThemeToken.critical)
293 } 310 }
294 } 311 }
295 } 312 }
@@ -342,7 +359,7 @@ private struct LocalAPISettingsView: View {
342 if let statusMessage = localAPIService.statusMessage { 359 if let statusMessage = localAPIService.statusMessage {
343 Text(statusMessage) 360 Text(statusMessage)
344 .font(appDensity.font(.caption, design: .default)) 361 .font(appDensity.font(.caption, design: .default))
345 .foregroundStyle(Color(.appTextSecondary)) 362 .foregroundStyle(ThemeToken.textSecondary)
346 } 363 }
347 } 364 }
348 365
@@ -361,7 +378,7 @@ private struct LocalAPISettingsView: View {
361 378
362 Text("Every request requires either `Authorization: Bearer <token>` or `X-API-Token`. DomainDig stores the token in Keychain and only binds the server to localhost.") 379 Text("Every request requires either `Authorization: Bearer <token>` or `X-API-Token`. DomainDig stores the token in Keychain and only binds the server to localhost.")
363 .font(appDensity.font(.caption, design: .default)) 380 .font(appDensity.font(.caption, design: .default))
364 .foregroundStyle(Color(.appTextSecondary)) 381 .foregroundStyle(ThemeToken.textSecondary)
365 } 382 }
366 383
367 Section("Request Logging") { 384 Section("Request Logging") {
@@ -376,7 +393,7 @@ private struct LocalAPISettingsView: View {
376 if localAPIService.requestLogs.isEmpty { 393 if localAPIService.requestLogs.isEmpty {
377 Text("No local API requests logged yet.") 394 Text("No local API requests logged yet.")
378 .font(appDensity.font(.caption, design: .default)) 395 .font(appDensity.font(.caption, design: .default))
379 .foregroundStyle(Color(.appTextSecondary)) 396 .foregroundStyle(ThemeToken.textSecondary)
380 } else { 397 } else {
381 ForEach(localAPIService.requestLogs.prefix(25)) { log in 398 ForEach(localAPIService.requestLogs.prefix(25)) { log in
382 VStack(alignment: .leading, spacing: 4) { 399 VStack(alignment: .leading, spacing: 4) {
@@ -386,16 +403,16 @@ private struct LocalAPISettingsView: View {
386 Spacer() 403 Spacer()
387 Text("\(log.statusCode)") 404 Text("\(log.statusCode)")
388 .font(appDensity.font(.caption, design: .default)) 405 .font(appDensity.font(.caption, design: .default))
389 .foregroundStyle(log.statusCode >= 400 ? Color(.statusCritical) : .secondary) 406 .foregroundStyle(log.statusCode >= 400 ? AnyShapeStyle(ThemeToken.critical) : AnyShapeStyle(.secondary))
390 } 407 }
391 408
392 Text(log.timestamp.formatted(date: .abbreviated, time: .standard)) 409 Text(log.timestamp.formatted(date: .abbreviated, time: .standard))
393 .font(appDensity.font(.caption2, design: .default)) 410 .font(appDensity.font(.caption2, design: .default))
394 .foregroundStyle(Color(.appTextSecondary)) 411 .foregroundStyle(ThemeToken.textSecondary)
395 412
396 Text("\(Int(log.duration * 1000)) ms") 413 Text("\(Int(log.duration * 1000)) ms")
397 .font(appDensity.font(.caption2, design: .default)) 414 .font(appDensity.font(.caption2, design: .default))
398 .foregroundStyle(Color(.appTextSecondary)) 415 .foregroundStyle(ThemeToken.textSecondary)
399 } 416 }
400 } 417 }
401 } 418 }
@@ -571,13 +588,13 @@ private struct MonitoringSettingsView: View {
571 if let monitoringStatusMessage = viewModel.monitoringStatusMessage { 588 if let monitoringStatusMessage = viewModel.monitoringStatusMessage {
572 Text(monitoringStatusMessage) 589 Text(monitoringStatusMessage)
573 .font(appDensity.font(.caption, design: .default)) 590 .font(appDensity.font(.caption, design: .default))
574 .foregroundStyle(Color(.appTextSecondary)) 591 .foregroundStyle(ThemeToken.textSecondary)
575 } 592 }
576 593
577 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { 594 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) {
578 Text("Background monitoring and alerts are available in Pro.") 595 Text("Background monitoring and alerts are available in Pro.")
579 .font(appDensity.font(.caption, design: .default)) 596 .font(appDensity.font(.caption, design: .default))
580 .foregroundStyle(Color(.appTextSecondary)) 597 .foregroundStyle(ThemeToken.textSecondary)
581 } 598 }
582 } 599 }
583 } 600 }
@@ -655,7 +672,7 @@ private struct DataPortabilitySettingsView: View {
655 672
656 Text(importMode.explanation) 673 Text(importMode.explanation)
657 .font(appDensity.font(.caption, design: .default)) 674 .font(appDensity.font(.caption, design: .default))
658 .foregroundStyle(Color(.appTextSecondary)) 675 .foregroundStyle(ThemeToken.textSecondary)
659 676
660 Button("Export Full Backup") { 677 Button("Export Full Backup") {
661 exportFullBackup() 678 exportFullBackup()
@@ -712,12 +729,12 @@ private struct DataPortabilitySettingsView: View {
712 729
713 Text("Data stays on this device unless you export it. Backup files can include domain history, monitoring settings, and notes. Imported files are processed on-device.") 730 Text("Data stays on this device unless you export it. Backup files can include domain history, monitoring settings, and notes. Imported files are processed on-device.")
714 .font(appDensity.font(.caption, design: .default)) 731 .font(appDensity.font(.caption, design: .default))
715 .foregroundStyle(Color(.appTextSecondary)) 732 .foregroundStyle(ThemeToken.textSecondary)
716 733
717 if let portabilityStatusMessage = viewModel.portabilityStatusMessage { 734 if let portabilityStatusMessage = viewModel.portabilityStatusMessage {
718 Text(portabilityStatusMessage) 735 Text(portabilityStatusMessage)
719 .font(appDensity.font(.caption, design: .default)) 736 .font(appDensity.font(.caption, design: .default))
720 .foregroundStyle(Color(.appTextSecondary)) 737 .foregroundStyle(ThemeToken.textSecondary)
721 } 738 }
722 } 739 }
723 740
@@ -726,7 +743,7 @@ private struct DataPortabilitySettingsView: View {
726 Section("Import Debug") { 743 Section("Import Debug") {
727 Text(importDebugStatus) 744 Text(importDebugStatus)
728 .font(appDensity.font(.caption, design: .default)) 745 .font(appDensity.font(.caption, design: .default))
729 .foregroundStyle(Color(.appTextSecondary)) 746 .foregroundStyle(ThemeToken.textSecondary)
730 .textSelection(.enabled) 747 .textSelection(.enabled)
731 } 748 }
732 } 749 }
@@ -1032,14 +1049,14 @@ private struct DataManagementSettingsView: View {
1032 if let deleteAllSuccessMessage { 1049 if let deleteAllSuccessMessage {
1033 Text(deleteAllSuccessMessage) 1050 Text(deleteAllSuccessMessage)
1034 .font(.footnote.weight(.medium)) 1051 .font(.footnote.weight(.medium))
1035 .foregroundStyle(Color(.appTextSecondary)) 1052 .foregroundStyle(ThemeToken.textSecondary)
1036 .padding(.horizontal, 14) 1053 .padding(.horizontal, 14)
1037 .padding(.vertical, 10) 1054 .padding(.vertical, 10)
1038 // Reduce Transparency swaps the blur for an opaque surface. 1055 // Reduce Transparency swaps the blur for an opaque surface.
1039 // On iOS 26+ the system also composites its own translucency 1056 // On iOS 26+ the system also composites its own translucency
1040 // that the app cannot declare — verify there too (Phase 6). 1057 // that the app cannot declare — verify there too (Phase 6).
1041 .background( 1058 .background(
1042 Capsule().fill(reduceTransparency ? AnyShapeStyle(Color(.appSurfaceElevated)) : AnyShapeStyle(.thinMaterial)) 1059 Capsule().fill(reduceTransparency ? AnyShapeStyle(ThemeToken.surfaceElevated) : AnyShapeStyle(.thinMaterial))
1043 ) 1060 )
1044 .padding(.bottom, 8) 1061 .padding(.bottom, 8)
1045 .transition(.move(edge: .bottom).combined(with: .opacity)) 1062 .transition(.move(edge: .bottom).combined(with: .opacity))
@@ -1101,7 +1118,7 @@ private struct DataImportPreviewSheet: View {
1101 Section("Warnings") { 1118 Section("Warnings") {
1102 ForEach(preview.warnings, id: \.self) { warning in 1119 ForEach(preview.warnings, id: \.self) { warning in
1103 Text(warning) 1120 Text(warning)
1104 .foregroundStyle(Color(.appTextSecondary)) 1121 .foregroundStyle(ThemeToken.textSecondary)
1105 } 1122 }
1106 } 1123 }
1107 } 1124 }
DomainDig/SubdomainsSectionView.swift +5 −5
@@ -100,16 +100,16 @@ struct SubdomainsSectionView: View {
100 if !groups.isEmpty { 100 if !groups.isEmpty {
101 Text("Groups") 101 Text("Groups")
102 .font(appDensity.font(.caption2)) 102 .font(appDensity.font(.caption2))
103 .foregroundStyle(Color(.appTextSecondary)) 103 .foregroundStyle(ThemeToken.textSecondary)
104 ForEach(groups) { group in 104 ForEach(groups) { group in
105 HStack { 105 HStack {
106 Text("\(group.label).*") 106 Text("\(group.label).*")
107 .font(appDensity.font(.caption)) 107 .font(appDensity.font(.caption))
108 .foregroundStyle(Color(.statusInfo)) 108 .foregroundStyle(ThemeToken.info)
109 Spacer() 109 Spacer()
110 Text("\(group.subdomains.count)") 110 Text("\(group.subdomains.count)")
111 .font(appDensity.font(.caption2)) 111 .font(appDensity.font(.caption2))
112 .foregroundStyle(Color(.appTextSecondary)) 112 .foregroundStyle(ThemeToken.textSecondary)
113 } 113 }
114 } 114 }
115 } 115 }
@@ -127,10 +127,10 @@ struct SubdomainsSectionView: View {
127 if row.isInteresting { 127 if row.isInteresting {
128 Text("Interesting") 128 Text("Interesting")
129 .font(.system(.caption2, design: .monospaced)) 129 .font(.system(.caption2, design: .monospaced))
130 .foregroundStyle(Color(.statusWarning)) 130 .foregroundStyle(ThemeToken.warning)
131 .padding(.horizontal, 8) 131 .padding(.horizontal, 8)
132 .padding(.vertical, 4) 132 .padding(.vertical, 4)
133 .background(Color(.statusWarningSurface)) 133 .background(ThemeToken.warningSurface)
134 .clipShape(Capsule()) 134 .clipShape(Capsule())
135 } 135 }
136 } 136 }
DomainDig/Theme.swift added +167
@@ -0,0 +1,167 @@
1import SwiftUI
2
3/// One of the app's semantic colours, named rather than resolved.
4///
5/// A token instead of a `Color` so a colour chosen outside a view body — a
6/// status badge's model, for one — can say which colour it means and leave the
7/// resolving to the view that draws it. That is what lets the whole palette sit
8/// in the environment rather than only the parts used inside `body`.
9///
10/// The case names drop the `app`/`status` prefixes that the colorsets carry so
11/// they do not collide with the style accessors below, which keep the prefixed
12/// spelling the call sites already used. The raw value is the colorset's name.
13nonisolated enum ThemeToken: String, CaseIterable, Sendable {
14 case background = "AppBackground"
15 case surface = "AppSurface"
16 case surfaceElevated = "AppSurfaceElevated"
17 case textSecondary = "AppTextSecondary"
18 case separator = "AppSeparator"
19 case onAccent = "AppOnAccent"
20 case accent = "AccentFill"
21 case positive = "StatusPositive"
22 case positiveSurface = "StatusPositiveSurface"
23 case warning = "StatusWarning"
24 case warningSurface = "StatusWarningSurface"
25 case critical = "StatusCritical"
26 case criticalSurface = "StatusCriticalSurface"
27 case info = "StatusInfo"
28 case infoSurface = "StatusInfoSurface"
29 case neutral = "StatusNeutral"
30 case neutralSurface = "StatusNeutralSurface"
31
32 /// The palette in `Shared/Colors.xcassets`, which stays the single
33 /// definition of every default colour.
34 ///
35 /// `Docs/ACCESSIBILITY.txt` names that palette as the guard against
36 /// contrast regressions, and reading the defaults from it here is what
37 /// keeps the guard: a theme overrides individual tokens, it does not
38 /// replace the set.
39 ///
40 /// Looked up by name rather than through the generated `ColorResource`
41 /// symbols, which are MainActor-isolated and so cannot be read from
42 /// `ShapeStyle.resolve(in:)`. `ThemeTests` asserts that every token still
43 /// has a colorset and that no colorset is left without a token.
44 var assetColor: Color {
45 Color(rawValue, bundle: .main)
46 }
47}
48
49/// A token is itself a style, so it can be handed straight to `foregroundStyle`,
50/// `background`, `tint` or `fill` and resolve against the environment's theme
51/// when the view draws.
52///
53/// This is what keeps the refactor from adding an `@Environment(\.theme)`
54/// property to every view in the app: in a style position the token needs no
55/// one to resolve it. Only a colour used as a plain value — a list row's
56/// background, which takes a view rather than a style — needs the environment
57/// read explicitly.
58nonisolated extension ThemeToken: ShapeStyle {
59 func resolve(in environment: EnvironmentValues) -> some ShapeStyle {
60 environment.theme[self]
61 }
62}
63
64/// The colours a screen draws with.
65///
66/// Carried in the environment so an accent choice reaches every view without
67/// threading a parameter. The default resolves every token from the asset
68/// catalog, so an app with no theme chosen renders exactly as it did before
69/// this existed.
70nonisolated struct Theme: Equatable, Sendable {
71 /// What this theme changes about the palette. Empty for the default.
72 private let overrides: [ThemeToken: Color]
73
74 init(overrides: [ThemeToken: Color] = [:]) {
75 self.overrides = overrides
76 }
77
78 static let `default` = Theme()
79
80 subscript(token: ThemeToken) -> Color {
81 overrides[token] ?? token.assetColor
82 }
83
84 /// For the few places that need a `Color` rather than a style, such as a
85 /// list row's background.
86 var appBackground: Color { self[.background] }
87 var appSurface: Color { self[.surface] }
88 var appSurfaceElevated: Color { self[.surfaceElevated] }
89 var appTextSecondary: Color { self[.textSecondary] }
90 var accentFill: Color { self[.accent] }
91}
92
93/// An accent a user can pick.
94///
95/// Only the accent tokens are overridden. The status colours keep their palette
96/// values deliberately: "critical" means one thing, and letting an accent
97/// recolour it would undo the contrast work phases 1–5 of #21 did and leave the
98/// palette no longer answerable for its own contrast.
99nonisolated enum AccentTheme: String, Codable, CaseIterable, Identifiable, Sendable {
100 case `default`
101 case graphite
102 case forest
103 case plum
104
105 static let userDefaultsKey = "appAccentTheme"
106
107 var id: String { rawValue }
108
109 var title: String {
110 switch self {
111 case .default: return "Default"
112 case .graphite: return "Graphite"
113 case .forest: return "Forest"
114 case .plum: return "Plum"
115 }
116 }
117
118 var theme: Theme {
119 guard let fill = accentFill else { return .default }
120 return Theme(overrides: [.accent: fill, .onAccent: .white])
121 }
122
123 private var accentFill: Color? {
124 switch self {
125 case .default:
126 return nil
127 case .graphite:
128 return Color(red: 0.26, green: 0.28, blue: 0.31)
129 case .forest:
130 return Color(red: 0.13, green: 0.40, blue: 0.27)
131 case .plum:
132 return Color(red: 0.42, green: 0.20, blue: 0.44)
133 }
134 }
135}
136
137nonisolated private struct ThemeKey: EnvironmentKey {
138 static let defaultValue = Theme.default
139}
140
141extension EnvironmentValues {
142 /// Nonisolated so `ShapeStyle.resolve(in:)`, which is itself nonisolated,
143 /// can read it.
144 nonisolated var theme: Theme {
145 get { self[ThemeKey.self] }
146 set { self[ThemeKey.self] = newValue }
147 }
148}
149
150/// `listRowBackground` takes a view rather than a style, so a token cannot be
151/// handed to it directly — it has to be resolved first, which needs the
152/// environment. This is the one place in the app that reads the theme to get a
153/// `Color` rather than passing a token as a style.
154private struct ThemedListRowBackground: ViewModifier {
155 @Environment(\.theme) private var theme
156 let token: ThemeToken
157
158 func body(content: Content) -> some View {
159 content.listRowBackground(theme[token])
160 }
161}
162
163extension View {
164 func themedListRowBackground(_ token: ThemeToken) -> some View {
165 modifier(ThemedListRowBackground(token: token))
166 }
167}
DomainDig/TimelineView.swift +9 −9
@@ -45,12 +45,12 @@ struct TimelineView: View {
45 } 45 }
46 } 46 }
47 } 47 }
48 .listRowBackground(Color(.appSurface)) 48 .themedListRowBackground(.surface)
49 } 49 }
50 } 50 }
51 } 51 }
52 .scrollContentBackground(.hidden) 52 .scrollContentBackground(.hidden)
53 .background(Color(.appBackground)) 53 .background(ThemeToken.background)
54 .navigationTitle(domain) 54 .navigationTitle(domain)
55 .toolbar { 55 .toolbar {
56 ToolbarItemGroup(placement: .topBarTrailing) { 56 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -117,8 +117,8 @@ private struct TimelineRow: View {
117 model: .init( 117 model: .init(
118 title: severity.title, 118 title: severity.title,
119 systemImage: "arrow.triangle.2.circlepath", 119 systemImage: "arrow.triangle.2.circlepath",
120 foregroundColor: severity == .high ? Color(.statusCritical) : Color(.statusWarning), 120 foreground: severity == .high ? .critical : .warning,
121 backgroundColor: (severity == .high ? AppStatusTone.critical : .warning).surface 121 background: (severity == .high ? AppStatusTone.critical : .warning).surface
122 ) 122 )
123 ) 123 )
124 } 124 }
@@ -126,7 +126,7 @@ private struct TimelineRow: View {
126 126
127 Text(summary.changeSummaryMessage ?? "No change summary") 127 Text(summary.changeSummaryMessage ?? "No change summary")
128 .font(appDensity.font(.caption)) 128 .font(appDensity.font(.caption))
129 .foregroundStyle(Color(.appTextSecondary)) 129 .foregroundStyle(ThemeToken.textSecondary)
130 .lineLimit(2) 130 .lineLimit(2)
131 131
132 HStack(spacing: 8) { 132 HStack(spacing: 8) {
@@ -138,14 +138,14 @@ private struct TimelineRow: View {
138 } 138 }
139 } 139 }
140 .font(appDensity.font(.caption2)) 140 .font(appDensity.font(.caption2))
141 .foregroundStyle(Color(.appTextSecondary)) 141 .foregroundStyle(ThemeToken.textSecondary)
142 142
143 if !entry.intelligenceTimeline.isEmpty { 143 if !entry.intelligenceTimeline.isEmpty {
144 VStack(alignment: .leading, spacing: 4) { 144 VStack(alignment: .leading, spacing: 4) {
145 ForEach(Array(entry.intelligenceTimeline.prefix(2))) { event in 145 ForEach(Array(entry.intelligenceTimeline.prefix(2))) { event in
146 Text("\(event.title): \(event.detail)") 146 Text("\(event.title): \(event.detail)")
147 .font(appDensity.font(.caption2)) 147 .font(appDensity.font(.caption2))
148 .foregroundStyle(Color(.appTextSecondary)) 148 .foregroundStyle(ThemeToken.textSecondary)
149 .lineLimit(1) 149 .lineLimit(1)
150 } 150 }
151 } 151 }
@@ -162,7 +162,7 @@ private struct TimelineRow: View {
162 .lineLimit(1) 162 .lineLimit(1)
163 } 163 }
164 .font(appDensity.font(.caption2)) 164 .font(appDensity.font(.caption2))
165 .foregroundStyle(Color(.appTextSecondary)) 165 .foregroundStyle(ThemeToken.textSecondary)
166 } 166 }
167 } 167 }
168} 168}
@@ -205,7 +205,7 @@ struct TimelineDiffView: View {
205 } 205 }
206 .padding() 206 .padding()
207 } 207 }
208 .background(Color(.appBackground)) 208 .background(ThemeToken.background)
209 .navigationTitle("Compare Snapshots") 209 .navigationTitle("Compare Snapshots")
210 .navigationBarTitleDisplayMode(.inline) 210 .navigationBarTitleDisplayMode(.inline)
211 .onAppear { 211 .onAppear {
DomainDig/WatchlistView.swift +34 −34
@@ -37,11 +37,11 @@ struct WatchlistView: View {
37 Section("Refresh Progress") { 37 Section("Refresh Progress") {
38 VStack(alignment: .leading, spacing: 8) { 38 VStack(alignment: .leading, spacing: 8) {
39 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1))) 39 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1)))
40 .tint(Color(.statusInfo)) 40 .tint(ThemeToken.info)
41 HStack { 41 HStack {
42 Text(viewModel.batchProgressLabel) 42 Text(viewModel.batchProgressLabel)
43 .font(appDensity.font(.caption)) 43 .font(appDensity.font(.caption))
44 .foregroundStyle(Color(.appTextSecondary)) 44 .foregroundStyle(ThemeToken.textSecondary)
45 Spacer() 45 Spacer()
46 if viewModel.batchLookupRunning { 46 if viewModel.batchLookupRunning {
47 Button("Cancel") { 47 Button("Cancel") {
@@ -58,7 +58,7 @@ struct WatchlistView: View {
58 } 58 }
59 .padding(.vertical, 4) 59 .padding(.vertical, 4)
60 } 60 }
61 .listRowBackground(Color(.appSurface)) 61 .themedListRowBackground(.surface)
62 } 62 }
63 63
64 if viewModel.filteredTrackedDomains.isEmpty { 64 if viewModel.filteredTrackedDomains.isEmpty {
@@ -71,15 +71,15 @@ struct WatchlistView: View {
71 showsCardBackground: false 71 showsCardBackground: false
72 ) 72 )
73 } 73 }
74 .listRowBackground(Color(.appSurface)) 74 .themedListRowBackground(.surface)
75 } else { 75 } else {
76 if let limitMessage = FeatureAccessService.trackedDomainLimitMessage(currentCount: viewModel.trackedDomains.count) { 76 if let limitMessage = FeatureAccessService.trackedDomainLimitMessage(currentCount: viewModel.trackedDomains.count) {
77 Section { 77 Section {
78 Text(limitMessage) 78 Text(limitMessage)
79 .font(appDensity.font(.caption)) 79 .font(appDensity.font(.caption))
80 .foregroundStyle(Color(.appTextSecondary)) 80 .foregroundStyle(ThemeToken.textSecondary)
81 } 81 }
82 .listRowBackground(Color(.appSurface)) 82 .themedListRowBackground(.surface)
83 } 83 }
84 84
85 if !pinnedDomains.isEmpty { 85 if !pinnedDomains.isEmpty {
@@ -93,7 +93,7 @@ struct WatchlistView: View {
93 } 93 }
94 .animation(reduceMotion ? nil : .easeInOut(duration: 0.2), value: viewModel.filteredTrackedDomains.map(\.id)) 94 .animation(reduceMotion ? nil : .easeInOut(duration: 0.2), value: viewModel.filteredTrackedDomains.map(\.id))
95 .scrollContentBackground(.hidden) 95 .scrollContentBackground(.hidden)
96 .background(Color(.appBackground)) 96 .background(ThemeToken.background)
97 .navigationTitle("Watchlist") 97 .navigationTitle("Watchlist")
98 .searchable(text: $viewModel.watchlistSearchText, prompt: "Search tracked domains") 98 .searchable(text: $viewModel.watchlistSearchText, prompt: "Search tracked domains")
99 .toolbar { 99 .toolbar {
@@ -180,14 +180,14 @@ struct WatchlistView: View {
180 Section { 180 Section {
181 Text("Adds the domain directly to your watchlist so monitoring can run without a prior inspection.") 181 Text("Adds the domain directly to your watchlist so monitoring can run without a prior inspection.")
182 .font(appDensity.font(.caption)) 182 .font(appDensity.font(.caption))
183 .foregroundStyle(Color(.appTextSecondary)) 183 .foregroundStyle(ThemeToken.textSecondary)
184 } 184 }
185 185
186 if let addDomainError { 186 if let addDomainError {
187 Section { 187 Section {
188 Text(addDomainError) 188 Text(addDomainError)
189 .font(appDensity.font(.caption)) 189 .font(appDensity.font(.caption))
190 .foregroundStyle(Color(.statusCritical)) 190 .foregroundStyle(ThemeToken.critical)
191 } 191 }
192 } 192 }
193 } 193 }
@@ -239,7 +239,7 @@ struct WatchlistView: View {
239 .foregroundStyle(.primary) 239 .foregroundStyle(.primary)
240 Text([view.tag, view.filter.title, view.sort.title].compactMap { $0 }.joined(separator: " • ")) 240 Text([view.tag, view.filter.title, view.sort.title].compactMap { $0 }.joined(separator: " • "))
241 .font(.caption) 241 .font(.caption)
242 .foregroundStyle(Color(.appTextSecondary)) 242 .foregroundStyle(ThemeToken.textSecondary)
243 } 243 }
244 } 244 }
245 } 245 }
@@ -283,19 +283,19 @@ struct WatchlistView: View {
283 .buttonStyle(.plain) 283 .buttonStyle(.plain)
284 .swipeActions(edge: .leading, allowsFullSwipe: false) { 284 .swipeActions(edge: .leading, allowsFullSwipe: false) {
285 refreshButton(trackedDomain) 285 refreshButton(trackedDomain)
286 .tint(Color(.statusInfo)) 286 .tint(ThemeToken.info)
287 pinButton(trackedDomain) 287 pinButton(trackedDomain)
288 .tint(Color(.statusWarning)) 288 .tint(ThemeToken.warning)
289 } 289 }
290 .swipeActions(edge: .trailing, allowsFullSwipe: false) { 290 .swipeActions(edge: .trailing, allowsFullSwipe: false) {
291 refreshButton(trackedDomain) 291 refreshButton(trackedDomain)
292 .tint(Color(.statusInfo)) 292 .tint(ThemeToken.info)
293 deleteButton(trackedDomain) 293 deleteButton(trackedDomain)
294 } 294 }
295 .contextMenu { 295 .contextMenu {
296 rowMenu(trackedDomain) 296 rowMenu(trackedDomain)
297 } 297 }
298 .listRowBackground(Color(.appSurface)) 298 .themedListRowBackground(.surface)
299 } 299 }
300 300
301 @ViewBuilder 301 @ViewBuilder
@@ -418,12 +418,12 @@ struct WatchlistRowView: View {
418 418
419 Text("Updated \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))") 419 Text("Updated \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))")
420 .font(appDensity.font(.caption2)) 420 .font(appDensity.font(.caption2))
421 .foregroundStyle(Color(.appTextSecondary)) 421 .foregroundStyle(ThemeToken.textSecondary)
422 422
423 if let collaboration = trackedDomain.collaboration, collaboration.isShared { 423 if let collaboration = trackedDomain.collaboration, collaboration.isShared {
424 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)") 424 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
425 .font(appDensity.font(.caption2)) 425 .font(appDensity.font(.caption2))
426 .foregroundStyle(Color(.appTextSecondary)) 426 .foregroundStyle(ThemeToken.textSecondary)
427 } 427 }
428 428
429 ViewThatFits(in: .horizontal) { 429 ViewThatFits(in: .horizontal) {
@@ -431,19 +431,19 @@ struct WatchlistRowView: View {
431 VStack(alignment: .leading, spacing: 2) { monitoringMetadata } 431 VStack(alignment: .leading, spacing: 2) { monitoringMetadata }
432 } 432 }
433 .font(appDensity.font(.caption2)) 433 .font(appDensity.font(.caption2))
434 .foregroundStyle(Color(.appTextSecondary)) 434 .foregroundStyle(ThemeToken.textSecondary)
435 435
436 indicatorRow 436 indicatorRow
437 437
438 if let note = trackedDomain.note?.trimmingCharacters(in: .whitespacesAndNewlines), !note.isEmpty { 438 if let note = trackedDomain.note?.trimmingCharacters(in: .whitespacesAndNewlines), !note.isEmpty {
439 Text(note) 439 Text(note)
440 .font(appDensity.font(.caption)) 440 .font(appDensity.font(.caption))
441 .foregroundStyle(Color(.appTextSecondary)) 441 .foregroundStyle(ThemeToken.textSecondary)
442 .lineLimit(2) 442 .lineLimit(2)
443 } else if let summary = trackedDomain.lastChangeSummary { 443 } else if let summary = trackedDomain.lastChangeSummary {
444 Text(summary.message) 444 Text(summary.message)
445 .font(appDensity.font(.caption)) 445 .font(appDensity.font(.caption))
446 .foregroundStyle(Color(.appTextSecondary)) 446 .foregroundStyle(ThemeToken.textSecondary)
447 .lineLimit(2) 447 .lineLimit(2)
448 } 448 }
449 } 449 }
@@ -468,7 +468,7 @@ struct WatchlistRowView: View {
468 if trackedDomain.isPinned { 468 if trackedDomain.isPinned {
469 Image(systemName: "pin.fill") 469 Image(systemName: "pin.fill")
470 .font(.caption2) 470 .font(.caption2)
471 .foregroundStyle(Color(.statusWarning)) 471 .foregroundStyle(ThemeToken.warning)
472 } 472 }
473 Text(trackedDomain.domain) 473 Text(trackedDomain.domain)
474 .font(appDensity.font(.callout)) 474 .font(appDensity.font(.callout))
@@ -493,7 +493,7 @@ struct WatchlistRowView: View {
493 @ViewBuilder 493 @ViewBuilder
494 private var statusBadge: some View { 494 private var statusBadge: some View {
495 if isRefreshing { 495 if isRefreshing {
496 AppStatusBadgeView(model: .init(title: "Refreshing", systemImage: "arrow.clockwise", foregroundColor: Color(.appTextSecondary), backgroundColor: Color(.appSurfaceElevated))) 496 AppStatusBadgeView(model: .init(title: "Refreshing", systemImage: "arrow.clockwise", foreground: .textSecondary, background: .surfaceElevated))
497 } else { 497 } else {
498 AppStatusBadgeView(model: AppStatusFactory.availability(trackedDomain.lastKnownAvailability)) 498 AppStatusBadgeView(model: AppStatusFactory.availability(trackedDomain.lastKnownAvailability))
499 } 499 }
@@ -507,8 +507,8 @@ struct WatchlistRowView: View {
507 model: .init( 507 model: .init(
508 title: "Shared", 508 title: "Shared",
509 systemImage: "person.2.fill", 509 systemImage: "person.2.fill",
510 foregroundColor: Color(.statusInfo), 510 foreground: .info,
511 backgroundColor: Color(.statusInfoSurface) 511 background: .infoSurface
512 ) 512 )
513 ) 513 )
514 } 514 }
@@ -525,11 +525,11 @@ struct WatchlistRowView: View {
525 let days = trackedDomain.certificateDaysRemaining.map { "\($0)d" } ?? "Soon" 525 let days = trackedDomain.certificateDaysRemaining.map { "\($0)d" } ?? "Soon"
526 switch trackedDomain.certificateWarningLevel { 526 switch trackedDomain.certificateWarningLevel {
527 case .critical: 527 case .critical:
528 return .init(title: "Invalid \(days)", systemImage: "xmark.octagon.fill", foregroundColor: Color(.statusCritical), backgroundColor: Color(.statusCriticalSurface)) 528 return .init(title: "Invalid \(days)", systemImage: "xmark.octagon.fill", foreground: .critical, background: .criticalSurface)
529 case .warning: 529 case .warning:
530 return .init(title: "Expiring \(days)", systemImage: "exclamationmark.triangle.fill", foregroundColor: Color(.statusWarning), backgroundColor: Color(.statusWarningSurface)) 530 return .init(title: "Expiring \(days)", systemImage: "exclamationmark.triangle.fill", foreground: .warning, background: .warningSurface)
531 case .none: 531 case .none:
532 return .init(title: "Valid", systemImage: "lock.fill", foregroundColor: Color(.statusPositive), backgroundColor: Color(.statusPositiveSurface)) 532 return .init(title: "Valid", systemImage: "lock.fill", foreground: .positive, background: .positiveSurface)
533 } 533 }
534 } 534 }
535} 535}
@@ -596,7 +596,7 @@ struct TrackedDomainDetailView: View {
596 isRefreshing: viewModel.refreshingTrackedDomainID == liveTrackedDomain.id 596 isRefreshing: viewModel.refreshingTrackedDomainID == liveTrackedDomain.id
597 ) 597 )
598 } 598 }
599 .listRowBackground(Color(.appSurface)) 599 .themedListRowBackground(.surface)
600 600
601 Section { 601 Section {
602 Button { 602 Button {
@@ -678,13 +678,13 @@ struct TrackedDomainDetailView: View {
678 Label(liveTrackedDomain.collaboration?.isShared == true ? "Manage Share" : "Share Domain", systemImage: "person.2") 678 Label(liveTrackedDomain.collaboration?.isShared == true ? "Manage Share" : "Share Domain", systemImage: "person.2")
679 } 679 }
680 } 680 }
681 .listRowBackground(Color(.appSurface)) 681 .themedListRowBackground(.surface)
682 682
683 if !liveTrackedDomain.tags.isEmpty { 683 if !liveTrackedDomain.tags.isEmpty {
684 Section("Tags") { 684 Section("Tags") {
685 TagChipRowView(tags: liveTrackedDomain.tags) 685 TagChipRowView(tags: liveTrackedDomain.tags)
686 } 686 }
687 .listRowBackground(Color(.appSurface)) 687 .themedListRowBackground(.surface)
688 } 688 }
689 689
690 Section("Monitoring Status") { 690 Section("Monitoring Status") {
@@ -698,7 +698,7 @@ struct TrackedDomainDetailView: View {
698 LabeledContent("Queued Alerts", value: "\(liveTrackedDomain.pendingMonitoringAlerts.count)") 698 LabeledContent("Queued Alerts", value: "\(liveTrackedDomain.pendingMonitoringAlerts.count)")
699 } 699 }
700 } 700 }
701 .listRowBackground(Color(.appSurface)) 701 .themedListRowBackground(.surface)
702 702
703 if let summary = viewModel.latestChangeSummary(for: liveTrackedDomain) { 703 if let summary = viewModel.latestChangeSummary(for: liveTrackedDomain) {
704 Section("Latest Change Summary") { 704 Section("Latest Change Summary") {
@@ -726,7 +726,7 @@ struct TrackedDomainDetailView: View {
726 if latestSnapshots.isEmpty { 726 if latestSnapshots.isEmpty {
727 Text("No snapshots yet") 727 Text("No snapshots yet")
728 .font(.system(.caption, design: .monospaced)) 728 .font(.system(.caption, design: .monospaced))
729 .foregroundStyle(Color(.appTextSecondary)) 729 .foregroundStyle(ThemeToken.textSecondary)
730 } else { 730 } else {
731 ForEach(latestSnapshots) { entry in 731 ForEach(latestSnapshots) { entry in
732 NavigationLink { 732 NavigationLink {
@@ -738,16 +738,16 @@ struct TrackedDomainDetailView: View {
738 .foregroundStyle(.primary) 738 .foregroundStyle(.primary)
739 Text(entry.changeSummary?.hasChanges == true ? "Changed" : "Snapshot") 739 Text(entry.changeSummary?.hasChanges == true ? "Changed" : "Snapshot")
740 .font(.system(.caption2, design: .monospaced)) 740 .font(.system(.caption2, design: .monospaced))
741 .foregroundStyle(Color(.appTextSecondary)) 741 .foregroundStyle(ThemeToken.textSecondary)
742 } 742 }
743 } 743 }
744 } 744 }
745 } 745 }
746 } 746 }
747 .listRowBackground(Color(.appSurface)) 747 .themedListRowBackground(.surface)
748 } 748 }
749 .scrollContentBackground(.hidden) 749 .scrollContentBackground(.hidden)
750 .background(Color(.appBackground)) 750 .background(ThemeToken.background)
751 .navigationTitle(liveTrackedDomain.domain) 751 .navigationTitle(liveTrackedDomain.domain)
752 .onChange(of: viewModel.rerunNavigationToken) { _, _ in 752 .onChange(of: viewModel.rerunNavigationToken) { _, _ in
753 dismiss() 753 dismiss()
DomainDig/WebSectionView.swift +8 −8
@@ -52,7 +52,7 @@ struct WebSectionView: View {
52 HStack { 52 HStack {
53 Text("TLS") 53 Text("TLS")
54 .font(appDensity.font(.subheadline, weight: .semibold)) 54 .font(appDensity.font(.subheadline, weight: .semibold))
55 .foregroundStyle(Color(.statusInfo)) 55 .foregroundStyle(ThemeToken.info)
56 Spacer() 56 Spacer()
57 if !sslLoading { 57 if !sslLoading {
58 AppStatusBadgeView(model: AppStatusFactory.tls(sslInfo: sslInfo, error: sslError)) 58 AppStatusBadgeView(model: AppStatusFactory.tls(sslInfo: sslInfo, error: sslError))
@@ -77,7 +77,7 @@ struct WebSectionView: View {
77 if let sslInfo, !sslInfo.subjectAltNames.isEmpty { 77 if let sslInfo, !sslInfo.subjectAltNames.isEmpty {
78 Text("SANs") 78 Text("SANs")
79 .font(appDensity.font(.caption2)) 79 .font(appDensity.font(.caption2))
80 .foregroundStyle(Color(.appTextSecondary)) 80 .foregroundStyle(ThemeToken.textSecondary)
81 ForEach(sslInfo.subjectAltNames, id: \.self) { san in 81 ForEach(sslInfo.subjectAltNames, id: \.self) { san in
82 HStack(alignment: .top, spacing: 8) { 82 HStack(alignment: .top, spacing: 8) {
83 Text(san) 83 Text(san)
@@ -96,7 +96,7 @@ struct WebSectionView: View {
96 CardView { 96 CardView {
97 Text("Headers") 97 Text("Headers")
98 .font(appDensity.font(.subheadline, weight: .semibold)) 98 .font(appDensity.font(.subheadline, weight: .semibold))
99 .foregroundStyle(Color(.statusInfo)) 99 .foregroundStyle(ThemeToken.info)
100 SectionTrustMetadataView(provenance: httpProvenance, confidence: nil) 100 SectionTrustMetadataView(provenance: httpProvenance, confidence: nil)
101 if headersLoading { 101 if headersLoading {
102 ProgressView("Fetching headers…") 102 ProgressView("Fetching headers…")
@@ -114,7 +114,7 @@ struct WebSectionView: View {
114 HStack(alignment: .top, spacing: 4) { 114 HStack(alignment: .top, spacing: 4) {
115 Text(header.name + ":") 115 Text(header.name + ":")
116 .font(appDensity.font(.caption)) 116 .font(appDensity.font(.caption))
117 .foregroundStyle(header.isSecurityHeader ? Color(.statusWarning) : Color(.statusInfo)) 117 .foregroundStyle(header.isSecurityHeader ? ThemeToken.warning : ThemeToken.info)
118 Text(header.value) 118 Text(header.value)
119 .font(appDensity.font(.caption)) 119 .font(appDensity.font(.caption))
120 .foregroundStyle(.primary) 120 .foregroundStyle(.primary)
@@ -129,7 +129,7 @@ struct WebSectionView: View {
129 HStack { 129 HStack {
130 Text("Redirects") 130 Text("Redirects")
131 .font(appDensity.font(.subheadline, weight: .semibold)) 131 .font(appDensity.font(.subheadline, weight: .semibold))
132 .foregroundStyle(Color(.statusInfo)) 132 .foregroundStyle(ThemeToken.info)
133 Spacer() 133 Spacer()
134 if let finalURL { 134 if let finalURL {
135 AppCopyButton(value: finalURL, label: "Copy redirect URL") 135 AppCopyButton(value: finalURL, label: "Copy redirect URL")
@@ -151,11 +151,11 @@ struct WebSectionView: View {
151 HStack(alignment: .top, spacing: 6) { 151 HStack(alignment: .top, spacing: 6) {
152 Text(redirect.stepLabel) 152 Text(redirect.stepLabel)
153 .font(appDensity.font(.caption)) 153 .font(appDensity.font(.caption))
154 .foregroundStyle(Color(.appTextSecondary)) 154 .foregroundStyle(ThemeToken.textSecondary)
155 .frame(width: 16, alignment: .trailing) 155 .frame(width: 16, alignment: .trailing)
156 Text(redirect.statusCode) 156 Text(redirect.statusCode)
157 .font(appDensity.font(.caption)) 157 .font(appDensity.font(.caption))
158 .foregroundStyle(Color(.statusInfo)) 158 .foregroundStyle(ThemeToken.info)
159 .frame(width: 36, alignment: .leading) 159 .frame(width: 36, alignment: .leading)
160 Text(redirect.url) 160 Text(redirect.url)
161 .font(appDensity.font(.caption)) 161 .font(appDensity.font(.caption))
@@ -163,7 +163,7 @@ struct WebSectionView: View {
163 if redirect.isFinal { 163 if redirect.isFinal {
164 Text("(final)") 164 Text("(final)")
165 .font(appDensity.font(.caption2)) 165 .font(appDensity.font(.caption2))
166 .foregroundStyle(Color(.appTextSecondary)) 166 .foregroundStyle(ThemeToken.textSecondary)
167 } 167 }
168 Spacer(minLength: 8) 168 Spacer(minLength: 8)
169 AppCopyButton(value: redirect.url, label: "Copy redirect URL") 169 AppCopyButton(value: redirect.url, label: "Copy redirect URL")
DomainDig/WorkflowsView.swift +24 −24
@@ -20,15 +20,15 @@ struct WorkflowsView: View {
20 Section { 20 Section {
21 Text(limitMessage) 21 Text(limitMessage)
22 .font(appDensity.font(.caption)) 22 .font(appDensity.font(.caption))
23 .foregroundStyle(Color(.appTextSecondary)) 23 .foregroundStyle(ThemeToken.textSecondary)
24 } 24 }
25 .listRowBackground(Color(.appSurface)) 25 .themedListRowBackground(.surface)
26 } 26 }
27 27
28 workflowContent 28 workflowContent
29 } 29 }
30 .scrollContentBackground(.hidden) 30 .scrollContentBackground(.hidden)
31 .background(Color(.appBackground)) 31 .background(ThemeToken.background)
32 .refreshable { 32 .refreshable {
33 await viewModel.refreshWorkflowList() 33 await viewModel.refreshWorkflowList()
34 } 34 }
@@ -71,12 +71,12 @@ struct WorkflowsView: View {
71 value: Double(viewModel.batchCompletedCount), 71 value: Double(viewModel.batchCompletedCount),
72 total: Double(max(viewModel.batchTotalCount, 1)) 72 total: Double(max(viewModel.batchTotalCount, 1))
73 ) 73 )
74 .tint(Color(.statusInfo)) 74 .tint(ThemeToken.info)
75 75
76 HStack { 76 HStack {
77 Text(viewModel.batchProgressLabel) 77 Text(viewModel.batchProgressLabel)
78 .font(appDensity.font(.caption)) 78 .font(appDensity.font(.caption))
79 .foregroundStyle(Color(.appTextSecondary)) 79 .foregroundStyle(ThemeToken.textSecondary)
80 Spacer() 80 Spacer()
81 if viewModel.batchLookupRunning { 81 if viewModel.batchLookupRunning {
82 Button("Cancel") { 82 Button("Cancel") {
@@ -89,7 +89,7 @@ struct WorkflowsView: View {
89 } 89 }
90 .padding(.vertical, 4) 90 .padding(.vertical, 4)
91 } 91 }
92 .listRowBackground(Color(.appSurface)) 92 .themedListRowBackground(.surface)
93 } 93 }
94 94
95 if viewModel.workflows.isEmpty { 95 if viewModel.workflows.isEmpty {
@@ -102,7 +102,7 @@ struct WorkflowsView: View {
102 showsCardBackground: false 102 showsCardBackground: false
103 ) 103 )
104 } 104 }
105 .listRowBackground(Color(.appSurface)) 105 .themedListRowBackground(.surface)
106 } else { 106 } else {
107 ForEach(viewModel.workflows) { workflow in 107 ForEach(viewModel.workflows) { workflow in
108 NavigationLink { 108 NavigationLink {
@@ -110,7 +110,7 @@ struct WorkflowsView: View {
110 } label: { 110 } label: {
111 WorkflowRowView(workflow: workflow) 111 WorkflowRowView(workflow: workflow)
112 } 112 }
113 .listRowBackground(Color(.appSurface)) 113 .themedListRowBackground(.surface)
114 } 114 }
115 .onDelete { offsets in 115 .onDelete { offsets in
116 let workflows = offsets.map { viewModel.workflows[$0] } 116 let workflows = offsets.map { viewModel.workflows[$0] }
@@ -131,7 +131,7 @@ private struct WorkflowRowView: View {
131 if workflow.collaboration?.isShared == true { 131 if workflow.collaboration?.isShared == true {
132 Image(systemName: "person.2.fill") 132 Image(systemName: "person.2.fill")
133 .font(.caption2) 133 .font(.caption2)
134 .foregroundStyle(Color(.statusInfo)) 134 .foregroundStyle(ThemeToken.info)
135 .accessibilityLabel("Shared") 135 .accessibilityLabel("Shared")
136 } 136 }
137 Text(workflow.name) 137 Text(workflow.name)
@@ -141,23 +141,23 @@ private struct WorkflowRowView: View {
141 Spacer(minLength: 8) 141 Spacer(minLength: 8)
142 Text("\(workflow.domains.count) domains") 142 Text("\(workflow.domains.count) domains")
143 .font(appDensity.font(.caption2)) 143 .font(appDensity.font(.caption2))
144 .foregroundStyle(Color(.appTextSecondary)) 144 .foregroundStyle(ThemeToken.textSecondary)
145 } 145 }
146 146
147 Text("Updated \(workflow.updatedAt.formatted(date: .abbreviated, time: .shortened))") 147 Text("Updated \(workflow.updatedAt.formatted(date: .abbreviated, time: .shortened))")
148 .font(appDensity.font(.caption2)) 148 .font(appDensity.font(.caption2))
149 .foregroundStyle(Color(.appTextSecondary)) 149 .foregroundStyle(ThemeToken.textSecondary)
150 150
151 if let collaboration = workflow.collaboration, collaboration.isShared { 151 if let collaboration = workflow.collaboration, collaboration.isShared {
152 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)") 152 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
153 .font(appDensity.font(.caption2)) 153 .font(appDensity.font(.caption2))
154 .foregroundStyle(Color(.appTextSecondary)) 154 .foregroundStyle(ThemeToken.textSecondary)
155 } 155 }
156 156
157 if let notes = workflow.notes, !notes.isEmpty { 157 if let notes = workflow.notes, !notes.isEmpty {
158 Text(notes) 158 Text(notes)
159 .font(appDensity.font(.caption)) 159 .font(appDensity.font(.caption))
160 .foregroundStyle(Color(.appTextSecondary)) 160 .foregroundStyle(ThemeToken.textSecondary)
161 .lineLimit(2) 161 .lineLimit(2)
162 } 162 }
163 } 163 }
@@ -196,12 +196,12 @@ struct WorkflowDetailView: View {
196 if let notes = workflow.notes, !notes.isEmpty { 196 if let notes = workflow.notes, !notes.isEmpty {
197 Text(notes) 197 Text(notes)
198 .font(appDensity.font(.caption)) 198 .font(appDensity.font(.caption))
199 .foregroundStyle(Color(.appTextSecondary)) 199 .foregroundStyle(ThemeToken.textSecondary)
200 } 200 }
201 if let collaboration = workflow.collaboration, collaboration.isShared { 201 if let collaboration = workflow.collaboration, collaboration.isShared {
202 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)") 202 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
203 .font(appDensity.font(.caption)) 203 .font(appDensity.font(.caption))
204 .foregroundStyle(Color(.appTextSecondary)) 204 .foregroundStyle(ThemeToken.textSecondary)
205 } 205 }
206 } 206 }
207 207
@@ -256,7 +256,7 @@ struct WorkflowDetailView: View {
256 if !latestSummary.workflowInsights.isEmpty { 256 if !latestSummary.workflowInsights.isEmpty {
257 Text(latestSummary.workflowInsights[0].description) 257 Text(latestSummary.workflowInsights[0].description)
258 .font(appDensity.font(.caption)) 258 .font(appDensity.font(.caption))
259 .foregroundStyle(Color(.appTextSecondary)) 259 .foregroundStyle(ThemeToken.textSecondary)
260 } 260 }
261 261
262 Button { 262 Button {
@@ -285,7 +285,7 @@ struct WorkflowDetailView: View {
285 if workflow.domains.isEmpty { 285 if workflow.domains.isEmpty {
286 Text("No domains in this workflow") 286 Text("No domains in this workflow")
287 .font(appDensity.font(.caption)) 287 .font(appDensity.font(.caption))
288 .foregroundStyle(Color(.appTextSecondary)) 288 .foregroundStyle(ThemeToken.textSecondary)
289 } else { 289 } else {
290 ForEach(workflow.domains, id: \.self) { domain in 290 ForEach(workflow.domains, id: \.self) { domain in
291 Button { 291 Button {
@@ -297,7 +297,7 @@ struct WorkflowDetailView: View {
297 .foregroundStyle(.primary) 297 .foregroundStyle(.primary)
298 Spacer() 298 Spacer()
299 Image(systemName: "arrow.up.right.circle") 299 Image(systemName: "arrow.up.right.circle")
300 .foregroundStyle(Color(.appTextSecondary)) 300 .foregroundStyle(ThemeToken.textSecondary)
301 } 301 }
302 } 302 }
303 .buttonStyle(.plain) 303 .buttonStyle(.plain)
@@ -314,7 +314,7 @@ struct WorkflowDetailView: View {
314 } 314 }
315 } 315 }
316 .scrollContentBackground(.hidden) 316 .scrollContentBackground(.hidden)
317 .background(Color(.appBackground)) 317 .background(ThemeToken.background)
318 .navigationTitle(workflow.name) 318 .navigationTitle(workflow.name)
319 .toolbar { 319 .toolbar {
320 if !workflow.domains.isEmpty { 320 if !workflow.domains.isEmpty {
@@ -334,7 +334,7 @@ struct WorkflowDetailView: View {
334 } else { 334 } else {
335 Text("Workflow not found") 335 Text("Workflow not found")
336 .font(appDensity.font(.callout)) 336 .font(appDensity.font(.callout))
337 .foregroundStyle(Color(.appTextSecondary)) 337 .foregroundStyle(ThemeToken.textSecondary)
338 } 338 }
339 } 339 }
340 } 340 }
@@ -343,7 +343,7 @@ struct WorkflowDetailView: View {
343 HStack { 343 HStack {
344 Text(label) 344 Text(label)
345 .font(appDensity.font(.caption)) 345 .font(appDensity.font(.caption))
346 .foregroundStyle(Color(.appTextSecondary)) 346 .foregroundStyle(ThemeToken.textSecondary)
347 Spacer() 347 Spacer()
348 Text(value) 348 Text(value)
349 .font(appDensity.font(.callout)) 349 .font(appDensity.font(.callout))
@@ -484,7 +484,7 @@ struct WorkflowRunSummaryView: View {
484 .foregroundStyle(.primary) 484 .foregroundStyle(.primary)
485 Text(insight.domainsInvolved.joined(separator: ", ")) 485 Text(insight.domainsInvolved.joined(separator: ", "))
486 .font(.system(.caption, design: .monospaced)) 486 .font(.system(.caption, design: .monospaced))
487 .foregroundStyle(Color(.appTextSecondary)) 487 .foregroundStyle(ThemeToken.textSecondary)
488 } 488 }
489 } 489 }
490 } 490 }
@@ -525,7 +525,7 @@ struct WorkflowRunSummaryView: View {
525 HStack { 525 HStack {
526 Text(label) 526 Text(label)
527 .font(.system(.caption, design: .monospaced)) 527 .font(.system(.caption, design: .monospaced))
528 .foregroundStyle(Color(.appTextSecondary)) 528 .foregroundStyle(ThemeToken.textSecondary)
529 Spacer() 529 Spacer()
530 Text(value) 530 Text(value)
531 .font(.system(.callout, design: .monospaced)) 531 .font(.system(.callout, design: .monospaced))
@@ -580,7 +580,7 @@ struct WorkflowBulkAddSheet: View {
580 .foregroundStyle(.primary) 580 .foregroundStyle(.primary)
581 Spacer() 581 Spacer()
582 Image(systemName: selectedDomains.contains(domain) ? "checkmark.circle.fill" : "circle") 582 Image(systemName: selectedDomains.contains(domain) ? "checkmark.circle.fill" : "circle")
583 .foregroundStyle(selectedDomains.contains(domain) ? Color(.statusInfo) : .secondary) 583 .foregroundStyle(selectedDomains.contains(domain) ? AnyShapeStyle(ThemeToken.info) : AnyShapeStyle(.secondary))
584 } 584 }
585 } 585 }
586 .buttonStyle(.plain) 586 .buttonStyle(.plain)
DomainDigTests/ThemeTests.swift added +130
@@ -0,0 +1,130 @@
1import SwiftUI
2import XCTest
3@testable import DomainDig
4
5/// The palette moved from 483 asset-catalog call sites into a `Theme` carried
6/// in the environment (I1's sibling, W13).
7///
8/// The one safety the move gave up is compile-time checking of the colour
9/// names: `ThemeToken.assetColor` looks them up by string, because the
10/// generated `ColorResource` symbols are MainActor-isolated and
11/// `ShapeStyle.resolve(in:)` is not. `testEveryTokenHasAColorset` and
12/// `testNoColorsetIsMissingAToken` are what replace it.
13final class ThemeTests: XCTestCase {
14
15 /// The colorsets on disk, which are the palette's definition.
16 private func colorsetNames() throws -> Set<String> {
17 // The bundle under test is the app's, and the catalog is compiled into
18 // it, so the names are read from the source tree instead.
19 let root = URL(fileURLWithPath: #filePath)
20 .deletingLastPathComponent()
21 .deletingLastPathComponent()
22 .appendingPathComponent("Shared/Colors.xcassets")
23 let entries = try FileManager.default.contentsOfDirectory(atPath: root.path)
24 return Set(
25 entries
26 .filter { $0.hasSuffix(".colorset") }
27 .map { String($0.dropLast(".colorset".count)) }
28 )
29 }
30
31 func testEveryTokenHasAColorset() throws {
32 let names = try colorsetNames()
33
34 for token in ThemeToken.allCases {
35 XCTAssertTrue(
36 names.contains(token.rawValue),
37 "\(token) names '\(token.rawValue)', which is not a colorset — it would render as a placeholder"
38 )
39 }
40 }
41
42 /// The other direction: a colour added to the catalog without a token is
43 /// unreachable through the theme, so it cannot be themed and nothing says
44 /// so.
45 func testNoColorsetIsMissingAToken() throws {
46 let names = try colorsetNames()
47 let tokens = Set(ThemeToken.allCases.map(\.rawValue))
48
49 XCTAssertEqual(
50 names.subtracting(tokens),
51 [],
52 "these colorsets have no ThemeToken, so the theme cannot reach them"
53 )
54 }
55
56 // MARK: Defaults
57
58 /// The default theme has to render exactly as the asset catalog did, or the
59 /// refactor changed the app's appearance rather than only its plumbing.
60 func testTheDefaultThemeResolvesEveryTokenFromTheCatalog() {
61 let theme = Theme.default
62
63 for token in ThemeToken.allCases {
64 XCTAssertEqual(theme[token], token.assetColor, "\(token) should come straight from the catalog")
65 }
66 }
67
68 func testAnEmptyOverrideSetIsTheDefault() {
69 XCTAssertEqual(Theme(overrides: [:]), Theme.default)
70 }
71
72 // MARK: Accents
73
74 func testTheDefaultAccentOverridesNothing() {
75 XCTAssertEqual(AccentTheme.default.theme, Theme.default)
76 }
77
78 /// An accent changes the accent and nothing else. Letting it reach the
79 /// status colours would undo the contrast work phases 1–5 of #21 did.
80 func testAnAccentOverridesOnlyTheAccentTokens() {
81 for accent in AccentTheme.allCases where accent != .default {
82 let theme = accent.theme
83
84 XCTAssertNotEqual(theme[.accent], ThemeToken.accent.assetColor, "\(accent) should change the accent")
85
86 for token in ThemeToken.allCases where token != .accent && token != .onAccent {
87 XCTAssertEqual(
88 theme[token],
89 token.assetColor,
90 "\(accent) must leave \(token) alone"
91 )
92 }
93 }
94 }
95
96 func testEveryAccentHasATitle() {
97 for accent in AccentTheme.allCases {
98 XCTAssertFalse(accent.title.isEmpty)
99 XCTAssertEqual(AccentTheme(rawValue: accent.rawValue), accent, "the stored value round-trips")
100 }
101 }
102
103 /// Accent themes are Pro+ per D1. Pro+ takes `allCases`, so the check that
104 /// matters is that the capability did not land in free or pro.
105 func testAccentThemesArePrOPlusOnly() {
106 XCTAssertFalse(FeatureAccessService.entitlements(for: .free).capabilities.contains(.accentTheme))
107 XCTAssertFalse(FeatureAccessService.entitlements(for: .pro).capabilities.contains(.accentTheme))
108 XCTAssertTrue(FeatureAccessService.entitlements(for: .proPlus).capabilities.contains(.accentTheme))
109 XCTAssertEqual(FeatureAccessService.upgradeMessage(for: .accentTheme), "Available in Pro+")
110 }
111
112 // MARK: Badge models carry tokens
113
114 /// The badges are built outside a view body, which is why their colours are
115 /// tokens rather than resolved values.
116 func testStatusBadgesNameTokensRatherThanColors() {
117 let registered = AppStatusFactory.availability(.registered)
118 XCTAssertFalse(registered.title.isEmpty)
119
120 // A token, so the theme resolves it at draw time.
121 XCTAssertEqual(Theme.default[registered.foreground], registered.foreground.assetColor)
122 XCTAssertEqual(Theme.default[registered.background], registered.background.assetColor)
123 }
124
125 func testEveryToneMapsToATokenPair() {
126 for tone in [AppStatusTone.positive, .warning, .critical, .info, .neutral] {
127 XCTAssertNotEqual(tone.foreground, tone.surface, "\(tone) should not use one colour for both")
128 }
129 }
130}