fix(ui): 缩小卡片并还原设计稿紧凑排布

This commit is contained in:
2026-11-15 17:14:42 +08:00
parent 3c1a2baace
commit d87aa3ccc5
29 changed files with 609 additions and 272 deletions
+8 -8
View File
@@ -7,13 +7,13 @@ nonisolated enum PanelCard: Int, CaseIterable {
nonisolated enum PanelLayout {
static let footerHeight: CGFloat = 26
static let maximumWidth: CGFloat = 960
static let maximumWidth: CGFloat = ResourceCardMetrics.preferredWidth * 3 + 32
static let maximumHeight: CGFloat = 800
static func headerHeight(width: CGFloat) -> CGFloat { width >= 560 ? 32 : 64 }
static func columns(width: CGFloat) -> Int { width >= 900 ? 3 : width >= 560 ? 2 : 1 }
static func columns(width: CGFloat) -> Int { width >= 620 ? 3 : width >= 430 ? 2 : 1 }
static func cardWidth(size: CGSize) -> CGFloat {
let count = columns(width: size.width)
return max(0, (size.width - 20 - CGFloat(count - 1) * 8) / CGFloat(count))
return max(0, (size.width - 20 - CGFloat(count - 1) * 6) / CGFloat(count))
}
/// Keep reading order stable across three-, two- and single-column grids.
@@ -29,8 +29,8 @@ nonisolated enum PanelLayout {
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
let base = ResourceCardMetrics.minimumHeight
let fanRows = fanCount.map { (max(0, $0) + 1) / 2 } ?? 1
return [.cpu: base + CGFloat(max(0, coreRows - 2)) * 26,
.gpu: base + CGFloat(max(0, fanRows - 1)) * 20,
return [.cpu: base + CGFloat(max(0, coreRows - 2)) * 14,
.gpu: base + CGFloat(max(0, fanRows - 1)) * 14,
.memory: base, .battery: base, .storage: base, .network: base]
}
@@ -42,12 +42,12 @@ nonisolated enum PanelLayout {
static func resourceHeight(columns: Int, heights: [PanelCard: CGFloat]) -> CGFloat {
let rows = rowHeights(columns: columns, heights: heights)
return rows.reduce(0, +) + CGFloat(max(0, rows.count - 1)) * 8
return rows.reduce(0, +) + CGFloat(max(0, rows.count - 1)) * 6
}
static func preferredHeight(width: CGFloat, heights: [PanelCard: CGFloat]) -> CGFloat {
min(maximumHeight, resourceHeight(columns: columns(width: width), heights: heights)
+ 20 + headerHeight(width: width) + footerHeight + 16)
+ 20 + headerHeight(width: width) + footerHeight + 12)
}
static var defaultHeight: CGFloat {
@@ -56,7 +56,7 @@ nonisolated enum PanelLayout {
static func needsResourceScroll(size: CGSize, heights: [PanelCard: CGFloat]) -> Bool {
resourceHeight(columns: columns(width: size.width), heights: heights)
> size.height - 20 - headerHeight(width: size.width) - footerHeight - 16
> size.height - 20 - headerHeight(width: size.width) - footerHeight - 12
}
static func contentSize(visible: CGRect, chrome: CGSize = .zero, preferredHeight: CGFloat? = nil) -> CGSize {