feat(ui): 实现全卡堆叠趋势与单页资源进程布局
This commit is contained in:
@@ -35,7 +35,7 @@ struct MenuPanelView: View {
|
||||
let coreCount = max(CPUCoreTopology.cores.count, ProcessInfo.processInfo.processorCount, snapshot.cpu?.cores.count ?? 0)
|
||||
let groups = CPUCoreGrid.groups(count: coreCount, kinds: CPUCoreTopology.cores)
|
||||
let widths = CPUCoreGrid.groupWidths(groups: groups, width: cardContentWidth)
|
||||
let coreRows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.reduce(0, +)
|
||||
let coreRows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.max() ?? 0
|
||||
let fanCount = reservedFanCount > 0 ? max(reservedFanCount, snapshot.fans?.count ?? 0) : snapshot.fans?.count
|
||||
return PanelLayout.cardHeights(coreRows: coreRows, fanCount: fanCount)
|
||||
}
|
||||
@@ -51,17 +51,11 @@ struct MenuPanelView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: PanelStyle.gap) {
|
||||
header
|
||||
if presentation.page == .overview {
|
||||
if PanelLayout.needsResourceScroll(size: panelSize, heights: cardHeights) {
|
||||
ScrollView { resourceGrid }
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
} else {
|
||||
resourceGrid
|
||||
.frame(maxHeight: .infinity, alignment: .top)
|
||||
}
|
||||
} else if presentation.isOpen {
|
||||
PanelProcessSection(metrics: metrics, state: processState)
|
||||
if PanelLayout.needsDashboardScroll(size: panelSize, heights: cardHeights) {
|
||||
ScrollView { dashboard }
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
} else {
|
||||
dashboard.frame(maxHeight: .infinity, alignment: .top)
|
||||
}
|
||||
footer
|
||||
}
|
||||
@@ -91,6 +85,17 @@ struct MenuPanelView: View {
|
||||
.modifier(AppearanceStyle(preferences: preferences))
|
||||
}
|
||||
|
||||
private var dashboard: some View {
|
||||
VStack(spacing: PanelStyle.gap) {
|
||||
resourceGrid
|
||||
if presentation.isOpen {
|
||||
PanelProcessSection(metrics: metrics, state: processState)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: PanelLayout.processHeight(heights: cardHeights))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var resourceGrid: some View {
|
||||
let rows = PanelLayout.cardRows(columns: columns)
|
||||
let heights = PanelLayout.rowHeights(columns: columns, heights: cardHeights)
|
||||
@@ -130,25 +135,11 @@ struct MenuPanelView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var pagePicker: some View {
|
||||
NeutralTabPicker(title: "panel.page", selection: Binding(get: { presentation.page }, set: { presentation.page = $0 }),
|
||||
options: [(.overview, "panel.overview"), (.processes, "panel.processes")])
|
||||
.frame(width: 164)
|
||||
.accessibilityIdentifier("panel.tabs")
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
VStack(spacing: 4) {
|
||||
HStack(spacing: 8) {
|
||||
brand
|
||||
Spacer(minLength: 8)
|
||||
controls
|
||||
}
|
||||
.frame(height: 32)
|
||||
.overlay {
|
||||
if panelSize.width >= 560 { pagePicker }
|
||||
}
|
||||
if panelSize.width < 560 { pagePicker.frame(maxWidth: .infinity).frame(height: 28) }
|
||||
HStack(spacing: 8) {
|
||||
brand
|
||||
Spacer(minLength: 8)
|
||||
controls
|
||||
}
|
||||
.frame(height: PanelLayout.headerHeight(width: panelSize.width))
|
||||
.padding(.horizontal, 4)
|
||||
|
||||
Reference in New Issue
Block a user