feat(ui): 实现全卡堆叠趋势与单页资源进程布局
This commit is contained in:
@@ -3,7 +3,7 @@ import CoreGraphics
|
||||
|
||||
@main struct PanelLayoutChecks {
|
||||
static func main() {
|
||||
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 448))
|
||||
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 630))
|
||||
for visible in [CGRect(x: 0, y: 67, width: 1512, height: 882), CGRect(x: -1440, y: -200, width: 1440, height: 800), CGRect(x: 0, y: 24, width: 800, height: 600)] {
|
||||
let content = PanelLayout.contentSize(visible: visible, chrome: CGSize(width: 4, height: 12))
|
||||
precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
|
||||
@@ -14,7 +14,7 @@ import CoreGraphics
|
||||
precondition(visible.insetBy(dx: 16, dy: 16).contains(centered))
|
||||
}
|
||||
}
|
||||
let compact = PanelLayout.cardHeights(coreRows: 2, fanCount: 2)
|
||||
let compact = PanelLayout.cardHeights(coreRows: 1, fanCount: 2)
|
||||
precondition(PanelLayout.cardRows(columns: 3) == [[.cpu, .gpu, .memory], [.battery, .storage, .network]])
|
||||
precondition(PanelLayout.cardRows(columns: 2) == [[.cpu, .gpu], [.memory, .battery], [.storage, .network]])
|
||||
precondition(PanelLayout.cardRows(columns: 1) == PanelCard.allCases.map { [$0] })
|
||||
@@ -29,39 +29,42 @@ import CoreGraphics
|
||||
for (row, height) in zip(rows, PanelLayout.rowHeights(columns: columns, heights: compact)) {
|
||||
precondition(row.allSatisfy { (compact[$0] ?? 0) <= height }, "Every card must fit its aligned row")
|
||||
}
|
||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 400), heights: compact))
|
||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact))
|
||||
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 400), heights: compact))
|
||||
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 2400), heights: compact))
|
||||
}
|
||||
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [176, 176])
|
||||
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [176, 176, 176])
|
||||
precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 448)) == ResourceCardMetrics.preferredWidth,
|
||||
precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 630)) == ResourceCardMetrics.preferredWidth,
|
||||
"Three columns must retain readable card widths")
|
||||
precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 448)
|
||||
precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 662)
|
||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 448), heights: compact))
|
||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 447), heights: compact))
|
||||
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 662), heights: compact))
|
||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 661), heights: compact))
|
||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 360, height: 800), heights: compact))
|
||||
precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 630)
|
||||
precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 800)
|
||||
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 630), heights: compact))
|
||||
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 629), heights: compact))
|
||||
precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 812), heights: compact))
|
||||
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 811), heights: compact))
|
||||
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 360, height: 800), heights: compact))
|
||||
precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3)
|
||||
precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1)
|
||||
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
|
||||
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [232, 176],
|
||||
"Extra CPU rows must grow the first grid row without changing the second")
|
||||
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10)
|
||||
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [346, 346],
|
||||
"All resource rows must share the maximum structural card height")
|
||||
let moreFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 10)
|
||||
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
|
||||
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 176])
|
||||
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0)
|
||||
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 232])
|
||||
let noFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 0)
|
||||
precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176])
|
||||
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 448,
|
||||
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 630,
|
||||
"A fanless GPU must keep row alignment with CPU and memory")
|
||||
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact,
|
||||
precondition(PanelLayout.cardHeights(coreRows: 1, fanCount: nil) == compact,
|
||||
"Discovery placeholders must reserve the ordinary fan row")
|
||||
let manyCores = PanelLayout.cardHeights(coreRows: 30, fanCount: 10)
|
||||
precondition(PanelLayout.preferredHeight(width: 648, heights: manyCores) == 800)
|
||||
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 800), heights: manyCores))
|
||||
precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 800), heights: manyCores))
|
||||
let requested = PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900), preferredHeight: 732)
|
||||
precondition(requested.height == 732, "A hardware-driven height above the default must be preserved")
|
||||
precondition(PanelLayout.processHeight(heights: compact) == 176)
|
||||
precondition(PanelLayout.dashboardHeight(columns: 3, heights: compact) == 540)
|
||||
precondition(PanelLayout.processHeight(heights: tallerCPU) == 346)
|
||||
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
|
||||
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
|
||||
let path: String? = index == 42 ? "/test/needle" : nil
|
||||
@@ -89,6 +92,6 @@ import CoreGraphics
|
||||
}
|
||||
let pidSorted = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .pid)], order: [])
|
||||
precondition(pidSorted.first?.id.pid == 2000)
|
||||
print("PASS: three-column/two-row grid, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results")
|
||||
print("PASS: three-column resource grid plus equal-height process row, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user