refactor(ui): 统一胶囊页签并将面板收窄至640点

This commit is contained in:
2026-11-08 15:06:27 +08:00
parent 48f7ac73c0
commit 521319ef93
18 changed files with 223 additions and 26 deletions
@@ -58,6 +58,7 @@ extension MenuPanelView {
HStack(spacing: 4) {
Text(title).foregroundStyle(.secondary)
Text(verbatim: address ?? "--").font(PanelStyle.value).monospacedDigit().textSelection(.enabled)
.help(Text(verbatim: address ?? "--"))
Spacer(minLength: 0)
if let address {
Button {
@@ -88,7 +88,8 @@ extension MenuPanelView {
thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1),
scaleLabel: MetricFormat.memory(snapshot.memory?.total), firstValueFormat: .memory, firstLabel: "gpu.totalUtilization",
secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed",
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals,
showsLegendValues: cardContentWidth >= 340)
if let memory = snapshot.memory {
MemoryDetailsView(memory: memory)
} else {
@@ -184,7 +185,8 @@ extension MenuPanelView {
Text("battery.timeEstimate").foregroundStyle(.secondary)
Spacer(minLength: 4)
if battery.externalPower {
Text("battery.timeNotApplicable").font(PanelStyle.value)
Text("battery.notApplicableShort").font(PanelStyle.value)
.help(Text("battery.timeNotApplicable"))
} else if let minutes = battery.minutesRemaining {
MetricText(value: "\(minutes) min").font(PanelStyle.value)
} else {
+3 -5
View File
@@ -124,11 +124,9 @@ struct MenuPanelView: View {
}
private var pagePicker: some View {
Picker("panel.page", selection: Binding(get: { presentation.page }, set: { presentation.page = $0 })) {
Text("panel.overview").tag(PanelPage.overview)
Text("panel.processes").tag(PanelPage.processes)
}
.pickerStyle(.segmented).labelsHidden().frame(width: 164)
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")
}
+2 -2
View File
@@ -4,7 +4,7 @@ import CoreGraphics
nonisolated enum PanelLayout {
static let baseCardHeight: CGFloat = 204
static func headerHeight(width: CGFloat) -> CGFloat { width >= 840 ? 32 : 64 }
static func columns(width: CGFloat) -> Int { width >= 680 ? 2 : 1 }
static func columns(width: CGFloat) -> Int { width >= 560 ? 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))
@@ -28,7 +28,7 @@ nonisolated enum PanelLayout {
}
static func contentSize(visible: CGRect, chrome: CGSize = .zero) -> CGSize {
CGSize(width: max(1, min(960, visible.width - 32 - max(0, chrome.width))),
CGSize(width: max(1, min(640, visible.width - 32 - max(0, chrome.width))),
height: max(1, min(800, visible.height - 32 - max(0, chrome.height))))
}
static func centeredFrame(_ frame: CGRect, visible: CGRect) -> CGRect {