Commit 1ebd99e628
Unsigned
Layout: unified · split
Docs/ACCESSIBILITY.txt +15
| @@ -169,6 +169,21 @@ The remaining Settings destinations — Display, History & Network, Local API, | |||
| 169 | iCloud Sync, Monitoring Log, Monitoring Settings, Scheduled Reports, Import & | 169 | iCloud Sync, Monitoring Log, Monitoring Settings, Scheduled Reports, Import & |
| 170 | Export, Data Management — are still unaudited. | 170 | Export, Data Management — are still unaudited. |
| 171 | 171 | ||
| 172 | ## Recent searches are never audited | ||
| 173 | |||
| 174 | The empty-state suite launches a fresh install, so Inspect's recent-searches | ||
| 175 | section — which only appears once a lookup has been run — is never in the tree | ||
| 176 | when the audit walks it. Driving one real lookup and re-auditing surfaced four | ||
| 177 | findings in it on iOS 27.0: | ||
| 178 | |||
| 179 | - `dynamicType` on the "RECENT" header and on the "Clear" button | ||
| 180 | - `hitRegion` too small on "Clear" | ||
| 181 | - `sufficientElementDescription`, "label not human-readable", on a domain chip | ||
| 182 | |||
| 183 | These are latent rather than new: nothing in the section changed when Inspect | ||
| 184 | moved to a `List`. They need a seeded recent-searches fixture to be audited | ||
| 185 | properly, which the seed harness does not have. | ||
| 186 | |||
| 172 | ## Why the floor runtime needs its own run | 187 | ## Why the floor runtime needs its own run |
| 173 | 188 | ||
| 174 | **Audit coverage is not nested across OS versions.** Each runtime reports | 189 | **Audit coverage is not nested across OS versions.** Each runtime reports |
DomainDig/ContentView.swift +41 −54
| @@ -48,47 +48,38 @@ struct ContentView: View { | |||
| 48 | 48 | ||
| 49 | var body: some View { | 49 | var body: some View { |
| 50 | NavigationStack(path: $navigationPath) { | 50 | NavigationStack(path: $navigationPath) { |
| 51 | ScrollView(.vertical) { | 51 | List { |
| 52 | VStack(spacing: 0) { | 52 | Section { inputSection } |
| 53 | inputSection | 53 | if !viewModel.batchResults.isEmpty || viewModel.batchLookupRunning { |
| 54 | if !viewModel.batchResults.isEmpty || viewModel.batchLookupRunning { | 54 | Section { batchSection } |
| 55 | batchSection | 55 | } |
| 56 | .padding(.top, appDensity.metrics.cardSpacing) | 56 | if viewModel.hasRun { |
| 57 | } | 57 | Section { actionButtons } |
| 58 | if viewModel.hasRun { | 58 | if !viewModel.resultsLoaded { |
| 59 | actionButtons | 59 | Section { LookupProgressOverviewView(steps: viewModel.activeLoadingLabels) } |
| 60 | if !viewModel.resultsLoaded { | 60 | } else if let statusMessage = resultStatusMessage { |
| 61 | LookupProgressOverviewView(steps: viewModel.activeLoadingLabels) | 61 | Section { |
| 62 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 63 | } else if let statusMessage = resultStatusMessage { | ||
| 64 | LookupStatusBannerView(message: statusMessage, resultSource: viewModel.currentResultSource) | 62 | LookupStatusBannerView(message: statusMessage, resultSource: viewModel.currentResultSource) |
| 65 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 66 | } | ||
| 67 | if viewModel.resultsLoaded { | ||
| 68 | SummaryView(fields: viewModel.summaryFields) | ||
| 69 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 70 | if let report = viewModel.currentReport { | ||
| 71 | RiskSummaryCardView(report: report) | ||
| 72 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 73 | InsightsSummaryCardView(insights: report.insights) | ||
| 74 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 75 | } | ||
| 76 | if let changeSummary = viewModel.currentChangeSummary { | ||
| 77 | DomainChangeSummaryView(summary: changeSummary) | ||
| 78 | .padding(.top, appDensity.metrics.cardSpacing) | ||
| 79 | } | ||
| 80 | } | 63 | } |
| 64 | } | ||
| 65 | if viewModel.resultsLoaded { | ||
| 66 | Section { SummaryView(fields: viewModel.summaryFields) } | ||
| 81 | if let report = viewModel.currentReport { | 67 | if let report = viewModel.currentReport { |
| 82 | intelligenceSection(report: report) | 68 | Section { RiskSummaryCardView(report: report) } |
| 83 | .padding(.top, appDensity.metrics.sectionSpacing) | 69 | Section { InsightsSummaryCardView(insights: report.insights) } |
| 70 | } | ||
| 71 | if let changeSummary = viewModel.currentChangeSummary { | ||
| 72 | Section { DomainChangeSummaryView(summary: changeSummary) } | ||
| 84 | } | 73 | } |
| 85 | domainOverviewSection | 74 | } |
| 86 | .padding(.top, appDensity.metrics.sectionSpacing) | 75 | if let report = viewModel.currentReport { |
| 87 | ownershipSection | 76 | Section { intelligenceSection(report: report) } |
| 88 | .padding(.top, appDensity.metrics.sectionSpacing) | 77 | } |
| 89 | subdomainsSection | 78 | Section { domainOverviewSection } |
| 90 | .padding(.top, appDensity.metrics.sectionSpacing) | 79 | Section { ownershipSection } |
| 91 | if !viewModel.currentDiffSections.isEmpty { | 80 | Section { subdomainsSection } |
| 81 | if !viewModel.currentDiffSections.isEmpty { | ||
| 82 | Section { | ||
| 92 | DomainDiffView( | 83 | DomainDiffView( |
| 93 | title: "Latest Changes", | 84 | title: "Latest Changes", |
| 94 | sections: viewModel.currentDiffSections, | 85 | sections: viewModel.currentDiffSections, |
| @@ -96,15 +87,16 @@ struct ContentView: View { | |||
| 96 | showsUnchanged: false, | 87 | showsUnchanged: false, |
| 97 | highlightedSectionID: nil | 88 | highlightedSectionID: nil |
| 98 | ) | 89 | ) |
| 99 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 100 | } | 90 | } |
| 101 | dnsSection | 91 | } |
| 102 | .padding(.top, appDensity.metrics.sectionSpacing) | 92 | Section { dnsSection } |
| 93 | Section { | ||
| 103 | WebSectionView( | 94 | WebSectionView( |
| 104 | isCollapsed: sectionCollapsedBinding(.web), | 95 | isCollapsed: sectionCollapsedBinding(.web), |
| 105 | data: viewModel.webSectionData | 96 | data: viewModel.webSectionData |
| 106 | ) | 97 | ) |
| 107 | .padding(.top, appDensity.metrics.sectionSpacing) | 98 | } |
| 99 | Section { | ||
| 108 | EmailSectionView( | 100 | EmailSectionView( |
| 109 | isCollapsed: sectionCollapsedBinding(.email), | 101 | isCollapsed: sectionCollapsedBinding(.email), |
| 110 | rows: viewModel.emailRows, | 102 | rows: viewModel.emailRows, |
| @@ -114,7 +106,8 @@ struct ContentView: View { | |||
| 114 | confidence: viewModel.currentSnapshot.emailSecurityConfidence, | 106 | confidence: viewModel.currentSnapshot.emailSecurityConfidence, |
| 115 | error: viewModel.emailSecurityError | 107 | error: viewModel.emailSecurityError |
| 116 | ) | 108 | ) |
| 117 | .padding(.top, appDensity.metrics.sectionSpacing) | 109 | } |
| 110 | Section { | ||
| 118 | NetworkSectionView( | 111 | NetworkSectionView( |
| 119 | isCollapsed: sectionCollapsedBinding(.network), | 112 | isCollapsed: sectionCollapsedBinding(.network), |
| 120 | customPortsExpanded: $customPortsExpanded, | 113 | customPortsExpanded: $customPortsExpanded, |
| @@ -122,21 +115,15 @@ struct ContentView: View { | |||
| 122 | data: viewModel.networkSectionData, | 115 | data: viewModel.networkSectionData, |
| 123 | onScanCustomPorts: runCustomPortScan | 116 | onScanCustomPorts: runCustomPortScan |
| 124 | ) | 117 | ) |
| 125 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 126 | } else if !viewModel.recentSearches.isEmpty { | ||
| 127 | recentSearchesSection | ||
| 128 | } | 118 | } |
| 119 | } else if !viewModel.recentSearches.isEmpty { | ||
| 120 | Section { recentSearchesSection } | ||
| 129 | } | 121 | } |
| 130 | .padding(.horizontal) | ||
| 131 | .padding(.bottom, 32) | ||
| 132 | } | 122 | } |
| 133 | .background( | 123 | .listRowBackground(Color(.appSurface)) |
| 134 | LinearGradient( | 124 | .environment(\.cardProvidesSurface, false) |
| 135 | colors: [Color(.appBackground), Color(.appSurface)], | 125 | .scrollContentBackground(.hidden) |
| 136 | startPoint: .top, | 126 | .background(Color(.appBackground)) |
| 137 | endPoint: .bottom | ||
| 138 | ) | ||
| 139 | ) | ||
| 140 | .navigationTitle("DomainDig") | 127 | .navigationTitle("DomainDig") |
| 141 | .toolbar { | 128 | .toolbar { |
| 142 | ToolbarItem(placement: .topBarTrailing) { | 129 | ToolbarItem(placement: .topBarTrailing) { |
DomainDig/DomainDigUI.swift +8 −1
| @@ -415,6 +415,13 @@ struct EmptyStateCardView: View { | |||
| 415 | } | 415 | } |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | /// A collapsible result section. | ||
| 419 | /// | ||
| 420 | /// Its body is a `Group`, not a stack: inside a `List` that makes the header | ||
| 421 | /// and each piece of content their own row, so the row backgrounds draw one | ||
| 422 | /// grouped panel per section and the separators keep the cards inside it | ||
| 423 | /// apart. Every caller puts it in a `List` for that reason — a stack would lay | ||
| 424 | /// the children out itself and lose both. | ||
| 418 | struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View { | 425 | struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View { |
| 419 | @Environment(\.appDensity) private var appDensity | 426 | @Environment(\.appDensity) private var appDensity |
| 420 | @Environment(\.accessibilityReduceMotion) private var reduceMotion | 427 | @Environment(\.accessibilityReduceMotion) private var reduceMotion |
| @@ -440,7 +447,7 @@ struct CollapsibleSectionView<HeaderTrailing: View, Content: View>: View { | |||
| 440 | } | 447 | } |
| 441 | 448 | ||
| 442 | var body: some View { | 449 | var body: some View { |
| 443 | VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) { | 450 | Group { |
| 444 | Button { | 451 | Button { |
| 445 | withAnimation(reduceMotion ? nil : .easeInOut(duration: 0.2)) { | 452 | withAnimation(reduceMotion ? nil : .easeInOut(duration: 0.2)) { |
| 446 | isCollapsed.toggle() | 453 | isCollapsed.toggle() |
DomainDig/HistoryView.swift +122 −108
| @@ -171,120 +171,134 @@ struct HistoryDetailView: View { | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | var body: some View { | 173 | var body: some View { |
| 174 | ScrollView(.vertical) { | 174 | List { |
| 175 | VStack(alignment: .leading, spacing: 0) { | 175 | Section { |
| 176 | snapshotBanner | 176 | snapshotBanner |
| 177 | SummaryView(fields: DomainViewModel.summaryFields(from: snapshot)) | 177 | } |
| 178 | .padding(.top, 8) | 178 | Section { |
| 179 | RiskSummaryCardView(report: report) | 179 | SummaryView(fields: DomainViewModel.summaryFields(from: snapshot)) |
| 180 | .padding(.top, 8) | 180 | } |
| 181 | InsightsSummaryCardView(insights: report.insights) | 181 | Section { |
| 182 | .padding(.top, 8) | 182 | RiskSummaryCardView(report: report) |
| 183 | IntelligenceSectionView( | 183 | } |
| 184 | isCollapsed: .constant(false), | 184 | Section { |
| 185 | report: report, | 185 | InsightsSummaryCardView(insights: report.insights) |
| 186 | showsPlaceholder: !FeatureAccessService.hasAccess(to: .intelligenceDetail) | 186 | } |
| 187 | ) | 187 | Section { |
| 188 | .padding(.top, 8) | 188 | IntelligenceSectionView( |
| 189 | DomainSectionView( | 189 | isCollapsed: .constant(false), |
| 190 | isCollapsed: .constant(false), | 190 | report: report, |
| 191 | rows: DomainViewModel.domainRows(from: snapshot), | 191 | showsPlaceholder: !FeatureAccessService.hasAccess(to: .intelligenceDetail) |
| 192 | suggestions: DomainViewModel.suggestionRows(from: snapshot), | 192 | ) |
| 193 | showSuggestions: entry.availabilityResult?.status == .registered && !entry.suggestions.isEmpty, | 193 | } |
| 194 | availabilityLoading: false, | 194 | Section { |
| 195 | suggestionsLoading: false, | 195 | DomainSectionView( |
| 196 | provenance: snapshot.provenanceBySection[.availability], | 196 | isCollapsed: .constant(false), |
| 197 | confidence: snapshot.availabilityConfidence, | 197 | rows: DomainViewModel.domainRows(from: snapshot), |
| 198 | snapshotNote: entry.note, | 198 | suggestions: DomainViewModel.suggestionRows(from: snapshot), |
| 199 | trackedDomain: trackedDomain, | 199 | showSuggestions: entry.availabilityResult?.status == .registered && !entry.suggestions.isEmpty, |
| 200 | workflows: viewModel.workflowsContaining(domain: entry.domain), | 200 | availabilityLoading: false, |
| 201 | trackingLimitMessage: nil, | 201 | suggestionsLoading: false, |
| 202 | onTrack: { | 202 | provenance: snapshot.provenanceBySection[.availability], |
| 203 | _ = viewModel.trackDomain(domain: entry.domain, availabilityStatus: entry.availabilityResult?.status) | 203 | confidence: snapshot.availabilityConfidence, |
| 204 | }, | 204 | snapshotNote: entry.note, |
| 205 | onTogglePinned: { | 205 | trackedDomain: trackedDomain, |
| 206 | guard let trackedDomain else { return } | 206 | workflows: viewModel.workflowsContaining(domain: entry.domain), |
| 207 | viewModel.togglePinned(for: trackedDomain) | 207 | trackingLimitMessage: nil, |
| 208 | }, | 208 | onTrack: { |
| 209 | onEditNote: nil, | 209 | _ = viewModel.trackDomain(domain: entry.domain, availabilityStatus: entry.availabilityResult?.status) |
| 210 | onAddToWorkflow: nil, | 210 | }, |
| 211 | onOpenWorkflow: nil, | 211 | onTogglePinned: { |
| 212 | onRunWorkflow: nil | 212 | guard let trackedDomain else { return } |
| 213 | ) | 213 | viewModel.togglePinned(for: trackedDomain) |
| 214 | .padding(.top, appDensity.metrics.sectionSpacing) | 214 | }, |
| 215 | OwnershipSectionView( | 215 | onEditNote: nil, |
| 216 | isCollapsed: .constant(false), | 216 | onAddToWorkflow: nil, |
| 217 | rows: DomainViewModel.ownershipRows(from: snapshot), | 217 | onOpenWorkflow: nil, |
| 218 | loading: false, | 218 | onRunWorkflow: nil |
| 219 | error: snapshot.ownershipError, | 219 | ) |
| 220 | provenance: snapshot.provenanceBySection[.ownership], | 220 | } |
| 221 | confidence: snapshot.ownershipConfidence | 221 | Section { |
| 222 | ) | 222 | OwnershipSectionView( |
| 223 | .padding(.top, appDensity.metrics.sectionSpacing) | 223 | isCollapsed: .constant(false), |
| 224 | SubdomainsSectionView( | 224 | rows: DomainViewModel.ownershipRows(from: snapshot), |
| 225 | isCollapsed: .constant(false), | 225 | loading: false, |
| 226 | rows: DomainViewModel.subdomainRows(from: snapshot), | 226 | error: snapshot.ownershipError, |
| 227 | groups: report.subdomainGroups, | 227 | provenance: snapshot.provenanceBySection[.ownership], |
| 228 | loading: false, | 228 | confidence: snapshot.ownershipConfidence |
| 229 | error: snapshot.subdomainsError, | 229 | ) |
| 230 | provenance: snapshot.provenanceBySection[.subdomains], | 230 | } |
| 231 | confidence: snapshot.subdomainConfidence, | 231 | Section { |
| 232 | showsExtendedPlaceholder: !FeatureAccessService.hasAccess(to: .extendedSubdomains) | 232 | SubdomainsSectionView( |
| 233 | ) | 233 | isCollapsed: .constant(false), |
| 234 | .padding(.top, appDensity.metrics.sectionSpacing) | 234 | rows: DomainViewModel.subdomainRows(from: snapshot), |
| 235 | groups: report.subdomainGroups, | ||
| 236 | loading: false, | ||
| 237 | error: snapshot.subdomainsError, | ||
| 238 | provenance: snapshot.provenanceBySection[.subdomains], | ||
| 239 | confidence: snapshot.subdomainConfidence, | ||
| 240 | showsExtendedPlaceholder: !FeatureAccessService.hasAccess(to: .extendedSubdomains) | ||
| 241 | ) | ||
| 242 | } | ||
| 235 | if let comparisonSnapshot = viewModel.comparisonSnapshot(for: entry) { | 243 | if let comparisonSnapshot = viewModel.comparisonSnapshot(for: entry) { |
| 236 | if let changeSummary = entry.changeSummary { | 244 | if let changeSummary = entry.changeSummary { |
| 237 | DomainChangeSummaryView(summary: changeSummary) | 245 | Section { |
| 238 | .padding(.top, appDensity.metrics.sectionSpacing) | 246 | DomainChangeSummaryView(summary: changeSummary) |
| 247 | } | ||
| 239 | } | 248 | } |
| 240 | DomainDiffView( | 249 | Section { |
| 241 | title: "Compared With Previous Snapshot", | 250 | DomainDiffView( |
| 242 | sections: DomainDiffService.diff(from: comparisonSnapshot, to: snapshot), | 251 | title: "Compared With Previous Snapshot", |
| 243 | contextNote: DomainDiffService.comparisonContextNote(from: comparisonSnapshot, to: snapshot), | 252 | sections: DomainDiffService.diff(from: comparisonSnapshot, to: snapshot), |
| 244 | showsUnchanged: false, | 253 | contextNote: DomainDiffService.comparisonContextNote(from: comparisonSnapshot, to: snapshot), |
| 245 | highlightedSectionID: nil | 254 | showsUnchanged: false, |
| 255 | highlightedSectionID: nil | ||
| 256 | ) | ||
| 257 | } | ||
| 258 | } | ||
| 259 | Section { | ||
| 260 | DNSSectionView( | ||
| 261 | isCollapsed: .constant(false), | ||
| 262 | dnssecLabel: DomainViewModel.dnssecLabel(from: snapshot), | ||
| 263 | patternSummary: report.dns.patternSummary, | ||
| 264 | sections: DomainViewModel.dnsRows(from: snapshot), | ||
| 265 | ptrMessage: DomainViewModel.ptrMessage(from: snapshot), | ||
| 266 | loading: false, | ||
| 267 | dnsProvenance: snapshot.provenanceBySection[.dns], | ||
| 268 | ptrProvenance: snapshot.provenanceBySection[.ptr], | ||
| 269 | sectionError: snapshot.dnsError | ||
| 270 | ) | ||
| 271 | } | ||
| 272 | Section { | ||
| 273 | WebSectionView( | ||
| 274 | isCollapsed: .constant(false), | ||
| 275 | data: DomainViewModel.webSectionData(from: snapshot, report: report) | ||
| 276 | ) | ||
| 277 | } | ||
| 278 | Section { | ||
| 279 | EmailSectionView( | ||
| 280 | isCollapsed: .constant(false), | ||
| 281 | rows: DomainViewModel.emailRows(from: snapshot), | ||
| 282 | assessment: report.email, | ||
| 283 | loading: false, | ||
| 284 | provenance: snapshot.provenanceBySection[.emailSecurity], | ||
| 285 | confidence: snapshot.emailSecurityConfidence, | ||
| 286 | error: snapshot.emailSecurityError | ||
| 287 | ) | ||
| 288 | } | ||
| 289 | Section { | ||
| 290 | NetworkSectionView( | ||
| 291 | isCollapsed: .constant(false), | ||
| 292 | customPortsExpanded: .constant(false), | ||
| 293 | customPortInput: .constant(""), | ||
| 294 | data: DomainViewModel.networkSectionData(from: snapshot), | ||
| 295 | onScanCustomPorts: { /* Historical snapshot; re-scanning is not offered here. */ } | ||
| 246 | ) | 296 | ) |
| 247 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 248 | } | 297 | } |
| 249 | DNSSectionView( | ||
| 250 | isCollapsed: .constant(false), | ||
| 251 | dnssecLabel: DomainViewModel.dnssecLabel(from: snapshot), | ||
| 252 | patternSummary: report.dns.patternSummary, | ||
| 253 | sections: DomainViewModel.dnsRows(from: snapshot), | ||
| 254 | ptrMessage: DomainViewModel.ptrMessage(from: snapshot), | ||
| 255 | loading: false, | ||
| 256 | dnsProvenance: snapshot.provenanceBySection[.dns], | ||
| 257 | ptrProvenance: snapshot.provenanceBySection[.ptr], | ||
| 258 | sectionError: snapshot.dnsError | ||
| 259 | ) | ||
| 260 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 261 | WebSectionView( | ||
| 262 | isCollapsed: .constant(false), | ||
| 263 | data: DomainViewModel.webSectionData(from: snapshot, report: report) | ||
| 264 | ) | ||
| 265 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 266 | EmailSectionView( | ||
| 267 | isCollapsed: .constant(false), | ||
| 268 | rows: DomainViewModel.emailRows(from: snapshot), | ||
| 269 | assessment: report.email, | ||
| 270 | loading: false, | ||
| 271 | provenance: snapshot.provenanceBySection[.emailSecurity], | ||
| 272 | confidence: snapshot.emailSecurityConfidence, | ||
| 273 | error: snapshot.emailSecurityError | ||
| 274 | ) | ||
| 275 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 276 | NetworkSectionView( | ||
| 277 | isCollapsed: .constant(false), | ||
| 278 | customPortsExpanded: .constant(false), | ||
| 279 | customPortInput: .constant(""), | ||
| 280 | data: DomainViewModel.networkSectionData(from: snapshot), | ||
| 281 | onScanCustomPorts: { /* Historical snapshot; re-scanning is not offered here. */ } | ||
| 282 | ) | ||
| 283 | .padding(.top, appDensity.metrics.sectionSpacing) | ||
| 284 | } | ||
| 285 | .padding(.horizontal) | ||
| 286 | .padding(.bottom, 32) | ||
| 287 | } | 298 | } |
| 299 | .listRowBackground(Color(.appSurface)) | ||
| 300 | .environment(\.cardProvidesSurface, false) | ||
| 301 | .scrollContentBackground(.hidden) | ||
| 288 | .background(Color(.appBackground)) | 302 | .background(Color(.appBackground)) |
| 289 | .navigationTitle(entry.domain) | 303 | .navigationTitle(entry.domain) |
| 290 | .toolbar { | 304 | .toolbar { |
DomainDig/ResultPrimitives.swift +27 −3
| @@ -36,6 +36,25 @@ struct SectionTitleView: View { | |||
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | /// Whether a `CardView` draws its own surface, or whether whatever contains it | ||
| 40 | /// already provides one. | ||
| 41 | /// | ||
| 42 | /// Set to `false` by the screens that put cards in `List` rows, where the row's | ||
| 43 | /// `.listRowBackground` is the surface and a card drawing its own would be a | ||
| 44 | /// panel inside a panel. `CardView` sets it back to `true` for its content, so | ||
| 45 | /// only the outermost card in a row gives up its chrome and a card nested | ||
| 46 | /// inside one keeps it. | ||
| 47 | private struct CardProvidesSurfaceKey: EnvironmentKey { | ||
| 48 | static let defaultValue = true | ||
| 49 | } | ||
| 50 | |||
| 51 | extension EnvironmentValues { | ||
| 52 | var cardProvidesSurface: Bool { | ||
| 53 | get { self[CardProvidesSurfaceKey.self] } | ||
| 54 | set { self[CardProvidesSurfaceKey.self] = newValue } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 39 | /// A card that wraps its content by default. | 58 | /// A card that wraps its content by default. |
| 40 | /// | 59 | /// |
| 41 | /// `allowsHorizontalScroll` used to default to `true`, so nine call sites put | 60 | /// `allowsHorizontalScroll` used to default to `true`, so nine call sites put |
| @@ -50,6 +69,7 @@ struct SectionTitleView: View { | |||
| 50 | struct CardView<Content: View>: View { | 69 | struct CardView<Content: View>: View { |
| 51 | @Environment(\.appDensity) private var appDensity | 70 | @Environment(\.appDensity) private var appDensity |
| 52 | @Environment(\.dynamicTypeSize) private var dynamicTypeSize | 71 | @Environment(\.dynamicTypeSize) private var dynamicTypeSize |
| 72 | @Environment(\.cardProvidesSurface) private var providesSurface | ||
| 53 | let allowsHorizontalScroll: Bool | 73 | let allowsHorizontalScroll: Bool |
| 54 | let content: Content | 74 | let content: Content |
| 55 | 75 | ||
| @@ -72,15 +92,19 @@ struct CardView<Content: View>: View { | |||
| 72 | } | 92 | } |
| 73 | } | 93 | } |
| 74 | .frame(maxWidth: .infinity, alignment: .leading) | 94 | .frame(maxWidth: .infinity, alignment: .leading) |
| 75 | .padding(appDensity.metrics.cardPadding) | 95 | .padding(providesSurface ? appDensity.metrics.cardPadding : 0) |
| 76 | .background(Color(.appSurface)) | 96 | .background(providesSurface ? Color(.appSurface) : Color.clear) |
| 77 | .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) | 97 | .clipShape( |
| 98 | RoundedRectangle(cornerRadius: providesSurface ? appDensity.metrics.cardCornerRadius : 0) | ||
| 99 | ) | ||
| 78 | } | 100 | } |
| 79 | 101 | ||
| 80 | private var cardContent: some View { | 102 | private var cardContent: some View { |
| 81 | VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) { | 103 | VStack(alignment: .leading, spacing: appDensity.metrics.cardSpacing) { |
| 82 | content | 104 | content |
| 83 | } | 105 | } |
| 106 | // Only the outermost card in a row gives up its surface. | ||
| 107 | .environment(\.cardProvidesSurface, true) | ||
| 84 | } | 108 | } |
| 85 | } | 109 | } |
| 86 | 110 | ||