feat(menubar): 实现紧凑独立双列与按内容定高
This commit is contained in:
@@ -5,9 +5,12 @@ import SwiftUI
|
||||
for count in 0...128 {
|
||||
for width in [120.0, 280.0, 430.0, 800.0] {
|
||||
let rows = CPUCoreGridLayout.rowCounts(count: count, width: width)
|
||||
precondition(rows.reduce(0, +) == count && rows.count <= 3)
|
||||
precondition(rows.reduce(0, +) == count)
|
||||
if let first = rows.first, let last = rows.last {
|
||||
precondition(last > 0 && first - last <= 1)
|
||||
let columns = rows.max()!
|
||||
let cellWidth = (width - Double(columns - 1) * 6) / Double(columns)
|
||||
precondition(cellWidth >= 16, "Core text must fit a readable cell instead of being forced into three rows")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,10 +28,13 @@ import SwiftUI
|
||||
precondition(widths.reduce(0, +) <= width + 0.001)
|
||||
for (group, groupWidth) in zip(groups, widths) {
|
||||
let rows = CPUCoreGridLayout.rowCounts(count: group.count, width: groupWidth)
|
||||
precondition(rows.count <= 3 && rows.reduce(0, +) == group.count)
|
||||
precondition(rows.reduce(0, +) == group.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
for width in [CGFloat.nan, .infinity, -.infinity, 0] {
|
||||
precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128)
|
||||
}
|
||||
precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2)
|
||||
print("PASS: balanced core rows at multiple widths and counts")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user