DomainDig/SectionViewData.swift

57 lines · 2065 bytes

 1import SwiftUI
 2
 3// What each result section needs in order to draw itself. Split out of
 4// ResultSectionViews.swift along with the views that consume them (A13).
 5
 6// MARK: - Section view data
 7
 8/// What one card inside a result section needs to know about its own state:
 9/// whether the data is still arriving, what failed, where it came from and how
10/// much to trust it.
11///
12/// These four travelled as a positional group repeated once per card, which is
13/// how `NetworkSectionView` came to declare 22 init parameters and
14/// `WebSectionView` 17 (A10). The views keep their own stored properties —
15/// unpacking happens in the init, so the bodies are unchanged — but a caller
16/// now names three groups instead of counting out twenty-two arguments.
17struct SectionPanelViewData {
18    var isLoading = false
19    var error: String?
20    var provenance: SectionProvenance?
21    var confidence: ConfidenceLevel?
22}
23
24/// The Web section's three cards: TLS, headers, redirects.
25struct WebSectionViewData {
26    var tls = SectionPanelViewData()
27    var certificateRows: [InfoRowViewData] = []
28    var sslInfo: SSLCertificateInfo?
29    var tlsSummary: WebResultSummary?
30
31    var http = SectionPanelViewData()
32    var responseRows: [InfoRowViewData] = []
33    var headers: [HTTPHeader] = []
34
35    var redirect = SectionPanelViewData()
36    var redirectRows: [RedirectHopViewData] = []
37    var finalURL: String?
38}
39
40/// The Network section's cards: reachability, location, ports. Custom port
41/// scanning carries its own state because it runs separately, after the user
42/// asks for it.
43struct NetworkSectionViewData {
44    var reachability = SectionPanelViewData()
45    var reachabilityRows: [ReachabilityRowViewData] = []
46
47    var location = SectionPanelViewData()
48    var locationRows: [InfoRowViewData] = []
49    var geolocation: IPGeolocation?
50
51    var portScan = SectionPanelViewData()
52    var standardPortRows: [PortScanRowViewData] = []
53    var customPortRows: [PortScanRowViewData] = []
54    var customPortScan = SectionPanelViewData()
55
56    var isCloudflareProxied = false
57}