feat(menubar): 将资源概览调整为三列两行布局
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user