feat(ui): 统一实现卡片背景趋势与大数值布局

This commit is contained in:
2026-11-15 15:40:29 +08:00
parent 397156249b
commit 3c1a2baace
25 changed files with 447 additions and 268 deletions
+14 -14
View File
@@ -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: 960, height: 514))
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 960, 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)
@@ -32,28 +32,28 @@ import CoreGraphics
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 500), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact))
}
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [204, 208])
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [204, 180, 208])
precondition(PanelLayout.cardWidth(size: CGSize(width: 960, height: 514)) == 308,
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [264, 264])
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [264, 264, 264])
precondition(PanelLayout.cardWidth(size: CGSize(width: 960, height: 630)) == 308,
"Three columns must retain readable card widths")
precondition(PanelLayout.preferredHeight(width: 960, heights: compact) == 514)
precondition(PanelLayout.preferredHeight(width: 640, heights: compact) == 702)
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 514), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 513), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 702), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 701), heights: compact))
precondition(PanelLayout.preferredHeight(width: 960, heights: compact) == 630)
precondition(PanelLayout.preferredHeight(width: 640, heights: compact) == 800)
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 630), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 960, height: 629), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 902), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 640, height: 901), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 480, height: 800), heights: compact))
precondition(PanelLayout.columns(width: 960) == 3 && PanelLayout.columns(width: 900) == 3)
precondition(PanelLayout.columns(width: 899) == 2 && PanelLayout.columns(width: 560) == 2 && PanelLayout.columns(width: 559) == 1)
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [308, 208],
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [368, 264],
"Extra CPU rows must grow the first grid row without changing the second")
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10)
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [244, 208])
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [344, 264])
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0)
precondition(noFans[.gpu] == 124 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [204, 208])
precondition(PanelLayout.preferredHeight(width: 960, heights: noFans) == 514,
precondition(noFans[.gpu] == 264 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [264, 264])
precondition(PanelLayout.preferredHeight(width: 960, heights: noFans) == 630,
"A fanless GPU must keep row alignment with CPU and memory")
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact,
"Discovery placeholders must reserve the ordinary fan row")