feat(menubar): 将资源概览调整为三列两行布局

This commit is contained in:
2026-11-15 14:39:55 +08:00
parent 585fb0e130
commit 47e3fe6ca8
6 changed files with 65 additions and 46 deletions
+10 -9
View File
@@ -53,10 +53,10 @@ struct MenuPanelView: View {
header
if presentation.page == .overview {
if PanelLayout.needsResourceScroll(size: panelSize, heights: cardHeights) {
ScrollView { resourceColumns }
ScrollView { resourceGrid }
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
resourceColumns
resourceGrid
.frame(maxHeight: .infinity, alignment: .top)
}
} else if presentation.isOpen {
@@ -91,15 +91,16 @@ struct MenuPanelView: View {
.modifier(AppearanceStyle(preferences: preferences))
}
private var resourceColumns: some View {
let groups = PanelLayout.cardColumns(columns: columns)
return HStack(alignment: .top, spacing: PanelStyle.gap) {
ForEach(groups.indices, id: \.self) { column in
VStack(spacing: PanelStyle.gap) {
ForEach(groups[column], id: \.self) { card in
private var resourceGrid: some View {
let rows = PanelLayout.cardRows(columns: columns)
let heights = PanelLayout.rowHeights(columns: columns, heights: cardHeights)
return VStack(spacing: PanelStyle.gap) {
ForEach(rows.indices, id: \.self) { row in
HStack(alignment: .top, spacing: PanelStyle.gap) {
ForEach(rows[row], id: \.self) { card in
resourceCard(card)
.frame(maxWidth: .infinity)
.frame(height: cardHeights[card])
.frame(height: heights[row])
.onGeometryChange(for: CGFloat.self) { $0.size.width } action: { width in
if card == .cpu { measuredCardWidth = width }
}