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 {
163163 } else {
164164 Section {
165165 Text("Release notes are unavailable.")
166 .foregroundStyle(Color(.appTextSecondary))
166 .foregroundStyle(ThemeToken.textSecondary)
167167 }
168168 }
169169 }
@@ -188,7 +188,7 @@ private struct AcknowledgementsView: View {
188188 Section("License") {
189189 Text("DomainDig is released under the MIT License.")
190190 Text(AppLinks.copyright)
191 .foregroundStyle(Color(.appTextSecondary))
191 .foregroundStyle(ThemeToken.textSecondary)
192192 }
193193 }
194194 .navigationTitle("Acknowledgements")
@@ -211,7 +211,7 @@ private struct ReportIssueView: View {
211211 Form {
212212 Section {
213213 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)
215215 }
216216
217217 Section("Included Diagnostics") {
DomainDig/AuditViews.swift +40 −40
@@ -27,7 +27,7 @@ struct AuditListView: View {
2727 showsCardBackground: false
2828 )
2929 }
30 .listRowBackground(Color(.appSurface))
30 .themedListRowBackground(.surface)
3131 } else {
3232 Section("Audit Domains") {
3333 ForEach(groupedSessions, id: \.domain) { group in
@@ -41,13 +41,13 @@ struct AuditListView: View {
4141 Spacer()
4242 Text("\(group.sessions.count) audit\(group.sessions.count == 1 ? "" : "s")")
4343 .font(appDensity.font(.caption2))
44 .foregroundStyle(Color(.appTextSecondary))
44 .foregroundStyle(ThemeToken.textSecondary)
4545 }
4646
4747 if let latest = group.sessions.first {
4848 Text(latest.findings.isEmpty ? "No findings recorded yet" : latest.findings.map(\.title).prefix(2).joined(separator: " • "))
4949 .font(appDensity.font(.caption))
50 .foregroundStyle(Color(.appTextSecondary))
50 .foregroundStyle(ThemeToken.textSecondary)
5151 .lineLimit(2)
5252
5353 HStack(spacing: 8) {
@@ -57,7 +57,7 @@ struct AuditListView: View {
5757 }
5858 Text("Checklist \(latest.completedChecklistCount)/\(latest.checklist.count)")
5959 .font(appDensity.font(.caption2))
60 .foregroundStyle(Color(.appTextSecondary))
60 .foregroundStyle(ThemeToken.textSecondary)
6161 }
6262 }
6363 }
@@ -65,11 +65,11 @@ struct AuditListView: View {
6565 }
6666 }
6767 }
68 .listRowBackground(Color(.appSurface))
68 .themedListRowBackground(.surface)
6969 }
7070 }
7171 .scrollContentBackground(.hidden)
72 .background(Color(.appBackground))
72 .background(ThemeToken.background)
7373 .navigationTitle("Audit Mode")
7474 .toolbar {
7575 if !viewModel.searchedDomain.isEmpty {
@@ -115,7 +115,7 @@ struct AuditDomainTimelineView: View {
115115
116116 Text("Reviewer: \(session.reviewer)")
117117 .font(appDensity.font(.caption))
118 .foregroundStyle(Color(.appTextSecondary))
118 .foregroundStyle(ThemeToken.textSecondary)
119119
120120 HStack(spacing: 8) {
121121 Text("\(session.findings.count) findings")
@@ -125,13 +125,13 @@ struct AuditDomainTimelineView: View {
125125 }
126126 }
127127 .font(appDensity.font(.caption2))
128 .foregroundStyle(Color(.appTextSecondary))
128 .foregroundStyle(ThemeToken.textSecondary)
129129 }
130130 .padding(.vertical, 4)
131131 }
132132 }
133133 }
134 .listRowBackground(Color(.appSurface))
134 .themedListRowBackground(.surface)
135135
136136 Section("Trend") {
137137 ForEach(viewModel.auditTimeline(for: domain)) { point in
@@ -142,19 +142,19 @@ struct AuditDomainTimelineView: View {
142142 Spacer()
143143 Text("\(point.findingCount) findings")
144144 .font(appDensity.font(.caption2))
145 .foregroundStyle(Color(.appTextSecondary))
145 .foregroundStyle(ThemeToken.textSecondary)
146146 }
147147 Text("Open high severity: \(point.openHighSeverityCount) • Repeated issues: \(point.repeatedIssueCount)")
148148 .font(appDensity.font(.caption2))
149 .foregroundStyle(Color(.appTextSecondary))
149 .foregroundStyle(ThemeToken.textSecondary)
150150 }
151151 .padding(.vertical, 2)
152152 }
153153 }
154 .listRowBackground(Color(.appSurface))
154 .themedListRowBackground(.surface)
155155 }
156156 .scrollContentBackground(.hidden)
157 .background(Color(.appBackground))
157 .background(ThemeToken.background)
158158 .navigationTitle(domain)
159159 .toolbar {
160160 ToolbarItem(placement: .topBarTrailing) {
@@ -196,7 +196,7 @@ struct AuditSessionDetailView: View {
196196 .font(appDensity.font(.headline, design: .default, weight: .semibold))
197197 Text("Reviewer: \(session.reviewer)")
198198 .font(appDensity.font(.caption))
199 .foregroundStyle(Color(.appTextSecondary))
199 .foregroundStyle(ThemeToken.textSecondary)
200200 }
201201 Spacer()
202202 auditStatusBadge(session.status)
@@ -214,10 +214,10 @@ struct AuditSessionDetailView: View {
214214
215215 Text("Captured \(session.evidence.capturedAt.formatted(date: .abbreviated, time: .shortened))")
216216 .font(appDensity.font(.caption2))
217 .foregroundStyle(Color(.appTextSecondary))
217 .foregroundStyle(ThemeToken.textSecondary)
218218 }
219219 }
220 .listRowBackground(Color(.appSurface))
220 .themedListRowBackground(.surface)
221221
222222 Section("Audit Summary") {
223223 LabeledContent("Findings", value: "\(session.findings.count)")
@@ -227,7 +227,7 @@ struct AuditSessionDetailView: View {
227227 LabeledContent("Highest Severity", value: severity.title)
228228 }
229229 }
230 .listRowBackground(Color(.appSurface))
230 .themedListRowBackground(.surface)
231231
232232 Section("Reviewer Notes") {
233233 TextEditor(text: $notesDraft)
@@ -239,7 +239,7 @@ struct AuditSessionDetailView: View {
239239 viewModel.updateAuditNotes(notesDraft, sessionID: session.id)
240240 }
241241 }
242 .listRowBackground(Color(.appSurface))
242 .themedListRowBackground(.surface)
243243
244244 Section("Checklist") {
245245 ForEach(session.checklist) { item in
@@ -248,14 +248,14 @@ struct AuditSessionDetailView: View {
248248 } label: {
249249 HStack(alignment: .top, spacing: 10) {
250250 Image(systemName: item.isComplete ? "checkmark.circle.fill" : "circle")
251 .foregroundStyle(item.isComplete ? Color(.statusPositive) : .secondary)
251 .foregroundStyle(item.isComplete ? AnyShapeStyle(ThemeToken.positive) : AnyShapeStyle(.secondary))
252252 VStack(alignment: .leading, spacing: 4) {
253253 Text(item.title)
254254 .font(appDensity.font(.callout))
255255 .foregroundStyle(.primary)
256256 Text(item.detail)
257257 .font(appDensity.font(.caption))
258 .foregroundStyle(Color(.appTextSecondary))
258 .foregroundStyle(ThemeToken.textSecondary)
259259 }
260260 Spacer()
261261 }
@@ -265,13 +265,13 @@ struct AuditSessionDetailView: View {
265265 .accessibilityHint(item.isComplete ? "Marks incomplete" : "Marks complete")
266266 }
267267 }
268 .listRowBackground(Color(.appSurface))
268 .themedListRowBackground(.surface)
269269
270270 Section("Findings") {
271271 if session.findings.isEmpty {
272272 Text("No findings recorded.")
273273 .font(appDensity.font(.caption))
274 .foregroundStyle(Color(.appTextSecondary))
274 .foregroundStyle(ThemeToken.textSecondary)
275275 } else {
276276 ForEach(session.findings) { finding in
277277 Button {
@@ -287,11 +287,11 @@ struct AuditSessionDetailView: View {
287287 }
288288 Text(finding.summary)
289289 .font(appDensity.font(.caption))
290 .foregroundStyle(Color(.appTextSecondary))
290 .foregroundStyle(ThemeToken.textSecondary)
291291 .lineLimit(2)
292292 Text("\(finding.status.title) • \(finding.evidenceReferences.count) evidence refs")
293293 .font(appDensity.font(.caption2))
294 .foregroundStyle(Color(.appTextSecondary))
294 .foregroundStyle(ThemeToken.textSecondary)
295295 }
296296 .padding(.vertical, 2)
297297 }
@@ -302,7 +302,7 @@ struct AuditSessionDetailView: View {
302302 }
303303 }
304304 }
305 .listRowBackground(Color(.appSurface))
305 .themedListRowBackground(.surface)
306306
307307 Section("Evidence Snapshot") {
308308 LabeledContent("Availability", value: availabilityTitle(session.evidence.report.availability))
@@ -312,7 +312,7 @@ struct AuditSessionDetailView: View {
312312 LabeledContent("Reachability", value: session.evidence.report.network.reachabilitySummary)
313313 LabeledContent("Registrar", value: session.evidence.report.ownership?.registrar ?? "Unavailable")
314314 }
315 .listRowBackground(Color(.appSurface))
315 .themedListRowBackground(.surface)
316316
317317 if !session.evidence.historicalContext.isEmpty {
318318 Section("Historical Context") {
@@ -322,11 +322,11 @@ struct AuditSessionDetailView: View {
322322 .font(appDensity.font(.caption, weight: .semibold))
323323 Text(entry.changeSummaryMessage ?? "No change summary")
324324 .font(appDensity.font(.caption2))
325 .foregroundStyle(Color(.appTextSecondary))
325 .foregroundStyle(ThemeToken.textSecondary)
326326 }
327327 }
328328 }
329 .listRowBackground(Color(.appSurface))
329 .themedListRowBackground(.surface)
330330 }
331331
332332 Section("Audit Timeline") {
@@ -338,18 +338,18 @@ struct AuditSessionDetailView: View {
338338 Spacer()
339339 Text(point.status.title)
340340 .font(appDensity.font(.caption2))
341 .foregroundStyle(Color(.appTextSecondary))
341 .foregroundStyle(ThemeToken.textSecondary)
342342 }
343343 Text("Findings \(point.findingCount) • Open high \(point.openHighSeverityCount) • Repeated \(point.repeatedIssueCount)")
344344 .font(appDensity.font(.caption2))
345 .foregroundStyle(Color(.appTextSecondary))
345 .foregroundStyle(ThemeToken.textSecondary)
346346 }
347347 }
348348 }
349 .listRowBackground(Color(.appSurface))
349 .themedListRowBackground(.surface)
350350 }
351351 .scrollContentBackground(.hidden)
352 .background(Color(.appBackground))
352 .background(ThemeToken.background)
353353 .navigationTitle("Audit Session")
354354 .toolbar {
355355 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -399,7 +399,7 @@ struct AuditSessionDetailView: View {
399399 }
400400 } else {
401401 ContentUnavailableView("Audit Session Missing", systemImage: "exclamationmark.triangle")
402 .background(Color(.appBackground))
402 .background(ThemeToken.background)
403403 }
404404 }
405405 }
@@ -459,7 +459,7 @@ private struct AuditFindingEditorView: View {
459459 ForEach(session.evidence.screenshots) { asset in
460460 Text("\(asset.title): \(asset.reference)")
461461 .font(.caption)
462 .foregroundStyle(Color(.appTextSecondary))
462 .foregroundStyle(ThemeToken.textSecondary)
463463 }
464464 }
465465 }
@@ -477,7 +477,7 @@ private struct AuditFindingEditorView: View {
477477 Text(area.title)
478478 Spacer()
479479 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))
481481 }
482482 }
483483 .buttonStyle(.plain)
@@ -529,11 +529,11 @@ private func auditStatusBadge(_ status: AuditStatus) -> some View {
529529 let model: AppStatusBadgeModel
530530 switch status {
531531 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)
533533 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)
535535 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)
537537 }
538538 return AppStatusBadgeView(model: model)
539539}
@@ -554,8 +554,8 @@ private func findingSeverityBadge(_ severity: AuditFindingSeverity) -> some View
554554 model: .init(
555555 title: severity.title,
556556 systemImage: "exclamationmark.circle.fill",
557 foregroundColor: tone.foreground,
558 backgroundColor: tone.surface
557 foreground: tone.foreground,
558 background: tone.surface
559559 )
560560 )
561561}
DomainDig/BatchResultsView.swift +17 −17
@@ -13,16 +13,16 @@ struct BatchResultsView: View {
1313 if viewModel.batchLookupRunning {
1414 VStack(alignment: .trailing, spacing: 4) {
1515 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1)))
16 .tint(Color(.statusInfo))
16 .tint(ThemeToken.info)
1717 .frame(width: 120)
1818 Text(viewModel.batchProgressLabel)
1919 .font(appDensity.font(.caption2))
20 .foregroundStyle(Color(.appTextSecondary))
20 .foregroundStyle(ThemeToken.textSecondary)
2121 }
2222 } else if !viewModel.batchResults.isEmpty {
2323 Text("\(viewModel.batchResults.count) domains")
2424 .font(appDensity.font(.caption2))
25 .foregroundStyle(Color(.appTextSecondary))
25 .foregroundStyle(ThemeToken.textSecondary)
2626 }
2727 }
2828
@@ -86,7 +86,7 @@ struct BatchResultRowView: View {
8686 }
8787 }
8888 .font(appDensity.font(.caption2))
89 .foregroundStyle(Color(.appTextSecondary))
89 .foregroundStyle(ThemeToken.textSecondary)
9090
9191 HStack(spacing: 10) {
9292 Text(result.primaryIP ?? "No IP")
@@ -99,12 +99,12 @@ struct BatchResultRowView: View {
9999 .lineLimit(1)
100100 }
101101 .font(appDensity.font(.caption2))
102 .foregroundStyle(Color(.appTextSecondary))
102 .foregroundStyle(ThemeToken.textSecondary)
103103
104104 if let summaryMessage = result.summaryMessage {
105105 Text(summaryMessage)
106106 .font(appDensity.font(.caption2))
107 .foregroundStyle(Color(.appTextSecondary))
107 .foregroundStyle(ThemeToken.textSecondary)
108108 }
109109
110110 if let changeClassification = result.changeClassification {
@@ -116,7 +116,7 @@ struct BatchResultRowView: View {
116116 if let errorMessage = result.errorMessage {
117117 Text(errorMessage)
118118 .font(appDensity.font(.caption2))
119 .foregroundStyle(result.status == .failed ? Color(.statusCritical) : Color(.appTextSecondary))
119 .foregroundStyle(result.status == .failed ? ThemeToken.critical : ThemeToken.textSecondary)
120120 }
121121 }
122122 .frame(maxWidth: .infinity, alignment: .leading)
@@ -151,7 +151,7 @@ struct BatchResultRowView: View {
151151 private var sourceLabel: some View {
152152 Text(result.resultSource.label.lowercased())
153153 .font(appDensity.font(.caption2))
154 .foregroundStyle(Color(.appTextSecondary))
154 .foregroundStyle(ThemeToken.textSecondary)
155155 }
156156
157157 private var changeContentLabel: String {
@@ -191,30 +191,30 @@ struct BatchResultRowView: View {
191191 return .init(
192192 title: availabilityText,
193193 systemImage: "exclamationmark.circle",
194 foregroundColor: Color(.appTextSecondary),
195 backgroundColor: Color(.appSurfaceElevated)
194 foreground: .textSecondary,
195 background: .surfaceElevated
196196 )
197197 }
198198
199199 private var quickStatusBadge: AppStatusBadgeModel {
200200 switch result.status {
201201 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)
203203 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)
205205 case .completed:
206206 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)
208208 }
209209 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)
211211 }
212212 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)
214214 }
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)
216216 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)
218218 }
219219 }
220220}
DomainDig/BatchSweepSummaryView.swift +2 −2
@@ -43,7 +43,7 @@ struct BatchSweepSummaryView: View {
4343 HStack {
4444 Text(label)
4545 .font(.system(.caption, design: .monospaced))
46 .foregroundStyle(Color(.appTextSecondary))
46 .foregroundStyle(ThemeToken.textSecondary)
4747 Spacer()
4848 Text(value)
4949 .font(.system(.callout, design: .monospaced))
@@ -65,7 +65,7 @@ struct BatchResultsSection: View {
6565 if results.isEmpty {
6666 Text(emptyText)
6767 .font(.system(.caption, design: .monospaced))
68 .foregroundStyle(Color(.appTextSecondary))
68 .foregroundStyle(ThemeToken.textSecondary)
6969 } else {
7070 ForEach(results) { result in
7171 if let entry = viewModel.historyEntry(for: result) {
DomainDig/ContentView.swift +18 −18
@@ -120,10 +120,10 @@ struct ContentView: View {
120120 Section { recentSearchesSection }
121121 }
122122 }
123 .listRowBackground(Color(.appSurface))
123 .themedListRowBackground(.surface)
124124 .environment(\.cardProvidesSurface, false)
125125 .scrollContentBackground(.hidden)
126 .background(Color(.appBackground))
126 .background(ThemeToken.background)
127127 .navigationTitle("DomainDig")
128128 .toolbar {
129129 ToolbarItem(placement: .topBarTrailing) {
@@ -140,7 +140,7 @@ struct ContentView: View {
140140 viewModel.reset()
141141 } label: {
142142 Image(systemName: "xmark.circle")
143 .foregroundStyle(Color(.appTextSecondary))
143 .foregroundStyle(ThemeToken.textSecondary)
144144 }
145145 .accessibilityLabel("Clear results")
146146 }
@@ -280,7 +280,7 @@ struct ContentView: View {
280280 .keyboardType(.URL)
281281 .padding(.horizontal, 12)
282282 .padding(.vertical, appDensity.metrics.controlVerticalPadding)
283 .background(Color(.appSurfaceElevated))
283 .background(ThemeToken.surfaceElevated)
284284 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
285285 .focused($focusedInputField, equals: .singleDomain)
286286 .onSubmit {
@@ -291,7 +291,7 @@ struct ContentView: View {
291291 if let domainInputError = viewModel.domainInputError {
292292 Text(domainInputError)
293293 .font(appDensity.font(.caption))
294 .foregroundStyle(Color(.statusCritical))
294 .foregroundStyle(ThemeToken.critical)
295295 .frame(maxWidth: .infinity, alignment: .leading)
296296 }
297297
@@ -305,19 +305,19 @@ struct ContentView: View {
305305 .frame(minHeight: appDensity.metrics.controlMinHeight)
306306 }
307307 .buttonStyle(.borderedProminent)
308 .tint(Color(.accentFill))
308 .tint(ThemeToken.accent)
309309 .disabled(viewModel.trimmedDomain.isEmpty)
310310 } else {
311311 if FeatureAccessService.hasAccess(to: .batchOperations) {
312312 VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) {
313313 Text("Paste domains separated by new lines or commas.")
314314 .font(appDensity.font(.caption))
315 .foregroundStyle(Color(.appTextSecondary))
315 .foregroundStyle(ThemeToken.textSecondary)
316316
317317 if let batchAllowanceSummary = FeatureAccessService.batchAllowanceSummary() {
318318 Text(batchAllowanceSummary)
319319 .font(appDensity.font(.caption2))
320 .foregroundStyle(Color(.appTextSecondary))
320 .foregroundStyle(ThemeToken.textSecondary)
321321 }
322322
323323 TextField(
@@ -332,14 +332,14 @@ struct ContentView: View {
332332 .lineLimit(4...10)
333333 .padding(.horizontal, 12)
334334 .padding(.vertical, appDensity.metrics.controlVerticalPadding)
335 .background(Color(.appSurfaceElevated))
335 .background(ThemeToken.surfaceElevated)
336336 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
337337 .focused($focusedInputField, equals: .bulkDomains)
338338
339339 if let bulkInputError = viewModel.bulkInputError {
340340 Text(bulkInputError)
341341 .font(appDensity.font(.caption))
342 .foregroundStyle(Color(.statusCritical))
342 .foregroundStyle(ThemeToken.critical)
343343 .frame(maxWidth: .infinity, alignment: .leading)
344344 }
345345
@@ -353,7 +353,7 @@ struct ContentView: View {
353353 .frame(minHeight: appDensity.metrics.controlMinHeight)
354354 }
355355 .buttonStyle(.borderedProminent)
356 .tint(Color(.accentFill))
356 .tint(ThemeToken.accent)
357357 .disabled(viewModel.bulkInput.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || viewModel.batchLookupRunning)
358358 }
359359 } else {
@@ -529,7 +529,7 @@ struct ContentView: View {
529529 } label: {
530530 Image(systemName: "bolt.circle")
531531 .font(appDensity.font(.body, design: .default))
532 .foregroundStyle(Color(.appTextSecondary))
532 .foregroundStyle(ThemeToken.textSecondary)
533533 }
534534 .accessibilityLabel("Actions")
535535 Menu {
@@ -537,7 +537,7 @@ struct ContentView: View {
537537 } label: {
538538 Image(systemName: "square.and.arrow.up")
539539 .font(appDensity.font(.body, design: .default))
540 .foregroundStyle(Color(.appTextSecondary))
540 .foregroundStyle(ThemeToken.textSecondary)
541541 }
542542 .accessibilityLabel("Export")
543543 }
@@ -582,13 +582,13 @@ struct ContentView: View {
582582 HStack {
583583 Text("RECENT")
584584 .font(appDensity.font(.caption2))
585 .foregroundStyle(Color(.appTextSecondary))
585 .foregroundStyle(ThemeToken.textSecondary)
586586 Spacer()
587587 Button("Clear") {
588588 viewModel.clearRecentSearches()
589589 }
590590 .font(appDensity.font(.caption2))
591 .foregroundStyle(Color(.appTextSecondary))
591 .foregroundStyle(ThemeToken.textSecondary)
592592 }
593593
594594 ForEach(viewModel.recentSearches, id: \.self) { domain in
@@ -603,7 +603,7 @@ struct ContentView: View {
603603 .frame(maxWidth: .infinity, alignment: .leading)
604604 .padding(.vertical, 8)
605605 .padding(.horizontal, 10)
606 .background(Color(.appSurface))
606 .background(ThemeToken.surface)
607607 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
608608 }
609609 }
@@ -624,11 +624,11 @@ struct ContentView: View {
624624 .font(appDensity.font(.headline, design: .default, weight: .semibold))
625625 Text(message)
626626 .font(appDensity.font(.callout, design: .default))
627 .foregroundStyle(Color(.appTextSecondary))
627 .foregroundStyle(ThemeToken.textSecondary)
628628 }
629629 .frame(maxWidth: .infinity, alignment: .leading)
630630 .padding(appDensity.metrics.cardPadding)
631 .background(Color(.appSurfaceElevated))
631 .background(ThemeToken.surfaceElevated)
632632 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
633633 }
634634
DomainDig/DNSSectionView.swift +7 −7
@@ -64,7 +64,7 @@ struct DNSSectionView: View {
6464 Text(section.title)
6565 .font(.system(.subheadline, design: .monospaced))
6666 .fontWeight(.semibold)
67 .foregroundStyle(Color(.statusInfo))
67 .foregroundStyle(ThemeToken.info)
6868
6969 if let message = section.message {
7070 MessageRowView(text: message.text, isError: message.isError)
@@ -77,7 +77,7 @@ struct DNSSectionView: View {
7777 if let wildcardTitle = section.wildcardTitle {
7878 Text(wildcardTitle)
7979 .font(.system(.caption, design: .monospaced))
80 .foregroundStyle(Color(.appTextSecondary))
80 .foregroundStyle(ThemeToken.textSecondary)
8181 .padding(.top, 4)
8282 ForEach(section.wildcardRows) { row in
8383 LabeledValueRow(row: row)
@@ -91,7 +91,7 @@ struct DNSSectionView: View {
9191 Text("PTR")
9292 .font(.system(.subheadline, design: .monospaced))
9393 .fontWeight(.semibold)
94 .foregroundStyle(Color(.statusInfo))
94 .foregroundStyle(ThemeToken.info)
9595 SectionTrustMetadataView(provenance: ptrProvenance, confidence: nil)
9696 MessageRowView(text: ptrMessage.text, isError: ptrMessage.isError)
9797 }
@@ -101,7 +101,7 @@ struct DNSSectionView: View {
101101 HStack {
102102 Text("History")
103103 .font(appDensity.font(.subheadline, weight: .semibold))
104 .foregroundStyle(Color(.statusInfo))
104 .foregroundStyle(ThemeToken.info)
105105 Spacer()
106106 if let onLoadHistory, history.isEmpty, !historyLoading {
107107 Button("Load") {
@@ -127,18 +127,18 @@ struct DNSSectionView: View {
127127 VStack(alignment: .leading, spacing: 3) {
128128 Text(event.date.formatted(date: .abbreviated, time: .omitted))
129129 .font(appDensity.font(.caption2))
130 .foregroundStyle(Color(.appTextSecondary))
130 .foregroundStyle(ThemeToken.textSecondary)
131131 Text(event.summary)
132132 .font(appDensity.font(.caption))
133133 if !event.aRecords.isEmpty {
134134 Text("A: \(event.aRecords.joined(separator: ", "))")
135135 .font(appDensity.font(.caption2))
136 .foregroundStyle(Color(.appTextSecondary))
136 .foregroundStyle(ThemeToken.textSecondary)
137137 }
138138 if !event.nameservers.isEmpty {
139139 Text("NS: \(event.nameservers.joined(separator: ", "))")
140140 .font(appDensity.font(.caption2))
141 .foregroundStyle(Color(.appTextSecondary))
141 .foregroundStyle(ThemeToken.textSecondary)
142142 }
143143 }
144144 }
DomainDig/DashboardView.swift +41 −38
@@ -2,6 +2,9 @@ import SwiftUI
22
33struct DashboardView: View {
44 @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
58 @Environment(\.accessibilityDifferentiateWithoutColor) private var differentiateWithoutColor
69 @Bindable var viewModel: DomainViewModel
710 @State private var collapsedGroups = Set<String>()
@@ -31,20 +34,20 @@ struct DashboardView: View {
3134 showsCardBackground: false
3235 )
3336 }
34 .listRowBackground(Color(.appSurface))
37 .themedListRowBackground(.surface)
3538 } else {
3639 Section {
3740 LazyVGrid(columns: summaryColumns, spacing: 10) {
38 summaryCard(title: "Total Domains", value: dashboard.snapshot.totalDomains, filter: .all, tint: Color(.statusInfo))
39 summaryCard(title: "Healthy", value: dashboard.snapshot.healthyCount, filter: .healthy, tint: Color(.statusPositive))
40 summaryCard(title: "Warning", value: dashboard.snapshot.warningCount, filter: .warning, tint: Color(.statusWarning))
41 summaryCard(title: "Critical", value: dashboard.snapshot.criticalCount, filter: .critical, tint: Color(.statusCritical))
42 summaryCard(title: "Changes (24h)", value: dashboard.snapshot.changedLast24h, filter: .changed, tint: Color(.statusWarning))
43 summaryCard(title: "Unreachable", value: dashboard.snapshot.unreachableCount, filter: .unreachable, tint: Color(.statusCritical))
41 summaryCard(title: "Total Domains", value: dashboard.snapshot.totalDomains, filter: .all, tint: .info)
42 summaryCard(title: "Healthy", value: dashboard.snapshot.healthyCount, filter: .healthy, tint: .positive)
43 summaryCard(title: "Warning", value: dashboard.snapshot.warningCount, filter: .warning, tint: .warning)
44 summaryCard(title: "Critical", value: dashboard.snapshot.criticalCount, filter: .critical, tint: .critical)
45 summaryCard(title: "Changes (24h)", value: dashboard.snapshot.changedLast24h, filter: .changed, tint: .warning)
46 summaryCard(title: "Unreachable", value: dashboard.snapshot.unreachableCount, filter: .unreachable, tint: .critical)
4447 }
4548 .padding(.vertical, 4)
4649 }
47 .listRowBackground(Color(.appSurface))
50 .themedListRowBackground(.surface)
4851
4952 Section("Quick Filters") {
5053 ScrollView(.horizontal, showsIndicators: false) {
@@ -66,10 +69,10 @@ struct DashboardView: View {
6669 Text(filter.title)
6770 .font(appDensity.font(.caption, weight: .semibold))
6871 }
69 .foregroundStyle(isSelected ? Color(.appOnAccent) : Color.primary)
72 .foregroundStyle(isSelected ? AnyShapeStyle(ThemeToken.onAccent) : AnyShapeStyle(.primary))
7073 .padding(.horizontal, 12)
7174 .padding(.vertical, 8)
72 .background(isSelected ? Color(.statusInfo) : Color(.appSurfaceElevated))
75 .background(isSelected ? ThemeToken.info : ThemeToken.surfaceElevated)
7376 .overlay(
7477 Capsule().strokeBorder(
7578 Color.primary,
@@ -85,7 +88,7 @@ struct DashboardView: View {
8588 .padding(.vertical, 4)
8689 }
8790 }
88 .listRowBackground(Color(.appSurface))
91 .themedListRowBackground(.surface)
8992
9093 Section("Recent Activity") {
9194 if visible.recentActivity.isEmpty {
@@ -98,7 +101,7 @@ struct DashboardView: View {
98101 }
99102 }
100103 }
101 .listRowBackground(Color(.appSurface))
104 .themedListRowBackground(.surface)
102105
103106 Section("Attention Required") {
104107 if visible.attentionRequired.isEmpty {
@@ -111,7 +114,7 @@ struct DashboardView: View {
111114 }
112115 }
113116 }
114 .listRowBackground(Color(.appSurface))
117 .themedListRowBackground(.surface)
115118
116119 Section("Expiring Soon") {
117120 if visible.expiringSoon.isEmpty {
@@ -127,7 +130,7 @@ struct DashboardView: View {
127130 }
128131 }
129132 }
130 .listRowBackground(Color(.appSurface))
133 .themedListRowBackground(.surface)
131134
132135 Section("Portfolio List") {
133136 if visible.groups.isEmpty {
@@ -156,7 +159,7 @@ struct DashboardView: View {
156159 .font(appDensity.font(.headline, design: .default, weight: .semibold))
157160 Text("\(group.domains.count) domain\(group.domains.count == 1 ? "" : "s")")
158161 .font(appDensity.font(.caption))
159 .foregroundStyle(Color(.appTextSecondary))
162 .foregroundStyle(ThemeToken.textSecondary)
160163 }
161164 Spacer()
162165 groupBadge(for: group.domains)
@@ -167,11 +170,11 @@ struct DashboardView: View {
167170 }
168171 }
169172 }
170 .listRowBackground(Color(.appSurface))
173 .themedListRowBackground(.surface)
171174 }
172175 }
173176 .scrollContentBackground(.hidden)
174 .background(Color(.appBackground))
177 .background(ThemeToken.background)
175178 .navigationTitle("Dashboard")
176179 .searchable(text: $viewModel.dashboardSearchText, prompt: "Search portfolio")
177180 .toolbar {
@@ -213,14 +216,14 @@ struct DashboardView: View {
213216 )
214217 }
215218
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 {
217220 Button {
218221 viewModel.dashboardFilter = filter
219222 } label: {
220223 VStack(alignment: .leading, spacing: 8) {
221224 Text(title)
222225 .font(appDensity.font(.caption, design: .default, weight: .semibold))
223 .foregroundStyle(Color(.appTextSecondary))
226 .foregroundStyle(ThemeToken.textSecondary)
224227 Text("\(value)")
225228 // Was a fixed 28pt, which ignored Dynamic Type entirely.
226229 .font(.system(.title, design: .rounded, weight: .bold))
@@ -270,13 +273,13 @@ struct DashboardView: View {
270273 // trick into light mode.
271274 return AnyShapeStyle(
272275 LinearGradient(
273 colors: [Color(.statusInfoSurface), Color(.appSurface)],
276 colors: [theme[.infoSurface], theme[.surface]],
274277 startPoint: .topLeading,
275278 endPoint: .bottomTrailing
276279 )
277280 )
278281 }
279 return AnyShapeStyle(Color(.appSurfaceElevated))
282 return AnyShapeStyle(ThemeToken.surfaceElevated)
280283 }
281284
282285 /// `label`, opening the tracked domain's detail; nothing for a domain no longer tracked.
@@ -295,7 +298,7 @@ struct DashboardView: View {
295298 private func dashboardEmptyRow(_ message: String) -> some View {
296299 Text(message)
297300 .font(appDensity.font(.caption))
298 .foregroundStyle(Color(.appTextSecondary))
301 .foregroundStyle(ThemeToken.textSecondary)
299302 .padding(.vertical, 4)
300303 }
301304
@@ -324,8 +327,8 @@ struct DashboardView: View {
324327 model: .init(
325328 title: title,
326329 systemImage: systemImage,
327 foregroundColor: tone.foreground,
328 backgroundColor: tone.surface
330 foreground: tone.foreground,
331 background: tone.surface
329332 )
330333 )
331334 }
@@ -353,20 +356,20 @@ private struct PortfolioActivityRow: View {
353356 Text(relativeTimestamp(item.timestamp))
354357 }
355358 .font(appDensity.font(.caption2))
356 .foregroundStyle(Color(.appTextSecondary))
359 .foregroundStyle(ThemeToken.textSecondary)
357360 }
358361 }
359362 .padding(.vertical, 4)
360363 }
361364
362 private var iconColor: Color {
365 private var iconColor: AnyShapeStyle {
363366 switch item.health {
364367 case .healthy:
365 return Color(.statusInfo)
368 return AnyShapeStyle(ThemeToken.info)
366369 case .warning:
367 return Color(.statusWarning)
370 return AnyShapeStyle(ThemeToken.warning)
368371 case .critical:
369 return Color(.statusCritical)
372 return AnyShapeStyle(ThemeToken.critical)
370373 }
371374 }
372375}
@@ -385,10 +388,10 @@ private struct PortfolioAttentionRow: View {
385388 .foregroundStyle(.primary)
386389 Text(item.reason)
387390 .font(appDensity.font(.caption, design: .default))
388 .foregroundStyle(Color(.appTextSecondary))
391 .foregroundStyle(ThemeToken.textSecondary)
389392 Text(relativeTimestamp(item.timestamp))
390393 .font(appDensity.font(.caption2))
391 .foregroundStyle(Color(.appTextSecondary))
394 .foregroundStyle(ThemeToken.textSecondary)
392395 }
393396 }
394397 .padding(.vertical, 4)
@@ -397,11 +400,11 @@ private struct PortfolioAttentionRow: View {
397400 private var badgeModel: AppStatusBadgeModel {
398401 switch item.health {
399402 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)
401404 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)
403406 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)
405408 }
406409 }
407410}
@@ -434,7 +437,7 @@ private struct PortfolioExpiryRow: View {
434437 .foregroundStyle(.primary)
435438 Text(expirySubtitle)
436439 .font(appDensity.font(.caption))
437 .foregroundStyle(Color(.appTextSecondary))
440 .foregroundStyle(ThemeToken.textSecondary)
438441 }
439442 }
440443
@@ -448,11 +451,11 @@ private struct PortfolioExpiryRow: View {
448451 private var badgeModel: AppStatusBadgeModel {
449452 switch state.certificateExpiryState {
450453 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)
452455 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)
454457 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)
456459 }
457460 }
458461}
DomainDig/DomainCompareView.swift +3 −3
@@ -38,7 +38,7 @@ struct DomainCompareView: View {
3838 Section {
3939 Text("Choose two different domains to compare.")
4040 .font(.callout)
41 .foregroundStyle(Color(.appTextSecondary))
41 .foregroundStyle(ThemeToken.textSecondary)
4242 }
4343 }
4444
@@ -63,11 +63,11 @@ struct DomainCompareView: View {
6363 showsCardBackground: false
6464 )
6565 }
66 .listRowBackground(Color(.appSurface))
66 .themedListRowBackground(.surface)
6767 }
6868 }
6969 .scrollContentBackground(.hidden)
70 .background(Color(.appBackground))
70 .background(ThemeToken.background)
7171 .navigationTitle("Compare Domains")
7272 }
7373
DomainDig/DomainDiffViews.swift +17 −17
@@ -13,11 +13,11 @@ struct DomainChangeSummaryView: View {
1313 HStack {
1414 Label(summary.hasChanges ? "Changed" : "Stable", systemImage: summary.hasChanges ? "arrow.triangle.2.circlepath" : "checkmark.circle")
1515 .font(appDensity.font(.caption))
16 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : Color(.statusPositive))
16 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : ThemeToken.positive)
1717 Spacer()
1818 Text(summary.severity.title.uppercased())
1919 .font(appDensity.font(.caption2))
20 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : Color(.appTextSecondary))
20 .foregroundStyle(summary.hasChanges ? severityTone(summary.severity).foreground : ThemeToken.textSecondary)
2121 .padding(.horizontal, 8)
2222 .padding(.vertical, 4)
2323 .background((summary.hasChanges ? severityTone(summary.severity) : AppStatusTone.neutral).surface)
@@ -31,13 +31,13 @@ struct DomainChangeSummaryView: View {
3131 .clipShape(Capsule())
3232 Text(summary.generatedAt, style: .time)
3333 .font(appDensity.font(.caption2))
34 .foregroundStyle(Color(.appTextSecondary))
34 .foregroundStyle(ThemeToken.textSecondary)
3535 }
3636
3737 VStack(alignment: .leading, spacing: 4) {
3838 Text("Inference")
3939 .font(appDensity.font(.caption2))
40 .foregroundStyle(Color(.appTextSecondary))
40 .foregroundStyle(ThemeToken.textSecondary)
4141 Text(summary.message)
4242 .font(appDensity.font(.caption))
4343 .foregroundStyle(.primary)
@@ -51,7 +51,7 @@ struct DomainChangeSummaryView: View {
5151 VStack(alignment: .leading, spacing: 4) {
5252 Text("Observed")
5353 .font(appDensity.font(.caption2))
54 .foregroundStyle(Color(.appTextSecondary))
54 .foregroundStyle(ThemeToken.textSecondary)
5555 ForEach(Array(summary.observedFacts.enumerated()), id: \.offset) { _, fact in
5656 Text(fact)
5757 .font(appDensity.font(.caption))
@@ -63,13 +63,13 @@ struct DomainChangeSummaryView: View {
6363 if let riskScoreDelta = summary.riskScoreDelta {
6464 Text("Risk delta: \(riskScoreDelta >= 0 ? "+" : "")\(riskScoreDelta)")
6565 .font(appDensity.font(.caption2))
66 .foregroundStyle(riskScoreDelta > 0 ? Color(.statusWarning) : .secondary)
66 .foregroundStyle(riskScoreDelta > 0 ? AnyShapeStyle(ThemeToken.warning) : AnyShapeStyle(.secondary))
6767 }
6868
6969 if let contextNote = summary.contextNote {
7070 Text(contextNote)
7171 .font(appDensity.font(.caption2))
72 .foregroundStyle(Color(.statusWarning))
72 .foregroundStyle(ThemeToken.warning)
7373 }
7474 }
7575 .padding(.top, 4)
@@ -153,7 +153,7 @@ struct DomainDiffView: View {
153153 HStack {
154154 Text(item.label)
155155 .font(.system(.caption, design: .monospaced))
156 .foregroundStyle(Color(.appTextSecondary))
156 .foregroundStyle(ThemeToken.textSecondary)
157157 Spacer()
158158 Text("\(item.changeType.marker) \(item.severity.title) • \(changeLabel(for: item.changeType))")
159159 .font(.system(.caption2, design: .monospaced))
@@ -168,10 +168,10 @@ struct DomainDiffView: View {
168168 VStack(alignment: .leading, spacing: 2) {
169169 Text("Old")
170170 .font(.system(.caption2, design: .monospaced))
171 .foregroundStyle(Color(.appTextSecondary))
171 .foregroundStyle(ThemeToken.textSecondary)
172172 Text(oldValue)
173173 .font(.system(.caption2, design: .monospaced))
174 .foregroundStyle(Color(.appTextSecondary))
174 .foregroundStyle(ThemeToken.textSecondary)
175175 .textSelection(.enabled)
176176 }
177177 }
@@ -180,7 +180,7 @@ struct DomainDiffView: View {
180180 VStack(alignment: .leading, spacing: 2) {
181181 Text("New")
182182 .font(.system(.caption2, design: .monospaced))
183 .foregroundStyle(Color(.appTextSecondary))
183 .foregroundStyle(ThemeToken.textSecondary)
184184 Text(newValue)
185185 .font(.system(.caption, design: .monospaced))
186186 .foregroundStyle(item.hasChanges ? .primary : .secondary)
@@ -189,7 +189,7 @@ struct DomainDiffView: View {
189189 }
190190 }
191191 .padding(10)
192 .background(item.hasChanges ? changeTone(for: item).surface : Color(.appSurface))
192 .background(item.hasChanges ? changeTone(for: item).surface : ThemeToken.surface)
193193 .cornerRadius(8)
194194 }
195195 } label: {
@@ -209,7 +209,7 @@ struct DomainDiffView: View {
209209 .overlay {
210210 if highlightedSectionID == section.id {
211211 RoundedRectangle(cornerRadius: 12)
212 .stroke(Color(.statusInfo).opacity(0.55), lineWidth: 1)
212 .stroke(ThemeToken.info.opacity(0.55), lineWidth: 1)
213213 }
214214 }
215215 }
@@ -248,14 +248,14 @@ struct DomainDiffView: View {
248248 }
249249 }
250250
251 private func sectionColor(_ section: DomainDiffSection) -> Color {
251 private func sectionColor(_ section: DomainDiffSection) -> AnyShapeStyle {
252252 switch section.severity {
253253 case .low:
254 return .blue
254 return AnyShapeStyle(.blue)
255255 case .medium:
256 return Color(.statusWarning)
256 return AnyShapeStyle(ThemeToken.warning)
257257 case .high:
258 return Color(.statusCritical)
258 return AnyShapeStyle(ThemeToken.critical)
259259 }
260260 }
261261
DomainDig/DomainDigApp.swift +13
@@ -13,11 +13,20 @@ struct DomainDigApp: App {
1313 @Environment(\.scenePhase) private var scenePhase
1414 @AppStorage(AppDensity.userDefaultsKey) private var density = AppDensity.compact.rawValue
1515 @AppStorage(AppAppearance.userDefaultsKey) private var appearance = AppAppearance.system.rawValue
16 @AppStorage(AccentTheme.userDefaultsKey) private var accent = AccentTheme.default.rawValue
1617 @State private var viewModel = DomainViewModel()
1718 @State private var purchaseService = PurchaseService.shared
1819 @State private var cloudSyncService = CloudSyncService.shared
1920 @State private var localAPIService = LocalAPIService.shared
2021
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
2130 init() {
2231 LocalNotificationService.shared.configureForegroundPresentation()
2332 DomainMonitoringScheduler.shared.registerBackgroundTask()
@@ -28,6 +37,10 @@ struct DomainDigApp: App {
2837 WindowGroup {
2938 RootTabView(viewModel: viewModel)
3039 .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)
3144 // The single place appearance is applied. Keep it that way.
3245 .preferredColorScheme((AppAppearance(rawValue: appearance) ?? .system).colorScheme)
3346 .task {
DomainDig/DomainDigUI.swift +46 −39
@@ -145,95 +145,102 @@ enum AppStatusTone {
145145 case info
146146 case neutral
147147
148 var foreground: Color {
148 var foreground: ThemeToken {
149149 switch self {
150150 case .positive:
151 return Color(.statusPositive)
151 return .positive
152152 case .warning:
153 return Color(.statusWarning)
153 return .warning
154154 case .critical:
155 return Color(.statusCritical)
155 return .critical
156156 case .info:
157 return Color(.statusInfo)
157 return .info
158158 case .neutral:
159 return Color(.statusNeutral)
159 return .neutral
160160 }
161161 }
162162
163 var surface: Color {
163 var surface: ThemeToken {
164164 switch self {
165165 case .positive:
166 return Color(.statusPositiveSurface)
166 return .positiveSurface
167167 case .warning:
168 return Color(.statusWarningSurface)
168 return .warningSurface
169169 case .critical:
170 return Color(.statusCriticalSurface)
170 return .criticalSurface
171171 case .info:
172 return Color(.statusInfoSurface)
172 return .infoSurface
173173 case .neutral:
174 return Color(.statusNeutralSurface)
174 return .neutralSurface
175175 }
176176 }
177177}
178178
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.
179185struct AppStatusBadgeModel: Equatable {
180186 let title: String
181187 let systemImage: String?
182 let foregroundColor: Color
183 let backgroundColor: Color
188 let foreground: ThemeToken
189 let background: ThemeToken
184190}
185191
186192enum AppStatusFactory {
187193 static func availability(_ status: DomainAvailabilityStatus?) -> AppStatusBadgeModel {
188194 switch status {
189195 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)
191197 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)
193199 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)
195201 }
196202 }
197203
198204 static func tls(sslInfo: SSLCertificateInfo?, error: String?) -> AppStatusBadgeModel {
199205 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)
201207 }
202208 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)
204210 }
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)
206212 }
207213
208214 static func email(_ result: EmailSecurityResult?, error: String?) -> AppStatusBadgeModel {
209215 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)
211217 }
212218
213219 let foundCount = [result.spf.found, result.dmarc.found, result.dkim.found].filter { $0 }.count
214220 switch foundCount {
215221 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)
217223 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)
219225 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)
221227 }
222228 }
223229
224230 static func change(_ summary: DomainChangeSummary?) -> AppStatusBadgeModel {
225231 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)
227233 }
228234 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)
230236 }
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)
232238 }
233239}
234240
235241struct AppStatusBadgeView: View {
236242 @Environment(\.appDensity) private var appDensity
243 @Environment(\.theme) private var theme
237244
238245 let model: AppStatusBadgeModel
239246
@@ -251,10 +258,10 @@ struct AppStatusBadgeView: View {
251258 // ViewThatFits onto its stacked layout, which is the intended fallback.
252259 .fixedSize()
253260 .font(appDensity.font(.caption, weight: .semibold))
254 .foregroundStyle(model.foregroundColor)
261 .foregroundStyle(theme[model.foreground])
255262 .padding(.horizontal, 9)
256263 .padding(.vertical, 5)
257 .background(model.backgroundColor)
264 .background(theme[model.background])
258265 .clipShape(Capsule())
259266 // Read as one word ("Critical"), not "icon, Critical". The symbol
260267 // duplicates the title for VoiceOver.
@@ -294,9 +301,9 @@ struct AppCopyButton: View {
294301 } label: {
295302 Image(systemName: didCopy ? "checkmark" : "doc.on.doc")
296303 .font(appDensity.font(.caption))
297 .foregroundStyle(didCopy ? Color(.statusPositive) : Color(.appTextSecondary))
304 .foregroundStyle(didCopy ? ThemeToken.positive : ThemeToken.textSecondary)
298305 .frame(width: max(size, AppLayout.minimumTapTarget), height: max(size, AppLayout.minimumTapTarget))
299 .background(Color(.appSurfaceElevated))
306 .background(ThemeToken.surfaceElevated)
300307 .clipShape(RoundedRectangle(cornerRadius: 8))
301308 }
302309 .buttonStyle(.plain)
@@ -400,17 +407,17 @@ struct EmptyStateCardView: View {
400407
401408 Text(message)
402409 .font(appDensity.font(.body))
403 .foregroundStyle(Color(.appTextSecondary))
410 .foregroundStyle(ThemeToken.textSecondary)
404411 .fixedSize(horizontal: false, vertical: true)
405412
406413 Text(suggestion)
407414 .font(appDensity.font(.caption))
408 .foregroundStyle(Color(.statusInfo))
415 .foregroundStyle(ThemeToken.info)
409416 .fixedSize(horizontal: false, vertical: true)
410417 }
411418 .frame(maxWidth: .infinity, alignment: .leading)
412419 .padding(appDensity.metrics.cardPadding)
413 .background(showsCardBackground ? Color(.appSurface) : Color.clear)
420 .background(showsCardBackground ? AnyShapeStyle(ThemeToken.surface) : AnyShapeStyle(.clear))
414421 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
415422 }
416423}
@@ -503,7 +510,7 @@ struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View {
503510 if let subtitle {
504511 Text(subtitle)
505512 .font(appDensity.font(.caption))
506 .foregroundStyle(Color(.appTextSecondary))
513 .foregroundStyle(ThemeToken.textSecondary)
507514 .fixedSize(horizontal: false, vertical: true)
508515 }
509516 }
@@ -512,7 +519,7 @@ struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View {
512519 private var chevron: some View {
513520 Image(systemName: isCollapsed ? "chevron.down" : "chevron.up")
514521 .font(.caption.weight(.semibold))
515 .foregroundStyle(Color(.appTextSecondary))
522 .foregroundStyle(ThemeToken.textSecondary)
516523 .accessibilityHidden(true)
517524 }
518525}
@@ -530,7 +537,7 @@ struct TagChipRowView: View {
530537 .font(.caption)
531538 .padding(.horizontal, 10)
532539 .padding(.vertical, 5)
533 .background(Color(.appSurfaceElevated), in: Capsule())
540 .background(ThemeToken.surfaceElevated, in: Capsule())
534541 }
535542 }
536543 }
@@ -564,8 +571,8 @@ struct TagFilterChipRowView: View {
564571 .font(.caption)
565572 .padding(.horizontal, 10)
566573 .padding(.vertical, 5)
567 .background(isSelected ? Color(.statusInfoSurface) : Color(.appSurfaceElevated), in: Capsule())
568 .foregroundStyle(isSelected ? Color(.statusInfo) : Color.primary)
574 .background(isSelected ? ThemeToken.infoSurface : ThemeToken.surfaceElevated, in: Capsule())
575 .foregroundStyle(isSelected ? AnyShapeStyle(ThemeToken.info) : AnyShapeStyle(.primary))
569576 }
570577 .buttonStyle(.plain)
571578 }
DomainDig/DomainSectionView.swift +4 −4
@@ -35,9 +35,9 @@ struct DomainSectionView: View {
3535 // VoiceOver still hears the word via the label.
3636 Image(systemName: "eye.fill")
3737 .font(appDensity.font(.caption))
38 .foregroundStyle(Color(.statusPositive))
38 .foregroundStyle(ThemeToken.positive)
3939 .padding(6)
40 .background(Color(.statusPositiveSurface), in: Circle())
40 .background(ThemeToken.positiveSurface, in: Circle())
4141 .fixedSize()
4242 .accessibilityLabel("Tracked")
4343 Button {
@@ -100,7 +100,7 @@ struct DomainSectionView: View {
100100 VStack(alignment: .leading, spacing: 8) {
101101 Text("Part of workflow")
102102 .font(appDensity.font(.caption))
103 .foregroundStyle(Color(.appTextSecondary))
103 .foregroundStyle(ThemeToken.textSecondary)
104104
105105 ForEach(workflows) { workflow in
106106 HStack {
@@ -135,7 +135,7 @@ struct DomainSectionView: View {
135135 if showSuggestions {
136136 Text("Suggestions")
137137 .font(appDensity.font(.caption))
138 .foregroundStyle(Color(.appTextSecondary))
138 .foregroundStyle(ThemeToken.textSecondary)
139139 .padding(.top, 4)
140140 if suggestionsLoading {
141141 ProgressView("Checking alternatives…")
DomainDig/EmailSectionView.swift +7 −7
@@ -29,7 +29,7 @@ struct EmailSectionView: View {
2929 if !assessment.reasons.isEmpty {
3030 Text(assessment.reasons.joined(separator: " | "))
3131 .font(appDensity.font(.caption2))
32 .foregroundStyle(Color(.appTextSecondary))
32 .foregroundStyle(ThemeToken.textSecondary)
3333 }
3434 }
3535 if loading {
@@ -45,7 +45,7 @@ struct EmailSectionView: View {
4545 HStack(spacing: 8) {
4646 Text(row.label)
4747 .font(appDensity.font(.caption))
48 .foregroundStyle(Color(.statusInfo))
48 .foregroundStyle(ThemeToken.info)
4949 .frame(width: 76, alignment: .leading)
5050 AppStatusBadgeView(model: emailRowBadge(row))
5151 }
@@ -56,7 +56,7 @@ struct EmailSectionView: View {
5656 if let auxiliaryDetail = row.auxiliaryDetail {
5757 Text(auxiliaryDetail)
5858 .font(appDensity.font(.caption2))
59 .foregroundStyle(Color(.appTextSecondary))
59 .foregroundStyle(ThemeToken.textSecondary)
6060 }
6161 }
6262 }
@@ -68,13 +68,13 @@ struct EmailSectionView: View {
6868 private func emailRowBadge(_ row: EmailRowViewData) -> AppStatusBadgeModel {
6969 switch row.statusTone {
7070 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)
7272 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)
7474 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)
7676 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)
7878 }
7979 }
8080}
DomainDig/FeatureAccessService.swift +5 −2
@@ -33,6 +33,7 @@ enum FeatureCapability: String, CaseIterable, Identifiable {
3333 case auditDepth
3434 case intelligenceDetail
3535 case bucketExport
36 case accentTheme
3637
3738 var id: String { rawValue }
3839
@@ -64,6 +65,8 @@ enum FeatureCapability: String, CaseIterable, Identifiable {
6465 return "Intelligence detail"
6566 case .bucketExport:
6667 return "Export to your own bucket"
68 case .accentTheme:
69 return "Accent themes"
6770 }
6871 }
6972}
@@ -194,7 +197,7 @@ enum FeatureAccessService {
194197 case .workflows, .batchOperations, .automatedMonitoring, .localAlerts, .advancedExports,
195198 .extendedSubdomains:
196199 return "Available in Pro"
197 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport:
200 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport, .accentTheme:
198201 return "Available in Pro+"
199202 case .limitedTracking:
200203 return "Tracking is limited on Free"
@@ -256,7 +259,7 @@ enum FeatureAccessService {
256259 static func upgradePrompt(for capability: FeatureCapability) -> UpgradePromptContext {
257260 let title: String
258261 switch capability {
259 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport:
262 case .sharedPortfolios, .auditDepth, .intelligenceDetail, .bucketExport, .accentTheme:
260263 title = "Available in Pro+"
261264 default:
262265 title = "Available in Pro"
DomainDig/HistoryView.swift +15 −15
@@ -25,7 +25,7 @@ struct HistoryView: View {
2525 systemImage: "clock.arrow.trianglehead.counterclockwise.rotate.90",
2626 showsCardBackground: false
2727 )
28 .listRowBackground(Color(.appSurface))
28 .themedListRowBackground(.surface)
2929 } else {
3030 Section("Domains") {
3131 ForEach(domainSummaries, id: \.domain) { item in
@@ -40,12 +40,12 @@ struct HistoryView: View {
4040 Spacer()
4141 Text("\(item.count) snapshots")
4242 .font(appDensity.font(.caption2))
43 .foregroundStyle(Color(.appTextSecondary))
43 .foregroundStyle(ThemeToken.textSecondary)
4444 }
4545
4646 Text(item.latest.changeSummaryMessage ?? "No change summary")
4747 .font(appDensity.font(.caption))
48 .foregroundStyle(Color(.appTextSecondary))
48 .foregroundStyle(ThemeToken.textSecondary)
4949 .lineLimit(2)
5050
5151 HStack(spacing: 8) {
@@ -55,21 +55,21 @@ struct HistoryView: View {
5555 model: .init(
5656 title: severity.title,
5757 systemImage: "arrow.triangle.2.circlepath",
58 foregroundColor: severity == .high ? Color(.statusCritical) : Color(.statusWarning),
59 backgroundColor: (severity == .high ? AppStatusTone.critical : .warning).surface
58 foreground: severity == .high ? .critical : .warning,
59 background: (severity == .high ? AppStatusTone.critical : .warning).surface
6060 )
6161 )
6262 }
6363 }
6464 }
6565 }
66 .listRowBackground(Color(.appSurface))
66 .themedListRowBackground(.surface)
6767 }
6868 }
6969 }
7070 }
7171 .scrollContentBackground(.hidden)
72 .background(Color(.appBackground))
72 .background(ThemeToken.background)
7373 .navigationTitle("History")
7474 .searchable(text: $viewModel.timelineDomainFilter, prompt: "Search domains")
7575 .toolbar {
@@ -296,10 +296,10 @@ struct HistoryDetailView: View {
296296 )
297297 }
298298 }
299 .listRowBackground(Color(.appSurface))
299 .themedListRowBackground(.surface)
300300 .environment(\.cardProvidesSurface, false)
301301 .scrollContentBackground(.hidden)
302 .background(Color(.appBackground))
302 .background(ThemeToken.background)
303303 .navigationTitle(entry.domain)
304304 .toolbar {
305305 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -362,28 +362,28 @@ struct HistoryDetailView: View {
362362 Spacer()
363363 Text("Live re-run available")
364364 .font(appDensity.font(.caption2))
365 .foregroundStyle(Color(.appTextSecondary))
365 .foregroundStyle(ThemeToken.textSecondary)
366366 }
367367 if let mismatchNote = viewModel.resolverMismatchNote(for: entry) {
368368 Text(mismatchNote)
369369 .font(appDensity.font(.caption2))
370 .foregroundStyle(Color(.statusWarning))
370 .foregroundStyle(ThemeToken.warning)
371371 }
372372 if entry.isPartialSnapshot {
373373 Text("Partial snapshot: \(entry.validationIssues.joined(separator: " | "))")
374374 .font(appDensity.font(.caption2))
375 .foregroundStyle(Color(.statusWarning))
375 .foregroundStyle(ThemeToken.warning)
376376 }
377377 if let note = entry.note, !note.isEmpty {
378378 Text(note)
379379 .font(appDensity.font(.caption2))
380 .foregroundStyle(Color(.appTextSecondary))
380 .foregroundStyle(ThemeToken.textSecondary)
381381 }
382382 }
383 .foregroundStyle(Color(.appTextSecondary))
383 .foregroundStyle(ThemeToken.textSecondary)
384384 .padding(8)
385385 .frame(maxWidth: .infinity, alignment: .leading)
386 .background(Color(.appSurface))
386 .background(ThemeToken.surface)
387387 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
388388 .padding(.vertical, 12)
389389 }
DomainDig/IntegrationsView.swift +22 −22
@@ -15,7 +15,7 @@ struct IntegrationsSettingsView: View {
1515 if let statusMessage = integrationService.statusMessage {
1616 Text(statusMessage)
1717 .font(.caption)
18 .foregroundStyle(Color(.appTextSecondary))
18 .foregroundStyle(ThemeToken.textSecondary)
1919 }
2020
2121 Button("Process Queue Now") {
@@ -26,7 +26,7 @@ struct IntegrationsSettingsView: View {
2626 Section("Targets") {
2727 if integrationService.targets.isEmpty {
2828 Text("No integrations configured.")
29 .foregroundStyle(Color(.appTextSecondary))
29 .foregroundStyle(ThemeToken.textSecondary)
3030 } else {
3131 ForEach(integrationService.targets) { target in
3232 NavigationLink {
@@ -42,17 +42,17 @@ struct IntegrationsSettingsView: View {
4242 Text(target.name)
4343 Spacer()
4444 Text(target.type.title)
45 .foregroundStyle(Color(.appTextSecondary))
45 .foregroundStyle(ThemeToken.textSecondary)
4646 }
4747
4848 Text(summary(for: target))
4949 .font(.caption)
50 .foregroundStyle(Color(.appTextSecondary))
50 .foregroundStyle(ThemeToken.textSecondary)
5151
5252 if !target.isEnabled {
5353 Text("Disabled")
5454 .font(.caption2)
55 .foregroundStyle(Color(.statusWarning))
55 .foregroundStyle(ThemeToken.warning)
5656 }
5757 }
5858 }
@@ -140,7 +140,7 @@ private struct IntegrationDetailView: View {
140140 Section("Delivery Log") {
141141 if integrationService.deliveryRecords(for: target.id).isEmpty {
142142 Text("No deliveries yet.")
143 .foregroundStyle(Color(.appTextSecondary))
143 .foregroundStyle(ThemeToken.textSecondary)
144144 } else {
145145 ForEach(integrationService.deliveryRecords(for: target.id), id: \.id) { record in
146146 VStack(alignment: .leading, spacing: 4) {
@@ -149,7 +149,7 @@ private struct IntegrationDetailView: View {
149149 Spacer()
150150 Text(record.timestamp.formatted(date: .abbreviated, time: .shortened))
151151 .font(.caption)
152 .foregroundStyle(Color(.appTextSecondary))
152 .foregroundStyle(ThemeToken.textSecondary)
153153 }
154154
155155 Text(record.summary)
@@ -157,13 +157,13 @@ private struct IntegrationDetailView: View {
157157
158158 Text(record.destination)
159159 .font(.caption)
160 .foregroundStyle(Color(.appTextSecondary))
160 .foregroundStyle(ThemeToken.textSecondary)
161161
162162 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)
164164 Text(failureReason)
165165 .font(.caption)
166 .foregroundStyle(failureColor)
166 .foregroundStyle(failureStyle)
167167 }
168168 }
169169 }
@@ -171,7 +171,7 @@ private struct IntegrationDetailView: View {
171171 }
172172 } else {
173173 Text("Integration not found.")
174 .foregroundStyle(Color(.appTextSecondary))
174 .foregroundStyle(ThemeToken.textSecondary)
175175 }
176176 }
177177 .navigationTitle(target?.name ?? "Integration")
@@ -238,7 +238,7 @@ private struct IntegrationEditorView: View {
238238 if !FeatureAccessService.hasAccess(to: .bucketExport) {
239239 Text("Export to your own bucket is \(FeatureAccessService.upgradeMessage(for: .bucketExport)).")
240240 .font(.caption)
241 .foregroundStyle(Color(.appTextSecondary))
241 .foregroundStyle(ThemeToken.textSecondary)
242242 }
243243
244244 TextField("Name", text: $name)
@@ -284,7 +284,7 @@ private struct IntegrationEditorView: View {
284284 if existingTarget != nil {
285285 Text("Saved webhook URL remains in Keychain unless you replace it.")
286286 .font(.caption)
287 .foregroundStyle(Color(.appTextSecondary))
287 .foregroundStyle(ThemeToken.textSecondary)
288288 }
289289 }
290290 case .slack:
@@ -297,7 +297,7 @@ private struct IntegrationEditorView: View {
297297 if existingTarget != nil {
298298 Text("Saved Slack webhook remains in Keychain unless you replace it.")
299299 .font(.caption)
300 .foregroundStyle(Color(.appTextSecondary))
300 .foregroundStyle(ThemeToken.textSecondary)
301301 }
302302 }
303303 case .email:
@@ -311,7 +311,7 @@ private struct IntegrationEditorView: View {
311311
312312 Text("Port 465 with Direct TLS is supported. Port 587 (STARTTLS) is not.")
313313 .font(.caption)
314 .foregroundStyle(Color(.appTextSecondary))
314 .foregroundStyle(ThemeToken.textSecondary)
315315
316316 TextField("Username", text: $emailUsername)
317317 .textInputAutocapitalization(.never)
@@ -338,7 +338,7 @@ private struct IntegrationEditorView: View {
338338 if existingTarget != nil {
339339 Text("Saved SMTP password remains in Keychain unless you replace it.")
340340 .font(.caption)
341 .foregroundStyle(Color(.appTextSecondary))
341 .foregroundStyle(ThemeToken.textSecondary)
342342 }
343343 }
344344 case .s3:
@@ -350,7 +350,7 @@ private struct IntegrationEditorView: View {
350350
351351 Text("Must be https. Signing puts your access key ID on the wire, and the signature with it.")
352352 .font(.caption)
353 .foregroundStyle(Color(.appTextSecondary))
353 .foregroundStyle(ThemeToken.textSecondary)
354354
355355 TextField("Bucket", text: $s3Bucket)
356356 .textInputAutocapitalization(.never)
@@ -368,7 +368,7 @@ private struct IntegrationEditorView: View {
368368
369369 Text("Addresses the bucket as endpoint/bucket/key. MinIO needs this, and so do R2 custom domains.")
370370 .font(.caption)
371 .foregroundStyle(Color(.appTextSecondary))
371 .foregroundStyle(ThemeToken.textSecondary)
372372 }
373373
374374 Section("Credentials") {
@@ -384,7 +384,7 @@ private struct IntegrationEditorView: View {
384384 if existingTarget != nil {
385385 Text("Saved secret access key remains in Keychain unless you replace it.")
386386 .font(.caption)
387 .foregroundStyle(Color(.appTextSecondary))
387 .foregroundStyle(ThemeToken.textSecondary)
388388 }
389389 }
390390
@@ -407,7 +407,7 @@ private struct IntegrationEditorView: View {
407407 if let detail = trigger.detail {
408408 Text(detail)
409409 .font(.caption)
410 .foregroundStyle(Color(.appTextSecondary))
410 .foregroundStyle(ThemeToken.textSecondary)
411411 }
412412 }
413413 }
@@ -417,7 +417,7 @@ private struct IntegrationEditorView: View {
417417 Section("Formats") {
418418 Text("JSON always uploads. The others are renderings of it.")
419419 .font(.caption)
420 .foregroundStyle(Color(.appTextSecondary))
420 .foregroundStyle(ThemeToken.textSecondary)
421421
422422 ForEach([DomainExportFormat.pdf, .csv]) { format in
423423 Toggle(
@@ -441,7 +441,7 @@ private struct IntegrationEditorView: View {
441441 Section {
442442 Text(validationMessage)
443443 .font(.caption)
444 .foregroundStyle(Color(.statusCritical))
444 .foregroundStyle(ThemeToken.critical)
445445 }
446446 }
447447 }
DomainDig/IntelligenceSectionView.swift +5 −5
@@ -44,7 +44,7 @@ struct IntelligenceSectionView: View {
4444 .font(appDensity.font(.caption, weight: .semibold))
4545 Text(signal.detail)
4646 .font(appDensity.font(.caption2))
47 .foregroundStyle(Color(.appTextSecondary))
47 .foregroundStyle(ThemeToken.textSecondary)
4848 }
4949 }
5050 }
@@ -80,12 +80,12 @@ struct IntelligenceSectionView: View {
8080 if item.isEphemeral {
8181 Text("Ephemeral")
8282 .font(appDensity.font(.caption2))
83 .foregroundStyle(Color(.statusWarning))
83 .foregroundStyle(ThemeToken.warning)
8484 }
8585 }
8686 Text("First \(item.firstSeen.formatted(date: .abbreviated, time: .omitted)) • Last \(item.lastSeen.formatted(date: .abbreviated, time: .omitted)) • Seen \(item.recurrenceCount)x")
8787 .font(appDensity.font(.caption2))
88 .foregroundStyle(Color(.appTextSecondary))
88 .foregroundStyle(ThemeToken.textSecondary)
8989 }
9090 }
9191 }
@@ -109,7 +109,7 @@ struct IntelligenceSectionView: View {
109109 VStack(alignment: .leading, spacing: 8) {
110110 Text(title)
111111 .font(appDensity.font(.subheadline, weight: .semibold))
112 .foregroundStyle(Color(.statusInfo))
112 .foregroundStyle(ThemeToken.info)
113113 content()
114114 }
115115 }
@@ -118,7 +118,7 @@ struct IntelligenceSectionView: View {
118118 VStack(alignment: .leading, spacing: 3) {
119119 Text(date.formatted(date: .abbreviated, time: .omitted))
120120 .font(appDensity.font(.caption2))
121 .foregroundStyle(Color(.appTextSecondary))
121 .foregroundStyle(ThemeToken.textSecondary)
122122 Text(title)
123123 .font(appDensity.font(.caption))
124124 }
DomainDig/LookupSummaryViews.swift +21 −21
@@ -15,7 +15,7 @@ struct SummaryView: View {
1515 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing) {
1616 Text(field.label)
1717 .font(appDensity.font(.caption2))
18 .foregroundStyle(Color(.appTextSecondary))
18 .foregroundStyle(ThemeToken.textSecondary)
1919 Text(field.value)
2020 .font(appDensity.font(.caption))
2121 .foregroundStyle(ResultColors.color(for: field.tone))
@@ -25,7 +25,7 @@ struct SummaryView: View {
2525 .frame(minHeight: appDensity.metrics.rowMinHeight + 12, alignment: .topLeading)
2626 .frame(maxWidth: .infinity, alignment: .leading)
2727 .padding(appDensity.metrics.cardPadding)
28 .background(Color(.appSurface))
28 .background(ThemeToken.surface)
2929 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
3030 }
3131 }
@@ -57,13 +57,13 @@ struct RiskSummaryCardView: View {
5757 Spacer()
5858 Text("Deterministic")
5959 .font(appDensity.font(.caption2))
60 .foregroundStyle(Color(.appTextSecondary))
60 .foregroundStyle(ThemeToken.textSecondary)
6161 }
6262
6363 if topFactors.isEmpty {
6464 Text("No major risk factors identified")
6565 .font(appDensity.font(.caption))
66 .foregroundStyle(Color(.appTextSecondary))
66 .foregroundStyle(ThemeToken.textSecondary)
6767 } else {
6868 ForEach(Array(topFactors.enumerated()), id: \.offset) { _, factor in
6969 HStack(alignment: .top, spacing: 8) {
@@ -81,25 +81,25 @@ struct RiskSummaryCardView: View {
8181 }
8282 }
8383
84 private var levelColor: Color {
84 private var levelColor: AnyShapeStyle {
8585 switch report.riskAssessment.level {
8686 case .low:
87 return Color(.statusPositive)
87 return AnyShapeStyle(ThemeToken.positive)
8888 case .medium:
89 return Color(.statusWarning)
89 return AnyShapeStyle(ThemeToken.warning)
9090 case .high:
91 return Color(.statusCritical)
91 return AnyShapeStyle(ThemeToken.critical)
9292 }
9393 }
9494
95 private func factorColor(_ impact: RiskImpact) -> Color {
95 private func factorColor(_ impact: RiskImpact) -> AnyShapeStyle {
9696 switch impact {
9797 case .positive:
98 return Color(.statusPositive)
98 return AnyShapeStyle(ThemeToken.positive)
9999 case .neutral:
100 return .secondary
100 return AnyShapeStyle(.secondary)
101101 case .negative:
102 return Color(.statusCritical)
102 return AnyShapeStyle(ThemeToken.critical)
103103 }
104104 }
105105}
@@ -115,13 +115,13 @@ struct InsightsSummaryCardView: View {
115115 if insights.isEmpty {
116116 Text("No deterministic insights triggered")
117117 .font(appDensity.font(.caption))
118 .foregroundStyle(Color(.appTextSecondary))
118 .foregroundStyle(ThemeToken.textSecondary)
119119 } else {
120120 ForEach(Array(insights.enumerated()), id: \.offset) { _, insight in
121121 HStack(alignment: .top, spacing: 8) {
122122 Image(systemName: "chart.line.uptrend.xyaxis")
123123 .font(appDensity.font(.caption2))
124 .foregroundStyle(Color(.statusInfo))
124 .foregroundStyle(ThemeToken.info)
125125 .padding(.top, 2)
126126 Text(insight)
127127 .font(appDensity.font(.caption))
@@ -171,7 +171,7 @@ struct StickyLookupSummaryView: View {
171171 HStack(spacing: 8) {
172172 Label(primaryIP, systemImage: "network")
173173 .font(appDensity.font(.caption))
174 .foregroundStyle(Color(.appTextSecondary))
174 .foregroundStyle(ThemeToken.textSecondary)
175175 Spacer(minLength: 6)
176176 AppCopyButton(value: primaryIP, label: "Copy IP")
177177 }
@@ -197,7 +197,7 @@ struct LookupProgressOverviewView: View {
197197 .foregroundStyle(.primary)
198198 Text(steps.isEmpty ? "Preparing requests" : steps.joined(separator: " • "))
199199 .font(appDensity.font(.caption2))
200 .foregroundStyle(Color(.appTextSecondary))
200 .foregroundStyle(ThemeToken.textSecondary)
201201 }
202202 Spacer()
203203 }
@@ -225,16 +225,16 @@ struct LookupStatusBannerView: View {
225225 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
226226 }
227227
228 private var color: Color {
228 private var color: AnyShapeStyle {
229229 switch resultSource {
230230 case .live:
231 return Color(.statusPositive)
231 return AnyShapeStyle(ThemeToken.positive)
232232 case .cached:
233 return .secondary
233 return AnyShapeStyle(.secondary)
234234 case .mixed:
235 return Color(.statusWarning)
235 return AnyShapeStyle(ThemeToken.warning)
236236 case .snapshot:
237 return Color(.statusWarning)
237 return AnyShapeStyle(ThemeToken.warning)
238238 }
239239 }
240240
DomainDig/MonitoringView.swift +19 −19
@@ -31,7 +31,7 @@ struct MonitoringView: View {
3131 !monitoringStatusMessage.isEmpty {
3232 Text(monitoringStatusMessage)
3333 .font(appDensity.font(.caption))
34 .foregroundStyle(Color(.appTextSecondary))
34 .foregroundStyle(ThemeToken.textSecondary)
3535 }
3636
3737 Button(viewModel.monitoringRunInProgress ? "Monitoring…" : "Run Now") {
@@ -41,7 +41,7 @@ struct MonitoringView: View {
4141 }
4242 .padding(.vertical, 4)
4343 }
44 .listRowBackground(Color(.appSurface))
44 .themedListRowBackground(.surface)
4545
4646 if viewModel.monitoringLogs.isEmpty {
4747 Section {
@@ -53,7 +53,7 @@ struct MonitoringView: View {
5353 showsCardBackground: false
5454 )
5555 }
56 .listRowBackground(Color(.appSurface))
56 .themedListRowBackground(.surface)
5757 } else {
5858 Section("Recent Runs") {
5959 ForEach(viewModel.monitoringLogs) { log in
@@ -68,12 +68,12 @@ struct MonitoringView: View {
6868 Spacer()
6969 Text(log.timestamp.formatted(date: .abbreviated, time: .shortened))
7070 .font(appDensity.font(.caption2))
71 .foregroundStyle(Color(.appTextSecondary))
71 .foregroundStyle(ThemeToken.textSecondary)
7272 }
7373
7474 Text(log.summary)
7575 .font(appDensity.font(.caption))
76 .foregroundStyle(Color(.appTextSecondary))
76 .foregroundStyle(ThemeToken.textSecondary)
7777
7878 HStack(spacing: 8) {
7979 metricBadge(title: "\(log.domainsChecked) checked")
@@ -89,11 +89,11 @@ struct MonitoringView: View {
8989 }
9090 }
9191 }
92 .listRowBackground(Color(.appSurface))
92 .themedListRowBackground(.surface)
9393 }
9494 }
9595 .scrollContentBackground(.hidden)
96 .background(Color(.appBackground))
96 .background(ThemeToken.background)
9797 .navigationTitle("Monitoring")
9898 .onAppear {
9999 viewModel.refreshMonitoringState()
@@ -132,7 +132,7 @@ struct MonitoringLogDetailView: View {
132132 LabeledContent("Alerts", value: "\(log.alertsTriggered)")
133133 LabeledContent("Timestamp", value: log.timestamp.formatted(date: .abbreviated, time: .shortened))
134134 }
135 .listRowBackground(Color(.appSurface))
135 .themedListRowBackground(.surface)
136136
137137 Section("Domains") {
138138 ForEach(log.checkedDomains) { result in
@@ -151,7 +151,7 @@ struct MonitoringLogDetailView: View {
151151
152152 Text(result.summaryMessage)
153153 .font(appDensity.font(.caption))
154 .foregroundStyle(Color(.appTextSecondary))
154 .foregroundStyle(ThemeToken.textSecondary)
155155
156156 HStack(spacing: 10) {
157157 Text(result.resultSource.label)
@@ -161,12 +161,12 @@ struct MonitoringLogDetailView: View {
161161 }
162162 }
163163 .font(appDensity.font(.caption2))
164 .foregroundStyle(Color(.appTextSecondary))
164 .foregroundStyle(ThemeToken.textSecondary)
165165
166166 if let errorMessage = result.errorMessage {
167167 Text(errorMessage)
168168 .font(appDensity.font(.caption2))
169 .foregroundStyle(Color(.statusWarning))
169 .foregroundStyle(ThemeToken.warning)
170170 }
171171
172172 if let historyEntryID = result.historyEntryID,
@@ -180,32 +180,32 @@ struct MonitoringLogDetailView: View {
180180 .padding(.vertical, 4)
181181 }
182182 }
183 .listRowBackground(Color(.appSurface))
183 .themedListRowBackground(.surface)
184184
185185 if !log.errors.isEmpty {
186186 Section("Errors") {
187187 ForEach(log.errors, id: \.self) { error in
188188 Text(error)
189189 .font(appDensity.font(.caption))
190 .foregroundStyle(Color(.appTextSecondary))
190 .foregroundStyle(ThemeToken.textSecondary)
191191 }
192192 }
193 .listRowBackground(Color(.appSurface))
193 .themedListRowBackground(.surface)
194194 }
195195 }
196196 .scrollContentBackground(.hidden)
197 .background(Color(.appBackground))
197 .background(ThemeToken.background)
198198 .navigationTitle("Run Details")
199199 }
200200
201 private func color(for severity: MonitoringAlertSeverity) -> Color {
201 private func color(for severity: MonitoringAlertSeverity) -> AnyShapeStyle {
202202 switch severity {
203203 case .info:
204 return .secondary
204 return AnyShapeStyle(.secondary)
205205 case .warning:
206 return Color(.statusWarning)
206 return AnyShapeStyle(ThemeToken.warning)
207207 case .critical:
208 return Color(.statusCritical)
208 return AnyShapeStyle(ThemeToken.critical)
209209 }
210210 }
211211}
DomainDig/NetworkSectionView.swift +18 −18
@@ -68,7 +68,7 @@ struct NetworkSectionView: View {
6868 CardView {
6969 Text("Reachability")
7070 .font(appDensity.font(.subheadline, weight: .semibold))
71 .foregroundStyle(Color(.statusInfo))
71 .foregroundStyle(ThemeToken.info)
7272 SectionTrustMetadataView(provenance: reachabilityProvenance, confidence: nil)
7373 if reachabilityLoading {
7474 ProgressView("Checking ports…")
@@ -83,7 +83,7 @@ struct NetworkSectionView: View {
8383 Spacer()
8484 Text(row.latencyLabel)
8585 .font(appDensity.font(.caption2))
86 .foregroundStyle(Color(.appTextSecondary))
86 .foregroundStyle(ThemeToken.textSecondary)
8787 AppStatusBadgeView(model: reachabilityBadge(row))
8888 }
8989 }
@@ -93,7 +93,7 @@ struct NetworkSectionView: View {
9393 CardView(allowsHorizontalScroll: false) {
9494 Text("Location")
9595 .font(appDensity.font(.subheadline, weight: .semibold))
96 .foregroundStyle(Color(.statusInfo))
96 .foregroundStyle(ThemeToken.info)
9797 SectionTrustMetadataView(provenance: geolocationProvenance, confidence: geolocationConfidence)
9898 if geolocationLoading {
9999 ProgressView("Looking up location…")
@@ -125,13 +125,13 @@ struct NetworkSectionView: View {
125125 CardView(allowsHorizontalScroll: false) {
126126 Text("Port Scan")
127127 .font(appDensity.font(.subheadline, weight: .semibold))
128 .foregroundStyle(Color(.statusInfo))
128 .foregroundStyle(ThemeToken.info)
129129 SectionTrustMetadataView(provenance: portScanProvenance, confidence: nil)
130130
131131 if isCloudflareProxied {
132132 Text("Domain is behind Cloudflare's proxy. Results reflect the edge, not the origin.")
133133 .font(appDensity.font(.caption2))
134 .foregroundStyle(Color(.statusWarning))
134 .foregroundStyle(ThemeToken.warning)
135135 .fixedSize(horizontal: false, vertical: true)
136136 }
137137
@@ -143,7 +143,7 @@ struct NetworkSectionView: View {
143143 } else {
144144 Text("Standard Ports")
145145 .font(.system(.caption, design: .monospaced))
146 .foregroundStyle(Color(.appTextSecondary))
146 .foregroundStyle(ThemeToken.textSecondary)
147147 PortRowsView(rows: standardPortRows)
148148 }
149149
@@ -155,7 +155,7 @@ struct NetworkSectionView: View {
155155 .autocorrectionDisabled()
156156 .keyboardType(.numberPad)
157157 .padding(10)
158 .background(Color(.appSurface))
158 .background(ThemeToken.surface)
159159 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
160160
161161 Button("Scan") {
@@ -163,7 +163,7 @@ struct NetworkSectionView: View {
163163 onScanCustomPorts()
164164 }
165165 .buttonStyle(.borderedProminent)
166 .tint(Color(.accentFill))
166 .tint(ThemeToken.accent)
167167 .disabled(customPortScanLoading)
168168
169169 if customPortScanLoading {
@@ -186,13 +186,13 @@ struct NetworkSectionView: View {
186186 private func reachabilityBadge(_ row: ReachabilityRowViewData) -> AppStatusBadgeModel {
187187 switch row.statusTone {
188188 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)
190190 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)
192192 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)
194194 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)
196196 }
197197 }
198198}
@@ -218,14 +218,14 @@ struct PortRowsView: View {
218218 if let durationLabel = row.durationLabel {
219219 Text(durationLabel)
220220 .font(appDensity.font(.caption2))
221 .foregroundStyle(Color(.appTextSecondary))
221 .foregroundStyle(ThemeToken.textSecondary)
222222 }
223223 AppStatusBadgeView(model: portBadge(row))
224224 }
225225 if let banner = row.banner {
226226 Text(banner)
227227 .font(appDensity.font(.caption2))
228 .foregroundStyle(Color(.appTextSecondary))
228 .foregroundStyle(ThemeToken.textSecondary)
229229 .padding(.leading, 8)
230230 }
231231 }
@@ -237,13 +237,13 @@ struct PortRowsView: View {
237237 private func portBadge(_ row: PortScanRowViewData) -> AppStatusBadgeModel {
238238 switch row.statusTone {
239239 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)
241241 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)
243243 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)
245245 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)
247247 }
248248 }
249249}
DomainDig/OwnershipSectionView.swift +3 −3
@@ -69,7 +69,7 @@ struct OwnershipSectionView: View {
6969 HStack {
7070 Text("History")
7171 .font(appDensity.font(.caption))
72 .foregroundStyle(Color(.appTextSecondary))
72 .foregroundStyle(ThemeToken.textSecondary)
7373 Spacer()
7474 if let onLoadHistory, history.isEmpty, !historyLoading {
7575 Button("Load") {
@@ -87,12 +87,12 @@ struct OwnershipSectionView: View {
8787 VStack(alignment: .leading, spacing: 3) {
8888 Text(event.date.formatted(date: .abbreviated, time: .omitted))
8989 .font(appDensity.font(.caption2))
90 .foregroundStyle(Color(.appTextSecondary))
90 .foregroundStyle(ThemeToken.textSecondary)
9191 Text(event.summary)
9292 .font(appDensity.font(.caption))
9393 Text(event.source)
9494 .font(appDensity.font(.caption2))
95 .foregroundStyle(Color(.appTextSecondary))
95 .foregroundStyle(ThemeToken.textSecondary)
9696 }
9797 }
9898 } else if let historyError {
DomainDig/PaywallView.swift +5 −5
@@ -12,7 +12,7 @@ struct PaywallView: View {
1212 Section {
1313 Text("Pro unlocks scale, background monitoring, alerts, exports, and extended subdomain discovery. Pro+ adds shared portfolios, unlimited audits, and the full intelligence breakdown.")
1414 .font(appDensity.font(.body, design: .default))
15 .foregroundStyle(Color(.appTextSecondary))
15 .foregroundStyle(ThemeToken.textSecondary)
1616 .fixedSize(horizontal: false, vertical: true)
1717 }
1818
@@ -38,7 +38,7 @@ struct PaywallView: View {
3838 } else if purchaseService.products.isEmpty {
3939 Text("Pricing is unavailable right now.")
4040 .font(appDensity.font(.caption, design: .default))
41 .foregroundStyle(Color(.appTextSecondary))
41 .foregroundStyle(ThemeToken.textSecondary)
4242
4343 Button("Retry") {
4444 Task {
@@ -58,7 +58,7 @@ struct PaywallView: View {
5858 .foregroundStyle(.primary)
5959 Text(product.displayPrice)
6060 .font(appDensity.font(.callout, design: .default))
61 .foregroundStyle(Color(.appTextSecondary))
61 .foregroundStyle(ThemeToken.textSecondary)
6262 }
6363 .frame(maxWidth: .infinity, alignment: .leading)
6464 }
@@ -69,13 +69,13 @@ struct PaywallView: View {
6969 if let statusMessage = purchaseService.statusMessage {
7070 Text(statusMessage)
7171 .font(appDensity.font(.caption, design: .default))
72 .foregroundStyle(Color(.appTextSecondary))
72 .foregroundStyle(ThemeToken.textSecondary)
7373 }
7474
7575 if let errorMessage = purchaseService.errorMessage {
7676 Text(errorMessage)
7777 .font(appDensity.font(.caption, design: .default))
78 .foregroundStyle(Color(.statusCritical))
78 .foregroundStyle(ThemeToken.critical)
7979 }
8080 }
8181
DomainDig/ResultPrimitives.swift +14 −14
@@ -19,7 +19,7 @@ struct TrackedDomainDetailHeaderView: View {
1919 Text("Last refresh \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))")
2020 }
2121 .font(.system(.caption2, design: .monospaced))
22 .foregroundStyle(Color(.appTextSecondary))
22 .foregroundStyle(ThemeToken.textSecondary)
2323 }
2424 }
2525}
@@ -93,7 +93,7 @@ struct CardView<Content: View>: View {
9393 }
9494 .frame(maxWidth: .infinity, alignment: .leading)
9595 .padding(providesSurface ? appDensity.metrics.cardPadding : 0)
96 .background(providesSurface ? Color(.appSurface) : Color.clear)
96 .background(providesSurface ? AnyShapeStyle(ThemeToken.surface) : AnyShapeStyle(.clear))
9797 .clipShape(
9898 RoundedRectangle(cornerRadius: providesSurface ? appDensity.metrics.cardCornerRadius : 0)
9999 )
@@ -139,7 +139,7 @@ struct MessageRowView: View {
139139 var body: some View {
140140 Label(text, systemImage: isError ? "exclamationmark.triangle.fill" : "info.circle")
141141 .font(appDensity.font(.caption))
142 .foregroundStyle(isError ? Color(.statusCritical) : .secondary)
142 .foregroundStyle(isError ? AnyShapeStyle(ThemeToken.critical) : AnyShapeStyle(.secondary))
143143 .lineLimit(nil)
144144 .fixedSize(horizontal: false, vertical: true)
145145 }
@@ -164,15 +164,15 @@ struct SectionTrustMetadataView: View {
164164 if let confidence {
165165 Text("Confidence \(confidence.title)")
166166 .font(appDensity.font(.caption2))
167 .foregroundStyle(Color(.appTextSecondary))
167 .foregroundStyle(ThemeToken.textSecondary)
168168 }
169169 if let provenance {
170170 Text(provenance.provider ?? provenance.source)
171171 .font(appDensity.font(.caption2))
172 .foregroundStyle(Color(.appTextSecondary))
172 .foregroundStyle(ThemeToken.textSecondary)
173173 Text(provenance.resultSource.label)
174174 .font(appDensity.font(.caption2))
175 .foregroundStyle(Color(.appTextSecondary))
175 .foregroundStyle(ThemeToken.textSecondary)
176176 }
177177 }
178178 DisclosureGroup("Details") {
@@ -212,7 +212,7 @@ struct LabeledValueRow: View {
212212 VStack(alignment: .leading, spacing: appDensity.metrics.rowSpacing - 1) {
213213 Text(row.label)
214214 .font(appDensity.font(.caption2))
215 .foregroundStyle(Color(.appTextSecondary))
215 .foregroundStyle(ThemeToken.textSecondary)
216216 HStack(alignment: .firstTextBaseline, spacing: 4) {
217217 if differentiateWithoutColor, let symbol = toneSymbol {
218218 Image(systemName: symbol)
@@ -274,21 +274,21 @@ struct LabeledValueRow: View {
274274/// Maps a row's semantic tone onto the app palette.
275275///
276276/// 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
278278/// palette fails WCAG AA badly in light mode (systemYellow is 1.28:1 on white).
279279enum ResultColors {
280 static func color(for tone: ResultTone) -> Color {
280 static func color(for tone: ResultTone) -> AnyShapeStyle {
281281 switch tone {
282282 case .primary:
283 return .primary
283 return AnyShapeStyle(.primary)
284284 case .secondary:
285 return .secondary
285 return AnyShapeStyle(.secondary)
286286 case .success:
287 return Color(.statusPositive)
287 return AnyShapeStyle(ThemeToken.positive)
288288 case .warning:
289 return Color(.statusWarning)
289 return AnyShapeStyle(ThemeToken.warning)
290290 case .failure:
291 return Color(.statusCritical)
291 return AnyShapeStyle(ThemeToken.critical)
292292 }
293293 }
294294}
DomainDig/ScheduledReportsView.swift +7 −7
@@ -13,7 +13,7 @@ struct ScheduledReportsView: View {
1313 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) {
1414 Text("Scheduled reports require Pro.")
1515 .font(appDensity.font(.caption))
16 .foregroundStyle(Color(.appTextSecondary))
16 .foregroundStyle(ThemeToken.textSecondary)
1717 }
1818
1919 Toggle("Scheduled Reports", isOn: Binding(
@@ -59,7 +59,7 @@ struct ScheduledReportsView: View {
5959 if let statusMessage {
6060 Text(statusMessage)
6161 .font(appDensity.font(.caption))
62 .foregroundStyle(Color(.appTextSecondary))
62 .foregroundStyle(ThemeToken.textSecondary)
6363 }
6464
6565 Button(isGenerating ? "Generating…" : "Generate Now") {
@@ -67,7 +67,7 @@ struct ScheduledReportsView: View {
6767 }
6868 .disabled(isGenerating || !FeatureAccessService.hasAccess(to: .automatedMonitoring))
6969 }
70 .listRowBackground(Color(.appSurface))
70 .themedListRowBackground(.surface)
7171
7272 if logs.isEmpty {
7373 Section {
@@ -79,7 +79,7 @@ struct ScheduledReportsView: View {
7979 showsCardBackground: false
8080 )
8181 }
82 .listRowBackground(Color(.appSurface))
82 .themedListRowBackground(.surface)
8383 } else {
8484 Section("Recent Reports") {
8585 ForEach(logs) { log in
@@ -91,16 +91,16 @@ struct ScheduledReportsView: View {
9191 .foregroundStyle(.primary)
9292 Text(log.generatedAt.formatted(date: .abbreviated, time: .shortened))
9393 .font(.caption)
94 .foregroundStyle(Color(.appTextSecondary))
94 .foregroundStyle(ThemeToken.textSecondary)
9595 }
9696 }
9797 }
9898 }
99 .listRowBackground(Color(.appSurface))
99 .themedListRowBackground(.surface)
100100 }
101101 }
102102 .scrollContentBackground(.hidden)
103 .background(Color(.appBackground))
103 .background(ThemeToken.background)
104104 .navigationTitle("Scheduled Reports")
105105 }
106106
DomainDig/SettingsViews.swift +41 −24
@@ -38,13 +38,13 @@ struct SettingsView: View {
3838 if let statusMessage = purchaseService.statusMessage {
3939 Text(statusMessage)
4040 .font(appDensity.font(.caption, design: .default))
41 .foregroundStyle(Color(.appTextSecondary))
41 .foregroundStyle(ThemeToken.textSecondary)
4242 }
4343
4444 if let errorMessage = purchaseService.errorMessage {
4545 Text(errorMessage)
4646 .font(appDensity.font(.caption, design: .default))
47 .foregroundStyle(Color(.statusCritical))
47 .foregroundStyle(ThemeToken.critical)
4848 }
4949 }
5050
@@ -105,8 +105,10 @@ struct SettingsView: View {
105105}
106106
107107private struct DisplaySettingsView: View {
108 @Environment(\.appDensity) private var appDensity
108109 @AppStorage(AppDensity.userDefaultsKey) private var storedDensity = AppDensity.compact.rawValue
109110 @AppStorage(AppAppearance.userDefaultsKey) private var storedAppearance = AppAppearance.system.rawValue
111 @AppStorage(AccentTheme.userDefaultsKey) private var storedAccent = AccentTheme.default.rawValue
110112
111113 var body: some View {
112114 Form {
@@ -117,6 +119,21 @@ private struct DisplaySettingsView: View {
117119 }
118120 }
119121
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
120137 Picker("Density", selection: $storedDensity) {
121138 ForEach(AppDensity.allCases) { density in
122139 Text(density.title).tag(density.rawValue)
@@ -172,7 +189,7 @@ private struct HistoryNetworkSettingsView: View {
172189
173190 Text(viewModel.historyRetentionCaption)
174191 .font(appDensity.font(.caption, design: .default))
175 .foregroundStyle(Color(.appTextSecondary))
192 .foregroundStyle(ThemeToken.textSecondary)
176193 }
177194
178195 Section("Network") {
@@ -191,7 +208,7 @@ private struct HistoryNetworkSettingsView: View {
191208 if let customResolverError {
192209 Text(customResolverError)
193210 .font(appDensity.font(.caption, design: .default))
194 .foregroundStyle(Color(.statusCritical))
211 .foregroundStyle(ThemeToken.critical)
195212 }
196213 }
197214
@@ -203,13 +220,13 @@ private struct HistoryNetworkSettingsView: View {
203220
204221 Text(selectedProfile.detail)
205222 .font(appDensity.font(.caption, design: .default))
206 .foregroundStyle(Color(.appTextSecondary))
223 .foregroundStyle(ThemeToken.textSecondary)
207224
208225 Toggle("Allow third-party enrichment", isOn: $allowsThirdPartyEnrichment)
209226
210227 Text(Self.enrichmentCaption)
211228 .font(appDensity.font(.caption, design: .default))
212 .foregroundStyle(Color(.appTextSecondary))
229 .foregroundStyle(ThemeToken.textSecondary)
213230 }
214231 }
215232 .navigationTitle("History & Network")
@@ -280,16 +297,16 @@ private struct CloudSyncSettingsView: View {
280297
281298 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.")
282299 .font(appDensity.font(.caption, design: .default))
283 .foregroundStyle(Color(.appTextSecondary))
300 .foregroundStyle(ThemeToken.textSecondary)
284301
285302 Text(cloudSyncService.detailMessage)
286303 .font(appDensity.font(.caption, design: .default))
287 .foregroundStyle(Color(.appTextSecondary))
304 .foregroundStyle(ThemeToken.textSecondary)
288305
289306 if let lastErrorMessage = cloudSyncService.lastErrorMessage {
290307 Text(lastErrorMessage)
291308 .font(appDensity.font(.caption, design: .default))
292 .foregroundStyle(Color(.statusCritical))
309 .foregroundStyle(ThemeToken.critical)
293310 }
294311 }
295312 }
@@ -342,7 +359,7 @@ private struct LocalAPISettingsView: View {
342359 if let statusMessage = localAPIService.statusMessage {
343360 Text(statusMessage)
344361 .font(appDensity.font(.caption, design: .default))
345 .foregroundStyle(Color(.appTextSecondary))
362 .foregroundStyle(ThemeToken.textSecondary)
346363 }
347364 }
348365
@@ -361,7 +378,7 @@ private struct LocalAPISettingsView: View {
361378
362379 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.")
363380 .font(appDensity.font(.caption, design: .default))
364 .foregroundStyle(Color(.appTextSecondary))
381 .foregroundStyle(ThemeToken.textSecondary)
365382 }
366383
367384 Section("Request Logging") {
@@ -376,7 +393,7 @@ private struct LocalAPISettingsView: View {
376393 if localAPIService.requestLogs.isEmpty {
377394 Text("No local API requests logged yet.")
378395 .font(appDensity.font(.caption, design: .default))
379 .foregroundStyle(Color(.appTextSecondary))
396 .foregroundStyle(ThemeToken.textSecondary)
380397 } else {
381398 ForEach(localAPIService.requestLogs.prefix(25)) { log in
382399 VStack(alignment: .leading, spacing: 4) {
@@ -386,16 +403,16 @@ private struct LocalAPISettingsView: View {
386403 Spacer()
387404 Text("\(log.statusCode)")
388405 .font(appDensity.font(.caption, design: .default))
389 .foregroundStyle(log.statusCode >= 400 ? Color(.statusCritical) : .secondary)
406 .foregroundStyle(log.statusCode >= 400 ? AnyShapeStyle(ThemeToken.critical) : AnyShapeStyle(.secondary))
390407 }
391408
392409 Text(log.timestamp.formatted(date: .abbreviated, time: .standard))
393410 .font(appDensity.font(.caption2, design: .default))
394 .foregroundStyle(Color(.appTextSecondary))
411 .foregroundStyle(ThemeToken.textSecondary)
395412
396413 Text("\(Int(log.duration * 1000)) ms")
397414 .font(appDensity.font(.caption2, design: .default))
398 .foregroundStyle(Color(.appTextSecondary))
415 .foregroundStyle(ThemeToken.textSecondary)
399416 }
400417 }
401418 }
@@ -571,13 +588,13 @@ private struct MonitoringSettingsView: View {
571588 if let monitoringStatusMessage = viewModel.monitoringStatusMessage {
572589 Text(monitoringStatusMessage)
573590 .font(appDensity.font(.caption, design: .default))
574 .foregroundStyle(Color(.appTextSecondary))
591 .foregroundStyle(ThemeToken.textSecondary)
575592 }
576593
577594 if !FeatureAccessService.hasAccess(to: .automatedMonitoring) {
578595 Text("Background monitoring and alerts are available in Pro.")
579596 .font(appDensity.font(.caption, design: .default))
580 .foregroundStyle(Color(.appTextSecondary))
597 .foregroundStyle(ThemeToken.textSecondary)
581598 }
582599 }
583600 }
@@ -655,7 +672,7 @@ private struct DataPortabilitySettingsView: View {
655672
656673 Text(importMode.explanation)
657674 .font(appDensity.font(.caption, design: .default))
658 .foregroundStyle(Color(.appTextSecondary))
675 .foregroundStyle(ThemeToken.textSecondary)
659676
660677 Button("Export Full Backup") {
661678 exportFullBackup()
@@ -712,12 +729,12 @@ private struct DataPortabilitySettingsView: View {
712729
713730 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.")
714731 .font(appDensity.font(.caption, design: .default))
715 .foregroundStyle(Color(.appTextSecondary))
732 .foregroundStyle(ThemeToken.textSecondary)
716733
717734 if let portabilityStatusMessage = viewModel.portabilityStatusMessage {
718735 Text(portabilityStatusMessage)
719736 .font(appDensity.font(.caption, design: .default))
720 .foregroundStyle(Color(.appTextSecondary))
737 .foregroundStyle(ThemeToken.textSecondary)
721738 }
722739 }
723740
@@ -726,7 +743,7 @@ private struct DataPortabilitySettingsView: View {
726743 Section("Import Debug") {
727744 Text(importDebugStatus)
728745 .font(appDensity.font(.caption, design: .default))
729 .foregroundStyle(Color(.appTextSecondary))
746 .foregroundStyle(ThemeToken.textSecondary)
730747 .textSelection(.enabled)
731748 }
732749 }
@@ -1032,14 +1049,14 @@ private struct DataManagementSettingsView: View {
10321049 if let deleteAllSuccessMessage {
10331050 Text(deleteAllSuccessMessage)
10341051 .font(.footnote.weight(.medium))
1035 .foregroundStyle(Color(.appTextSecondary))
1052 .foregroundStyle(ThemeToken.textSecondary)
10361053 .padding(.horizontal, 14)
10371054 .padding(.vertical, 10)
10381055 // Reduce Transparency swaps the blur for an opaque surface.
10391056 // On iOS 26+ the system also composites its own translucency
10401057 // that the app cannot declare — verify there too (Phase 6).
10411058 .background(
1042 Capsule().fill(reduceTransparency ? AnyShapeStyle(Color(.appSurfaceElevated)) : AnyShapeStyle(.thinMaterial))
1059 Capsule().fill(reduceTransparency ? AnyShapeStyle(ThemeToken.surfaceElevated) : AnyShapeStyle(.thinMaterial))
10431060 )
10441061 .padding(.bottom, 8)
10451062 .transition(.move(edge: .bottom).combined(with: .opacity))
@@ -1101,7 +1118,7 @@ private struct DataImportPreviewSheet: View {
11011118 Section("Warnings") {
11021119 ForEach(preview.warnings, id: \.self) { warning in
11031120 Text(warning)
1104 .foregroundStyle(Color(.appTextSecondary))
1121 .foregroundStyle(ThemeToken.textSecondary)
11051122 }
11061123 }
11071124 }
DomainDig/SubdomainsSectionView.swift +5 −5
@@ -100,16 +100,16 @@ struct SubdomainsSectionView: View {
100100 if !groups.isEmpty {
101101 Text("Groups")
102102 .font(appDensity.font(.caption2))
103 .foregroundStyle(Color(.appTextSecondary))
103 .foregroundStyle(ThemeToken.textSecondary)
104104 ForEach(groups) { group in
105105 HStack {
106106 Text("\(group.label).*")
107107 .font(appDensity.font(.caption))
108 .foregroundStyle(Color(.statusInfo))
108 .foregroundStyle(ThemeToken.info)
109109 Spacer()
110110 Text("\(group.subdomains.count)")
111111 .font(appDensity.font(.caption2))
112 .foregroundStyle(Color(.appTextSecondary))
112 .foregroundStyle(ThemeToken.textSecondary)
113113 }
114114 }
115115 }
@@ -127,10 +127,10 @@ struct SubdomainsSectionView: View {
127127 if row.isInteresting {
128128 Text("Interesting")
129129 .font(.system(.caption2, design: .monospaced))
130 .foregroundStyle(Color(.statusWarning))
130 .foregroundStyle(ThemeToken.warning)
131131 .padding(.horizontal, 8)
132132 .padding(.vertical, 4)
133 .background(Color(.statusWarningSurface))
133 .background(ThemeToken.warningSurface)
134134 .clipShape(Capsule())
135135 }
136136 }
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 {
4545 }
4646 }
4747 }
48 .listRowBackground(Color(.appSurface))
48 .themedListRowBackground(.surface)
4949 }
5050 }
5151 }
5252 .scrollContentBackground(.hidden)
53 .background(Color(.appBackground))
53 .background(ThemeToken.background)
5454 .navigationTitle(domain)
5555 .toolbar {
5656 ToolbarItemGroup(placement: .topBarTrailing) {
@@ -117,8 +117,8 @@ private struct TimelineRow: View {
117117 model: .init(
118118 title: severity.title,
119119 systemImage: "arrow.triangle.2.circlepath",
120 foregroundColor: severity == .high ? Color(.statusCritical) : Color(.statusWarning),
121 backgroundColor: (severity == .high ? AppStatusTone.critical : .warning).surface
120 foreground: severity == .high ? .critical : .warning,
121 background: (severity == .high ? AppStatusTone.critical : .warning).surface
122122 )
123123 )
124124 }
@@ -126,7 +126,7 @@ private struct TimelineRow: View {
126126
127127 Text(summary.changeSummaryMessage ?? "No change summary")
128128 .font(appDensity.font(.caption))
129 .foregroundStyle(Color(.appTextSecondary))
129 .foregroundStyle(ThemeToken.textSecondary)
130130 .lineLimit(2)
131131
132132 HStack(spacing: 8) {
@@ -138,14 +138,14 @@ private struct TimelineRow: View {
138138 }
139139 }
140140 .font(appDensity.font(.caption2))
141 .foregroundStyle(Color(.appTextSecondary))
141 .foregroundStyle(ThemeToken.textSecondary)
142142
143143 if !entry.intelligenceTimeline.isEmpty {
144144 VStack(alignment: .leading, spacing: 4) {
145145 ForEach(Array(entry.intelligenceTimeline.prefix(2))) { event in
146146 Text("\(event.title): \(event.detail)")
147147 .font(appDensity.font(.caption2))
148 .foregroundStyle(Color(.appTextSecondary))
148 .foregroundStyle(ThemeToken.textSecondary)
149149 .lineLimit(1)
150150 }
151151 }
@@ -162,7 +162,7 @@ private struct TimelineRow: View {
162162 .lineLimit(1)
163163 }
164164 .font(appDensity.font(.caption2))
165 .foregroundStyle(Color(.appTextSecondary))
165 .foregroundStyle(ThemeToken.textSecondary)
166166 }
167167 }
168168}
@@ -205,7 +205,7 @@ struct TimelineDiffView: View {
205205 }
206206 .padding()
207207 }
208 .background(Color(.appBackground))
208 .background(ThemeToken.background)
209209 .navigationTitle("Compare Snapshots")
210210 .navigationBarTitleDisplayMode(.inline)
211211 .onAppear {
DomainDig/WatchlistView.swift +34 −34
@@ -37,11 +37,11 @@ struct WatchlistView: View {
3737 Section("Refresh Progress") {
3838 VStack(alignment: .leading, spacing: 8) {
3939 ProgressView(value: Double(viewModel.batchCompletedCount), total: Double(max(viewModel.batchTotalCount, 1)))
40 .tint(Color(.statusInfo))
40 .tint(ThemeToken.info)
4141 HStack {
4242 Text(viewModel.batchProgressLabel)
4343 .font(appDensity.font(.caption))
44 .foregroundStyle(Color(.appTextSecondary))
44 .foregroundStyle(ThemeToken.textSecondary)
4545 Spacer()
4646 if viewModel.batchLookupRunning {
4747 Button("Cancel") {
@@ -58,7 +58,7 @@ struct WatchlistView: View {
5858 }
5959 .padding(.vertical, 4)
6060 }
61 .listRowBackground(Color(.appSurface))
61 .themedListRowBackground(.surface)
6262 }
6363
6464 if viewModel.filteredTrackedDomains.isEmpty {
@@ -71,15 +71,15 @@ struct WatchlistView: View {
7171 showsCardBackground: false
7272 )
7373 }
74 .listRowBackground(Color(.appSurface))
74 .themedListRowBackground(.surface)
7575 } else {
7676 if let limitMessage = FeatureAccessService.trackedDomainLimitMessage(currentCount: viewModel.trackedDomains.count) {
7777 Section {
7878 Text(limitMessage)
7979 .font(appDensity.font(.caption))
80 .foregroundStyle(Color(.appTextSecondary))
80 .foregroundStyle(ThemeToken.textSecondary)
8181 }
82 .listRowBackground(Color(.appSurface))
82 .themedListRowBackground(.surface)
8383 }
8484
8585 if !pinnedDomains.isEmpty {
@@ -93,7 +93,7 @@ struct WatchlistView: View {
9393 }
9494 .animation(reduceMotion ? nil : .easeInOut(duration: 0.2), value: viewModel.filteredTrackedDomains.map(\.id))
9595 .scrollContentBackground(.hidden)
96 .background(Color(.appBackground))
96 .background(ThemeToken.background)
9797 .navigationTitle("Watchlist")
9898 .searchable(text: $viewModel.watchlistSearchText, prompt: "Search tracked domains")
9999 .toolbar {
@@ -180,14 +180,14 @@ struct WatchlistView: View {
180180 Section {
181181 Text("Adds the domain directly to your watchlist so monitoring can run without a prior inspection.")
182182 .font(appDensity.font(.caption))
183 .foregroundStyle(Color(.appTextSecondary))
183 .foregroundStyle(ThemeToken.textSecondary)
184184 }
185185
186186 if let addDomainError {
187187 Section {
188188 Text(addDomainError)
189189 .font(appDensity.font(.caption))
190 .foregroundStyle(Color(.statusCritical))
190 .foregroundStyle(ThemeToken.critical)
191191 }
192192 }
193193 }
@@ -239,7 +239,7 @@ struct WatchlistView: View {
239239 .foregroundStyle(.primary)
240240 Text([view.tag, view.filter.title, view.sort.title].compactMap { $0 }.joined(separator: " • "))
241241 .font(.caption)
242 .foregroundStyle(Color(.appTextSecondary))
242 .foregroundStyle(ThemeToken.textSecondary)
243243 }
244244 }
245245 }
@@ -283,19 +283,19 @@ struct WatchlistView: View {
283283 .buttonStyle(.plain)
284284 .swipeActions(edge: .leading, allowsFullSwipe: false) {
285285 refreshButton(trackedDomain)
286 .tint(Color(.statusInfo))
286 .tint(ThemeToken.info)
287287 pinButton(trackedDomain)
288 .tint(Color(.statusWarning))
288 .tint(ThemeToken.warning)
289289 }
290290 .swipeActions(edge: .trailing, allowsFullSwipe: false) {
291291 refreshButton(trackedDomain)
292 .tint(Color(.statusInfo))
292 .tint(ThemeToken.info)
293293 deleteButton(trackedDomain)
294294 }
295295 .contextMenu {
296296 rowMenu(trackedDomain)
297297 }
298 .listRowBackground(Color(.appSurface))
298 .themedListRowBackground(.surface)
299299 }
300300
301301 @ViewBuilder
@@ -418,12 +418,12 @@ struct WatchlistRowView: View {
418418
419419 Text("Updated \(trackedDomain.updatedAt.formatted(date: .abbreviated, time: .shortened))")
420420 .font(appDensity.font(.caption2))
421 .foregroundStyle(Color(.appTextSecondary))
421 .foregroundStyle(ThemeToken.textSecondary)
422422
423423 if let collaboration = trackedDomain.collaboration, collaboration.isShared {
424424 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
425425 .font(appDensity.font(.caption2))
426 .foregroundStyle(Color(.appTextSecondary))
426 .foregroundStyle(ThemeToken.textSecondary)
427427 }
428428
429429 ViewThatFits(in: .horizontal) {
@@ -431,19 +431,19 @@ struct WatchlistRowView: View {
431431 VStack(alignment: .leading, spacing: 2) { monitoringMetadata }
432432 }
433433 .font(appDensity.font(.caption2))
434 .foregroundStyle(Color(.appTextSecondary))
434 .foregroundStyle(ThemeToken.textSecondary)
435435
436436 indicatorRow
437437
438438 if let note = trackedDomain.note?.trimmingCharacters(in: .whitespacesAndNewlines), !note.isEmpty {
439439 Text(note)
440440 .font(appDensity.font(.caption))
441 .foregroundStyle(Color(.appTextSecondary))
441 .foregroundStyle(ThemeToken.textSecondary)
442442 .lineLimit(2)
443443 } else if let summary = trackedDomain.lastChangeSummary {
444444 Text(summary.message)
445445 .font(appDensity.font(.caption))
446 .foregroundStyle(Color(.appTextSecondary))
446 .foregroundStyle(ThemeToken.textSecondary)
447447 .lineLimit(2)
448448 }
449449 }
@@ -468,7 +468,7 @@ struct WatchlistRowView: View {
468468 if trackedDomain.isPinned {
469469 Image(systemName: "pin.fill")
470470 .font(.caption2)
471 .foregroundStyle(Color(.statusWarning))
471 .foregroundStyle(ThemeToken.warning)
472472 }
473473 Text(trackedDomain.domain)
474474 .font(appDensity.font(.callout))
@@ -493,7 +493,7 @@ struct WatchlistRowView: View {
493493 @ViewBuilder
494494 private var statusBadge: some View {
495495 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))
497497 } else {
498498 AppStatusBadgeView(model: AppStatusFactory.availability(trackedDomain.lastKnownAvailability))
499499 }
@@ -507,8 +507,8 @@ struct WatchlistRowView: View {
507507 model: .init(
508508 title: "Shared",
509509 systemImage: "person.2.fill",
510 foregroundColor: Color(.statusInfo),
511 backgroundColor: Color(.statusInfoSurface)
510 foreground: .info,
511 background: .infoSurface
512512 )
513513 )
514514 }
@@ -525,11 +525,11 @@ struct WatchlistRowView: View {
525525 let days = trackedDomain.certificateDaysRemaining.map { "\($0)d" } ?? "Soon"
526526 switch trackedDomain.certificateWarningLevel {
527527 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)
529529 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)
531531 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)
533533 }
534534 }
535535}
@@ -596,7 +596,7 @@ struct TrackedDomainDetailView: View {
596596 isRefreshing: viewModel.refreshingTrackedDomainID == liveTrackedDomain.id
597597 )
598598 }
599 .listRowBackground(Color(.appSurface))
599 .themedListRowBackground(.surface)
600600
601601 Section {
602602 Button {
@@ -678,13 +678,13 @@ struct TrackedDomainDetailView: View {
678678 Label(liveTrackedDomain.collaboration?.isShared == true ? "Manage Share" : "Share Domain", systemImage: "person.2")
679679 }
680680 }
681 .listRowBackground(Color(.appSurface))
681 .themedListRowBackground(.surface)
682682
683683 if !liveTrackedDomain.tags.isEmpty {
684684 Section("Tags") {
685685 TagChipRowView(tags: liveTrackedDomain.tags)
686686 }
687 .listRowBackground(Color(.appSurface))
687 .themedListRowBackground(.surface)
688688 }
689689
690690 Section("Monitoring Status") {
@@ -698,7 +698,7 @@ struct TrackedDomainDetailView: View {
698698 LabeledContent("Queued Alerts", value: "\(liveTrackedDomain.pendingMonitoringAlerts.count)")
699699 }
700700 }
701 .listRowBackground(Color(.appSurface))
701 .themedListRowBackground(.surface)
702702
703703 if let summary = viewModel.latestChangeSummary(for: liveTrackedDomain) {
704704 Section("Latest Change Summary") {
@@ -726,7 +726,7 @@ struct TrackedDomainDetailView: View {
726726 if latestSnapshots.isEmpty {
727727 Text("No snapshots yet")
728728 .font(.system(.caption, design: .monospaced))
729 .foregroundStyle(Color(.appTextSecondary))
729 .foregroundStyle(ThemeToken.textSecondary)
730730 } else {
731731 ForEach(latestSnapshots) { entry in
732732 NavigationLink {
@@ -738,16 +738,16 @@ struct TrackedDomainDetailView: View {
738738 .foregroundStyle(.primary)
739739 Text(entry.changeSummary?.hasChanges == true ? "Changed" : "Snapshot")
740740 .font(.system(.caption2, design: .monospaced))
741 .foregroundStyle(Color(.appTextSecondary))
741 .foregroundStyle(ThemeToken.textSecondary)
742742 }
743743 }
744744 }
745745 }
746746 }
747 .listRowBackground(Color(.appSurface))
747 .themedListRowBackground(.surface)
748748 }
749749 .scrollContentBackground(.hidden)
750 .background(Color(.appBackground))
750 .background(ThemeToken.background)
751751 .navigationTitle(liveTrackedDomain.domain)
752752 .onChange(of: viewModel.rerunNavigationToken) { _, _ in
753753 dismiss()
DomainDig/WebSectionView.swift +8 −8
@@ -52,7 +52,7 @@ struct WebSectionView: View {
5252 HStack {
5353 Text("TLS")
5454 .font(appDensity.font(.subheadline, weight: .semibold))
55 .foregroundStyle(Color(.statusInfo))
55 .foregroundStyle(ThemeToken.info)
5656 Spacer()
5757 if !sslLoading {
5858 AppStatusBadgeView(model: AppStatusFactory.tls(sslInfo: sslInfo, error: sslError))
@@ -77,7 +77,7 @@ struct WebSectionView: View {
7777 if let sslInfo, !sslInfo.subjectAltNames.isEmpty {
7878 Text("SANs")
7979 .font(appDensity.font(.caption2))
80 .foregroundStyle(Color(.appTextSecondary))
80 .foregroundStyle(ThemeToken.textSecondary)
8181 ForEach(sslInfo.subjectAltNames, id: \.self) { san in
8282 HStack(alignment: .top, spacing: 8) {
8383 Text(san)
@@ -96,7 +96,7 @@ struct WebSectionView: View {
9696 CardView {
9797 Text("Headers")
9898 .font(appDensity.font(.subheadline, weight: .semibold))
99 .foregroundStyle(Color(.statusInfo))
99 .foregroundStyle(ThemeToken.info)
100100 SectionTrustMetadataView(provenance: httpProvenance, confidence: nil)
101101 if headersLoading {
102102 ProgressView("Fetching headers…")
@@ -114,7 +114,7 @@ struct WebSectionView: View {
114114 HStack(alignment: .top, spacing: 4) {
115115 Text(header.name + ":")
116116 .font(appDensity.font(.caption))
117 .foregroundStyle(header.isSecurityHeader ? Color(.statusWarning) : Color(.statusInfo))
117 .foregroundStyle(header.isSecurityHeader ? ThemeToken.warning : ThemeToken.info)
118118 Text(header.value)
119119 .font(appDensity.font(.caption))
120120 .foregroundStyle(.primary)
@@ -129,7 +129,7 @@ struct WebSectionView: View {
129129 HStack {
130130 Text("Redirects")
131131 .font(appDensity.font(.subheadline, weight: .semibold))
132 .foregroundStyle(Color(.statusInfo))
132 .foregroundStyle(ThemeToken.info)
133133 Spacer()
134134 if let finalURL {
135135 AppCopyButton(value: finalURL, label: "Copy redirect URL")
@@ -151,11 +151,11 @@ struct WebSectionView: View {
151151 HStack(alignment: .top, spacing: 6) {
152152 Text(redirect.stepLabel)
153153 .font(appDensity.font(.caption))
154 .foregroundStyle(Color(.appTextSecondary))
154 .foregroundStyle(ThemeToken.textSecondary)
155155 .frame(width: 16, alignment: .trailing)
156156 Text(redirect.statusCode)
157157 .font(appDensity.font(.caption))
158 .foregroundStyle(Color(.statusInfo))
158 .foregroundStyle(ThemeToken.info)
159159 .frame(width: 36, alignment: .leading)
160160 Text(redirect.url)
161161 .font(appDensity.font(.caption))
@@ -163,7 +163,7 @@ struct WebSectionView: View {
163163 if redirect.isFinal {
164164 Text("(final)")
165165 .font(appDensity.font(.caption2))
166 .foregroundStyle(Color(.appTextSecondary))
166 .foregroundStyle(ThemeToken.textSecondary)
167167 }
168168 Spacer(minLength: 8)
169169 AppCopyButton(value: redirect.url, label: "Copy redirect URL")
DomainDig/WorkflowsView.swift +24 −24
@@ -20,15 +20,15 @@ struct WorkflowsView: View {
2020 Section {
2121 Text(limitMessage)
2222 .font(appDensity.font(.caption))
23 .foregroundStyle(Color(.appTextSecondary))
23 .foregroundStyle(ThemeToken.textSecondary)
2424 }
25 .listRowBackground(Color(.appSurface))
25 .themedListRowBackground(.surface)
2626 }
2727
2828 workflowContent
2929 }
3030 .scrollContentBackground(.hidden)
31 .background(Color(.appBackground))
31 .background(ThemeToken.background)
3232 .refreshable {
3333 await viewModel.refreshWorkflowList()
3434 }
@@ -71,12 +71,12 @@ struct WorkflowsView: View {
7171 value: Double(viewModel.batchCompletedCount),
7272 total: Double(max(viewModel.batchTotalCount, 1))
7373 )
74 .tint(Color(.statusInfo))
74 .tint(ThemeToken.info)
7575
7676 HStack {
7777 Text(viewModel.batchProgressLabel)
7878 .font(appDensity.font(.caption))
79 .foregroundStyle(Color(.appTextSecondary))
79 .foregroundStyle(ThemeToken.textSecondary)
8080 Spacer()
8181 if viewModel.batchLookupRunning {
8282 Button("Cancel") {
@@ -89,7 +89,7 @@ struct WorkflowsView: View {
8989 }
9090 .padding(.vertical, 4)
9191 }
92 .listRowBackground(Color(.appSurface))
92 .themedListRowBackground(.surface)
9393 }
9494
9595 if viewModel.workflows.isEmpty {
@@ -102,7 +102,7 @@ struct WorkflowsView: View {
102102 showsCardBackground: false
103103 )
104104 }
105 .listRowBackground(Color(.appSurface))
105 .themedListRowBackground(.surface)
106106 } else {
107107 ForEach(viewModel.workflows) { workflow in
108108 NavigationLink {
@@ -110,7 +110,7 @@ struct WorkflowsView: View {
110110 } label: {
111111 WorkflowRowView(workflow: workflow)
112112 }
113 .listRowBackground(Color(.appSurface))
113 .themedListRowBackground(.surface)
114114 }
115115 .onDelete { offsets in
116116 let workflows = offsets.map { viewModel.workflows[$0] }
@@ -131,7 +131,7 @@ private struct WorkflowRowView: View {
131131 if workflow.collaboration?.isShared == true {
132132 Image(systemName: "person.2.fill")
133133 .font(.caption2)
134 .foregroundStyle(Color(.statusInfo))
134 .foregroundStyle(ThemeToken.info)
135135 .accessibilityLabel("Shared")
136136 }
137137 Text(workflow.name)
@@ -141,23 +141,23 @@ private struct WorkflowRowView: View {
141141 Spacer(minLength: 8)
142142 Text("\(workflow.domains.count) domains")
143143 .font(appDensity.font(.caption2))
144 .foregroundStyle(Color(.appTextSecondary))
144 .foregroundStyle(ThemeToken.textSecondary)
145145 }
146146
147147 Text("Updated \(workflow.updatedAt.formatted(date: .abbreviated, time: .shortened))")
148148 .font(appDensity.font(.caption2))
149 .foregroundStyle(Color(.appTextSecondary))
149 .foregroundStyle(ThemeToken.textSecondary)
150150
151151 if let collaboration = workflow.collaboration, collaboration.isShared {
152152 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
153153 .font(appDensity.font(.caption2))
154 .foregroundStyle(Color(.appTextSecondary))
154 .foregroundStyle(ThemeToken.textSecondary)
155155 }
156156
157157 if let notes = workflow.notes, !notes.isEmpty {
158158 Text(notes)
159159 .font(appDensity.font(.caption))
160 .foregroundStyle(Color(.appTextSecondary))
160 .foregroundStyle(ThemeToken.textSecondary)
161161 .lineLimit(2)
162162 }
163163 }
@@ -196,12 +196,12 @@ struct WorkflowDetailView: View {
196196 if let notes = workflow.notes, !notes.isEmpty {
197197 Text(notes)
198198 .font(appDensity.font(.caption))
199 .foregroundStyle(Color(.appTextSecondary))
199 .foregroundStyle(ThemeToken.textSecondary)
200200 }
201201 if let collaboration = workflow.collaboration, collaboration.isShared {
202202 Text("\(collaboration.ownership.title) • \(collaboration.permission.title)")
203203 .font(appDensity.font(.caption))
204 .foregroundStyle(Color(.appTextSecondary))
204 .foregroundStyle(ThemeToken.textSecondary)
205205 }
206206 }
207207
@@ -256,7 +256,7 @@ struct WorkflowDetailView: View {
256256 if !latestSummary.workflowInsights.isEmpty {
257257 Text(latestSummary.workflowInsights[0].description)
258258 .font(appDensity.font(.caption))
259 .foregroundStyle(Color(.appTextSecondary))
259 .foregroundStyle(ThemeToken.textSecondary)
260260 }
261261
262262 Button {
@@ -285,7 +285,7 @@ struct WorkflowDetailView: View {
285285 if workflow.domains.isEmpty {
286286 Text("No domains in this workflow")
287287 .font(appDensity.font(.caption))
288 .foregroundStyle(Color(.appTextSecondary))
288 .foregroundStyle(ThemeToken.textSecondary)
289289 } else {
290290 ForEach(workflow.domains, id: \.self) { domain in
291291 Button {
@@ -297,7 +297,7 @@ struct WorkflowDetailView: View {
297297 .foregroundStyle(.primary)
298298 Spacer()
299299 Image(systemName: "arrow.up.right.circle")
300 .foregroundStyle(Color(.appTextSecondary))
300 .foregroundStyle(ThemeToken.textSecondary)
301301 }
302302 }
303303 .buttonStyle(.plain)
@@ -314,7 +314,7 @@ struct WorkflowDetailView: View {
314314 }
315315 }
316316 .scrollContentBackground(.hidden)
317 .background(Color(.appBackground))
317 .background(ThemeToken.background)
318318 .navigationTitle(workflow.name)
319319 .toolbar {
320320 if !workflow.domains.isEmpty {
@@ -334,7 +334,7 @@ struct WorkflowDetailView: View {
334334 } else {
335335 Text("Workflow not found")
336336 .font(appDensity.font(.callout))
337 .foregroundStyle(Color(.appTextSecondary))
337 .foregroundStyle(ThemeToken.textSecondary)
338338 }
339339 }
340340 }
@@ -343,7 +343,7 @@ struct WorkflowDetailView: View {
343343 HStack {
344344 Text(label)
345345 .font(appDensity.font(.caption))
346 .foregroundStyle(Color(.appTextSecondary))
346 .foregroundStyle(ThemeToken.textSecondary)
347347 Spacer()
348348 Text(value)
349349 .font(appDensity.font(.callout))
@@ -484,7 +484,7 @@ struct WorkflowRunSummaryView: View {
484484 .foregroundStyle(.primary)
485485 Text(insight.domainsInvolved.joined(separator: ", "))
486486 .font(.system(.caption, design: .monospaced))
487 .foregroundStyle(Color(.appTextSecondary))
487 .foregroundStyle(ThemeToken.textSecondary)
488488 }
489489 }
490490 }
@@ -525,7 +525,7 @@ struct WorkflowRunSummaryView: View {
525525 HStack {
526526 Text(label)
527527 .font(.system(.caption, design: .monospaced))
528 .foregroundStyle(Color(.appTextSecondary))
528 .foregroundStyle(ThemeToken.textSecondary)
529529 Spacer()
530530 Text(value)
531531 .font(.system(.callout, design: .monospaced))
@@ -580,7 +580,7 @@ struct WorkflowBulkAddSheet: View {
580580 .foregroundStyle(.primary)
581581 Spacer()
582582 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))
584584 }
585585 }
586586 .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}