fix(ui): 提升卡片文字对比度与辅助信息可读性

This commit is contained in:
2026-11-15 19:51:47 +08:00
parent 60c146f8b7
commit 9088f8a251
14 changed files with 179 additions and 79 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ SystemSampler actor 持有差分基线。CPU / 内存 Mach 查询取得的 host
## 展示与本地状态
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。背景绘图区覆盖卡片全宽全高:CPU / GPU / 电池底边为 0、顶边为 100%,内存顶边为物理总量;速率采用独立双向投影,文字和控件叠放其上。统一 16pt 圆角、10pt 前景内边距和静态轻阴影,图表锚点和提示在同一宿主内处理;不显示常驻图例、数值坐标轴、网格或起止时间。
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。背景绘图区覆盖卡片全宽全高:CPU / GPU / 电池底边为 0、顶边为 100%,内存顶边为物理总量;速率采用独立双向投影,文字和控件叠放其上。标题 / 主值 / 详情使用 88% 不透明 PanelCard 同色底板,圆角 8pt 并外延 4pt;底板只包裹内容块,排除底部 Spacer,且不拦截交互。辅助信息主要为 10pt / 16pt 行高,内存和存储详情通过 ViewThatFits 按信息组换行,默认卡片仍为 176pt 高。统一 16pt 圆角、10pt 前景内边距和静态轻阴影,图表锚点和提示在同一宿主内处理;不显示常驻图例、数值坐标轴、网格或起止时间。
StackedSeries 仅在渲染时构建累计上下边界:CPU 自下而上为系统 / 用户,内存为应用 / 联动 / 压缩,GPU 为总占用 / 空闲(相加为 100%,Renderer / Tiler 保留原始提示读数)。任一必要分量缺失或无效时不构造部分总量,原始历史不变。NativePanelCurve 按连续段在匹配的上下边界间闭合面积,保留真实断点;悬浮使用缓存累计边界定位,而提示读取原始分量。电池绘制电量。存储 / 网络通过 PanelCurveProjection.split 在自卡片顶向下 60% 位置绘制零轴,读取 / 上传向上、写入 / 下载向下,两侧各使用卡片高度 30% 的振幅并共享自动速率尺度,峰值不映射到卡片顶边。原始速率仍为正值,提示、标记与面积采用同一投影,保留缺失与真实断点。内存的已用三层包含匿名应用 / 系统进程、联动和压缩器物理内存;缓存 / Swap 口径见监控文档,不再显示重复容量进度条。
+31
View File
@@ -0,0 +1,31 @@
# 卡片文字可读性调整
## 目标与范围
本轮仅实施用户选择的前两项:文字区底板、辅助字号 / 行距与标签数值层级。涉及 UI/Components 的卡片 / 风扇、Features/MenuBar 六卡详情、现有组件检查和 docs。沿用现有卡片尺寸、三行布局、图表尺度 / 配色 / 透明度、采样与进程表,不新增依赖。
## 实施方案
- 前景标题、主值和详情组成紧凑内容块,使用 PanelCard 同色 88% 不透明底板、8pt 圆角,向文字外延 4pt;底板不包含卡片底部 Spacer、不拦截交互。图表仍覆盖整卡并使用原坐标,底板之外的图层保持原样;无模糊、渐变或额外动画。
- 常规辅助信息提升至 10pt,数值 primary / medium、标签 secondary,行高 16pt;标题行升至 16pt,主值 28 / 网络 16pt 保持。核心紧凑短标签升为 9pt、12pt 高;主值单位 / 状态 / 压力标签按空间提升至 10pt。长分类、速率和硬件说明优先按信息组换行,保留完整提示,不靠缩至原 8pt 排版。
- 默认资源卡片仍为 205⅓×176pt;CPU 逐核、风扇与现有多行结构预算延用,详情在剩余高度内排列。保留所有指标、接口 / 卷入口及复制。
## 步骤与验证
- [x] 实现底板与六卡字体、行高和必要换行。
- [x] Debug 构建;复用现有卡片 / 核心 / 风扇 / 布局检查。检查底板只覆盖前景、整卡图区不变、三语与窄宽度详情不出界。
- [x] 隔离真实面板检查浅深色、入口和暂停 / 恢复,只截取本应用内容,保留用户安装副本。
- [x] 同步设计 / 架构 / 测试文档,生成新 dist,清理本轮临时副本和构建并提交,不推送。
## 风险与边界
文字底板会压淡文字下方的曲线,完整背景坐标与原始数据不变。长英文或极大数值可能增加详情行,使用现有 176pt 高度内的留白并实际检查。主观观感、多屏和长期能耗不以短时验证替代。
## 本轮结果(2026-11-15)
- Debug 构建通过(隔离副本关闭调试 dylib 拆分,未改变沙盒 / 权限);仅有无 AppIntents 依赖的元数据提示。
- ResourceCardChecks、CPUCoreGridChecks、FanRotorChecks、PanelLayoutChecks 通过;161 键的三语 / 格式参数检查通过。新增前景 / 留白像素对比确认只有文字区压淡图表,六卡仍为整卡绘图区;生产内存 / 存储详情在 190 / 205⅓ / 400pt、浅深色和三语下保持在 176pt 卡片边界内。
- 隔离实际应用核对深色简体及浅色英文:六个原生绘图区均约 205⅓×176pt;前景有局部同色底板,放大的辅助数值可见,英文内存分类自动分为两行。已实测暂停 / 恢复、卷详情打开 / 关闭及接口菜单打开 / 取消;底板未拦截这些控件。截图仅来自本应用内容。
- Release 生成 dist/readability-v1;原始 / 解压包签名、Hardened Runtime、权限及压缩包内容通过,SHA-256 单独复核。版本仍为 1.2 (14),arm64 / macOS 27.0 起,ad-hoc 未公证。
- 本轮只实施前两项;图表全局配色 / 明度、投影、采样和进程表保持现有实现。真实鼠标悬浮、主观观感、多屏与长期能耗未由本轮检查替代。
- 清理本轮临时构建、脚本、截图、日志、隔离副本与容器;保留用户原安装进程。
+1 -1
View File
@@ -41,7 +41,7 @@ python3 tools/check.py --list
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
| NativeMetricDrawingChecks(--gui) | 实际曲线 / 堆叠色带、双向速率面积和零轴、方向 / 悬浮 / 断点及累计边界定位、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 |
| FanRotorChecks(--gui) | 独立图层多角度 / 多尺寸旋转中心不漂移,原生旋转动画时长、无效 / 零 / 缺失、非活动 / 减弱动态效果及卸载停转 |
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的全宽全高图区、前景覆盖、卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 |
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的全宽全高图区、前景底板像素衰减且未覆盖底部留白、10pt 三语内存 / 存储详情在固定卡片内的边界、卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 |
| ProcessSectionChecks(--gui) | 生产进程区域固定 176pt,三语 / 浅深色及 340 / 628pt 下移除说明行后表格占满剩余高度且无横向滚动条 |
| NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 |
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、六列窄宽度适配、隐藏路径列但真实菜单复制路径、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
+6 -5
View File
@@ -1,4 +1,4 @@
# Kymo 界面设计规范 v1.3
# Kymo 界面设计规范 v1.4
2026-11-15 根据用户确认的[背景趋势设计稿](designs/card-background-trends-v1/README.md)制定,并按后续反馈将首版卡片宽、高缩至 2/3,恢复图稿中的紧凑左对齐排布;本轮将图表扩展到整卡、采用分量堆叠,并合并进程为第三行。本文为实现与验收标准,效果图中的示例数据、品牌重绘与核心格子不作为数据或素材依据。
@@ -18,7 +18,7 @@
| 面板内边距 / 卡片间距 | 10 / 6;常规卡片宽 205⅓ |
| 卡片 | 基础高 176,圆角 16,前景内边距 10 |
| 动态高度 | CPU 核型横向分组,逐核竖柱一行基础预算,超出每行增加 34;GPU 超过一行风扇后每行增加 14;所有行采用最大结构预算,不裁掉硬件数据 |
| 标题 / 主值区域 | 标题行 14,主值行 34,区域间距 4 |
| 标题 / 主值区域 | 标题行 16,主值行 34,区域间距 4 |
| 背景趋势 | 覆盖全卡宽高,CPU / GPU / 电池底边 0、顶边 100%;内存顶边为物理总量;速率采用 60% 高度零轴的上下双向投影;文字与控件覆盖其上,按卡片圆角裁切 |
| 逐核格子 | 每核四个 6×6 方块,间距 2,柱高 30;底部先填充,最后一格部分填充保留真实比例;核型短标签在柱上方 |
| 顶栏 / 底栏 | 32 / 26;操作可键盘访问 |
@@ -26,15 +26,16 @@
## 字体、颜色与层级
- 使用系统字体、现有品牌图像和 SF Symbols;数值使用等宽数字。
- 卡片标题 11 semibold,主数值 28 semibold,单位 12 medium;双指标网络主数值 16、单位 9,避免挤压。必要时主值最多缩至 75%,全文保留为辅助说明。
- 辅助指标 8–9;强调值 medium;悬浮提示 9。辅助内容使用紧凑左对齐信息行,低透明背景曲线可穿过文字区域,须保持可读。
- 卡片标题 11 semibold,主数值 28 semibold,单位 12 medium;双指标网络主数值 16、单位 10,避免挤压。必要时主值最多缩至 75%,全文保留为辅助说明。
- 主要辅助信息 10pt、行高 16pt,标签 secondary、数值 primary / medium;逐核紧凑短标签 9pt、行高 12pt。悬浮提示沿用 9pt。内存分类 / 存储读写和健康说明在宽度不足时按组换行;少数紧凑单行最低缩至 90%,避免回落到原 8pt。
- 主数值使用 primary,提高浅深色对比度;网络仅方向箭头着色。CPU 青绿(MetricCPU)、GPU 玫红(MetricGPU)、内存蓝(MemoryApplication)、电池绿(MetricBattery)、存储琥珀(MetricDisk)、下载蓝(MetricMemory)、上传琥珀(SeriesUpload)。所有颜色来自 Assets。
- 温度在标题右侧;CPU ≥90°C 使用红色和既有高温说明。内存压力沿用正常 / 警告 / 严重颜色和文字,不能仅靠颜色传达状态。
- 标题、主值和详情组成紧凑前景块,使用 PanelCard 同色 88% 不透明底板,圆角 8、向外延 4pt;底板不包含底部 Spacer,且不拦截控件与图表交互。图表继续整卡绘制,底板之外的线条 / 面积透明度、色彩和尺度不变;不使用模糊或渐变。
- 卡片采用 PanelCard、面板采用 PanelBackground 的浅深色资源。边框为 primary 浅色 2.5% / 深色 6%;静态轻阴影半径 4、纵偏移 1,不给文字或曲线单独加阴影。
## 曲线与悬浮
- 移除常驻图例、坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层、遮罩层或动画层。
- 不显示常驻图例、数值坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层、遮罩层或动画层。
- CPU 自下而上堆叠系统态 / 用户态;内存堆叠应用 / 联动 / 压缩,顶边为物理总量、空余为可用空间;GPU 堆叠占用 / 空闲至 100%,Renderer / Tiler 仅保留原始提示读数,不叠加为总占用。电池背景显示电量,功率在悬浮中单独注明 W,不能与电量共用未解释的尺度。存储和网络采用上下双向曲线:自顶向下 60% 为零轴(细线),向上读取 / 上传、向下写入 / 下载,两侧各有卡片高度 30% 的振幅,共用自动速率尺度,峰值不触及卡片顶边。
- 百分比固定 0–100%;内存固定当前物理总量;速率保留既有自动范围及延迟缩小策略,不为视觉任意改变振幅。
- 时间使用真实采样日期;有效 0 保留,nil / 非有限数值不补值。沿用既有缺失节点接续与显式断点 / 长空档策略。堆叠缺少任一必要分量时不构造部分总量;面积在匹配上下边界之间按每个连续段分别闭合,不能填过暂停空档。
+4 -4
View File
@@ -60,10 +60,10 @@ struct CPUCoreGrid: View {
Circle().fill(color(kinds[groups[group][0]])).frame(width: 3, height: 3)
if let kind = kinds[groups[group][0]] { label(kind, compact: true) }
else { Text("cpu.core") }
Text(verbatim: "\(groups[group].count)").foregroundStyle(.secondary)
Text(verbatim: "\(groups[group].count)").foregroundStyle(.primary)
}
.font(.system(size: 8, weight: .medium)).lineLimit(1).minimumScaleFactor(0.65)
.frame(height: 10)
.font(.system(size: 9, weight: .medium)).lineLimit(1).minimumScaleFactor(0.65)
.frame(height: 12)
CPUCoreGridLayout {
ForEach(groups[group], id: \.self) { index in core(index: index) }
}
@@ -79,7 +79,7 @@ struct CPUCoreGrid: View {
private func gridHeight(groups: [[Int]]) -> CGFloat {
let widths = Self.groupWidths(groups: groups, width: availableWidth)
let rows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.max() ?? 0
return 14 + CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing
return 16 + CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing
}
private func core(index: Int) -> some View {
+23 -13
View File
@@ -7,26 +7,36 @@ struct MemoryDetailsView: View {
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 3) {
ForEach(0..<3) { index in
if index > 0 { Text("·").foregroundStyle(.secondary) }
HStack(spacing: 2) {
Text(labels[index])
MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824))
ViewThatFits(in: .horizontal) {
classification(0..<3, unit: true).fixedSize(horizontal: true, vertical: true)
VStack(alignment: .leading, spacing: 4) {
classification(0..<2, unit: false)
classification(2..<3, unit: true)
}
.help(Text(MetricFormat.memory(values[index])))
}
Text(verbatim: "GiB")
}
.font(.system(size: 8)).foregroundStyle(.secondary)
.lineLimit(1).minimumScaleFactor(0.75)
HStack(spacing: 4) {
Text("memory.available").foregroundStyle(.secondary)
MetricText(value: MetricFormat.memory(memory.available))
}.font(.system(size: 9)).lineLimit(1)
MetricText(value: MetricFormat.memory(memory.available)).fontWeight(.medium)
}.frame(height: 16)
}
.font(.system(size: 10)).lineLimit(1)
.help(Text("memory.distributionHelp"))
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("memory.distribution"))
}
private func classification(_ indices: Range<Int>, unit: Bool) -> some View {
HStack(spacing: 4) {
ForEach(Array(indices), id: \.self) { index in
if index > indices.lowerBound { Text("·").foregroundStyle(.secondary) }
HStack(spacing: 3) {
Text(labels[index]).foregroundStyle(.secondary)
MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824))
.fontWeight(.medium).foregroundStyle(.primary)
}
.help(Text(MetricFormat.memory(values[index])))
}
if unit { Text(verbatim: "GiB").foregroundStyle(.secondary) }
}.frame(height: 16)
}
}
@@ -18,18 +18,18 @@ extension MenuPanelView {
HStack(spacing: 3) {
Text("network.totalShort").foregroundStyle(.secondary)
Image(systemName: "arrow.down").foregroundStyle(Color("MetricMemory"))
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }))
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received })).fontWeight(.medium)
Text("·").foregroundStyle(.secondary)
Image(systemName: "arrow.up").foregroundStyle(Color("SeriesUpload"))
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }))
}.font(.system(size: 8)).lineLimit(1).minimumScaleFactor(0.75)
VStack(spacing: 3) {
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent })).fontWeight(.medium)
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9).frame(height: 16)
VStack(spacing: 4) {
networkAddress("network.public", address: publicIPAddress)
networkAddress(
"network.local",
address: addressInterface?.addresses.first(where: { !$0.contains(":") }) ?? addressInterface?.addresses.first)
}
.font(.system(size: 9))
.font(.system(size: 10))
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("network.addresses"))
}
@@ -54,7 +54,7 @@ extension MenuPanelView {
func networkAddress(_ title: LocalizedStringKey, address: String?) -> some View {
HStack(spacing: 3) {
Text(title).foregroundStyle(.secondary)
Text(verbatim: address ?? "--").font(.system(size: 9, weight: .medium)).monospacedDigit().textSelection(.enabled)
Text(verbatim: address ?? "--").font(.system(size: 10, weight: .medium)).monospacedDigit().textSelection(.enabled)
.help(Text(verbatim: address ?? "--"))
.frame(maxWidth: .infinity, alignment: .leading)
if let address {
@@ -66,7 +66,7 @@ extension MenuPanelView {
}
.buttonStyle(.plain).accessibilityLabel(Text("panel.copy"))
}
}.frame(maxWidth: .infinity, alignment: .leading).lineLimit(1)
}.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16).lineLimit(1)
}
var networkStatusLabel: LocalizedStringKey {
switch snapshot.networkPath {
@@ -4,10 +4,10 @@ import SwiftUI
extension MenuPanelView {
func line(_ key: LocalizedStringKey, _ value: String) -> some View {
HStack(alignment: .firstTextBaseline, spacing: 4) {
Text(key).font(.system(size: 9)).foregroundStyle(.secondary)
Text(key).font(.system(size: 10)).foregroundStyle(.secondary)
Spacer(minLength: 6)
MetricText(value: value).font(.system(size: 9, weight: .medium))
}.frame(height: 12)
MetricText(value: value).font(.system(size: 10, weight: .medium))
}.frame(height: 16)
}
func inlineMetric(_ title: LocalizedStringKey, _ value: String) -> some View {
@@ -15,7 +15,7 @@ extension MenuPanelView {
Text(title).foregroundStyle(.secondary)
MetricText(value: value).fontWeight(.medium)
}
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.8)
.font(.system(size: 10)).lineLimit(1)
}
func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
@@ -45,7 +45,7 @@ extension MenuPanelView {
HStack(spacing: 5) {
inlineMetric("cpu.user", MetricFormat.percent(snapshot.cpu?.user))
inlineMetric("cpu.system", MetricFormat.percent(snapshot.cpu?.system))
}.frame(height: 12)
}.frame(height: 16)
if let cpu = snapshot.cpu {
CPUCoreGrid(
values: cpu.cores, kinds: CPUCoreTopology.cores,
@@ -75,9 +75,9 @@ extension MenuPanelView {
HStack(spacing: 5) {
if let count = snapshot.gpu?.coreCount {
Text(verbatim: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), count))
.foregroundStyle(.secondary)
.foregroundStyle(.primary)
}
}.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75).frame(height: 12)
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9).frame(height: 16)
let fans = displayedFans
if !fans.isEmpty {
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 5, alignment: .leading), count: min(2, fans.count)), spacing: 2) {
@@ -87,12 +87,12 @@ extension MenuPanelView {
? (fan.id == 0 ? Text("gpu.fanLeft") : Text("gpu.fanRight"))
: Text("gpu.fanNumber \(fan.id + 1)"), rpm: fan.rpm,
isActive: metrics.isPanelVisible && !metrics.isPaused && !metrics.isSystemSleeping && !metrics.isDisplaySleeping)
.frame(height: 12)
.frame(height: 16)
}
}
} else if snapshot.fans == nil {
Text("metric.waiting").font(.system(size: 9))
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 12)
Text("metric.waiting").font(.system(size: 10))
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16)
}
}
}
@@ -122,7 +122,7 @@ extension MenuPanelView {
MemoryDetailsView(memory: memory)
} else {
Text("metric.waiting").foregroundStyle(.secondary)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}
@@ -136,7 +136,7 @@ extension MenuPanelView {
} ?? "--",
headerAccessory: AnyView(Button { showVolumes.toggle() } label: {
HStack(spacing: 2) { Text("disk.localVolumes"); Image(systemName: "chevron.right").font(.system(size: 7)) }
}.font(.system(size: 9)).buttonStyle(.plain).help(Text("disk.viewDetails"))),
}.font(.system(size: 10)).buttonStyle(.plain).help(Text("disk.viewDetails"))),
chart: {
PanelTrendChart(
dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"),
@@ -159,7 +159,7 @@ extension MenuPanelView {
"\(MetricFormat.bytes(volume.capacity.available)) / \(MetricFormat.bytes(volume.capacity.total))")
}
}
Text("panel.apfsScope").font(.system(size: 9)).foregroundStyle(.secondary)
Text("panel.apfsScope").font(.system(size: 10)).foregroundStyle(.secondary)
}
}.padding(12).frame(width: 330)
.environment(\.locale, locale)
@@ -191,17 +191,17 @@ extension MenuPanelView {
}
) {
inlineMetric("battery.powerShort", MetricFormat.watts(snapshot.battery?.power))
.frame(height: 12)
.frame(height: 16)
if let battery = snapshot.battery {
batteryDetails(battery)
} else {
Text(snapshot.batteryState == .absent ? "panel.noBattery" : "panel.batteryFailed").foregroundStyle(.secondary)
.font(.system(size: 9)).frame(maxWidth: .infinity).frame(height: 32)
.font(.system(size: 10)).frame(maxWidth: .infinity).frame(height: 32)
}
}
}
private func batteryDetails(_ battery: BatteryMetrics) -> some View {
VStack(alignment: .leading, spacing: 3) {
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 8) {
inlineMetric("battery.healthShort", MetricFormat.percent(battery.health))
inlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--")
@@ -217,6 +217,6 @@ extension MenuPanelView {
}
}
}
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75)
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9)
}
}
+17 -9
View File
@@ -8,23 +8,31 @@ struct StorageDetailsView: View {
var body: some View {
VStack(alignment: .leading, spacing: 4) {
field("memory.available", value: MetricFormat.bytes(disk?.available))
HStack(spacing: 6) {
field("disk.read", value: MetricFormat.rate(io?.read))
field("disk.write", value: MetricFormat.rate(io?.written))
ViewThatFits(in: .horizontal) {
HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true)
VStack(alignment: .leading, spacing: 4) { read; write }
}
ViewThatFits(in: .horizontal) {
HStack(spacing: 4) {
field("disk.lifeShort", value: MetricFormat.percent(health?.remainingLife))
life
Text("·").foregroundStyle(.secondary)
field("disk.powerOnShort", value: health?.powerOnHours.map { "\($0) h" } ?? "--")
}.font(.system(size: 8))
powerOn
}.fixedSize(horizontal: true, vertical: true)
VStack(alignment: .leading, spacing: 4) { life; powerOn }
}
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75)
}
.font(.system(size: 10)).lineLimit(1)
}
private var read: some View { field("disk.read", value: MetricFormat.rate(io?.read)) }
private var write: some View { field("disk.write", value: MetricFormat.rate(io?.written)) }
private var life: some View { field("disk.lifeShort", value: MetricFormat.percent(health?.remainingLife)) }
private var powerOn: some View { field("disk.powerOnShort", value: health?.powerOnHours.map { "\($0) h" } ?? "--") }
private func field(_ title: LocalizedStringKey, value: String) -> some View {
HStack(spacing: 3) {
Text(title).foregroundStyle(.secondary).help(Text(title))
MetricText(value: value)
}
MetricText(value: value).fontWeight(.medium).foregroundStyle(.primary)
}.frame(height: 16)
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ struct FanSpeedIndicator: View {
MetricText(value: rpm.map { "\(Int($0.rounded())) RPM" } ?? "-- RPM")
.monospacedDigit().fontWeight(.medium)
}
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.7)
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9)
}
}
+28 -15
View File
@@ -27,20 +27,10 @@ struct ResourceCard<Chart: View, Content: View>: View {
ZStack(alignment: .bottomLeading) {
chart()
.frame(width: bounds.size.width, height: bounds.size.height)
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
header
HStack(alignment: .firstTextBaseline, spacing: 6) {
MetricHeadline(value: value, compact: secondaryValue != nil, color: valueColor ?? .primary)
if let secondaryValue {
MetricHeadline(value: secondaryValue, compact: true, color: secondaryValueColor ?? .primary)
}
}
.frame(height: ResourceCardMetrics.headlineHeight, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .leading)
content()
VStack(alignment: .leading, spacing: 0) {
foreground
Spacer(minLength: 0)
}
.font(.system(size: 9))
.padding(ResourceCardMetrics.padding)
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
}
@@ -69,6 +59,29 @@ struct ResourceCard<Chart: View, Content: View>: View {
}
}
private var foreground: some View {
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
header
HStack(alignment: .firstTextBaseline, spacing: 6) {
MetricHeadline(value: value, compact: secondaryValue != nil, color: valueColor ?? .primary)
if let secondaryValue {
MetricHeadline(value: secondaryValue, compact: true, color: secondaryValueColor ?? .primary)
}
}
.frame(height: ResourceCardMetrics.headlineHeight, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .leading)
content()
}
.font(.system(size: ResourceCardMetrics.auxiliarySize))
.fixedSize(horizontal: false, vertical: true)
.background {
RoundedRectangle(cornerRadius: 8)
.fill(Color("PanelCard").opacity(ResourceCardMetrics.textBackgroundOpacity))
.padding(-4)
.allowsHitTesting(false)
}
}
private var header: some View {
HStack(spacing: 6) {
Label {
@@ -80,14 +93,14 @@ struct ResourceCard<Chart: View, Content: View>: View {
Spacer(minLength: 4)
if let status {
Text(verbatim: status)
.font(.system(size: 9, weight: .medium))
.font(.system(size: 10, weight: .medium))
.foregroundStyle(statusWarning ? .red : .secondary)
.help(warningText ?? Text(verbatim: status))
.accessibilityLabel(warningText.map { Text("\(status) \($0)") } ?? Text(verbatim: status))
}
if let detail {
Text(verbatim: detail)
.font(.system(size: 8, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
.font(.system(size: 10, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
.padding(.horizontal, 5).frame(height: 14)
.background((detailColor ?? .primary).opacity(0.10), in: Capsule())
.lineLimit(1)
@@ -123,7 +136,7 @@ private struct MetricHeadline: View {
.font(.system(size: compact ? 16 : 28, weight: .semibold))
if parts.count > 1 {
Text(verbatim: String(parts[1]))
.font(.system(size: compact ? 9 : 12, weight: .medium))
.font(.system(size: compact ? 10 : 12, weight: .medium))
.foregroundStyle(Color.primary.opacity(0.8))
}
}
+4 -1
View File
@@ -6,8 +6,11 @@ nonisolated enum ResourceCardMetrics {
static let minimumHeight: CGFloat = 176
static let padding: CGFloat = 10
static let radius: CGFloat = 16
static let titleHeight: CGFloat = 14
static let titleHeight: CGFloat = 16
static let headlineHeight: CGFloat = 34
static let auxiliarySize: CGFloat = 10
static let auxiliaryHeight: CGFloat = 16
static let textBackgroundOpacity: Double = 0.88
static let gap: CGFloat = 4
static let tooltipMinimumY: CGFloat = 68
}
+36 -2
View File
@@ -36,6 +36,27 @@ import SwiftUI
precondition(detail.minY >= 0 && detail.maxY <= host.bounds.height && detail.width <= host.bounds.width - 20 + 0.5,
"Foreground details must overlay the full-height graph within card bounds, including narrow/localized cards")
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
let bitmap = host.bitmapImageRepForCachingDisplay(in: host.bounds)!
host.cacheDisplay(in: host.bounds, to: bitmap)
func sample(_ y: Double) -> [Double] {
let c = bitmap.colorAt(x: bitmap.pixelsWide / 2, y: Int(y * Double(bitmap.pixelsHigh) / 176))!.usingColorSpace(.deviceRGB)!
return [Double(c.redComponent), Double(c.greenComponent), Double(c.blueComponent)]
}
let base = sample(3)
let covered = zip(sample(80), base).reduce(0.0) { $0 + abs($1.0 - $1.1) }
let open = zip(sample(150), base).reduce(0.0) { $0 + abs($1.0 - $1.1) }
precondition(open > 0.02 && covered < open * 0.35,
"Only the foreground area should suppress chart color; the bottom Spacer must remain uncovered: \(covered), \(open)")
for kind in 0...1 {
host.rootView = AnyView(detailsFixture(kind: kind, probe: probe)
.environment(\.locale, Locale(identifier: language))
.environment(\.colorScheme, dark ? .dark : .light))
try? await Task.sleep(for: .milliseconds(60)); host.layoutSubtreeIfNeeded()
let details = topRect(probe.view!, in: host)
precondition(details.maxY <= host.bounds.height - 10 + 0.5 && details.width <= host.bounds.width - 20 + 0.5,
"Larger production details must fit the unchanged card: \(kind), \(language), \(width), \(details)")
}
}
}
}
@@ -43,7 +64,7 @@ import SwiftUI
try? await Task.sleep(for: .milliseconds(100))
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
window.orderOut(nil); window.contentView = nil; window.close()
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, full-height chart overlay, unmount")
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, full-height chart overlay, foreground-only color shielding, larger localized memory/storage detail bounds, unmount")
NSApp.terminate(nil)
}
NSApp.run()
@@ -54,13 +75,26 @@ import SwiftUI
return ResourceCard(title: "metric.network", symbol: "network", color: .blue,
value: dualMetric ? "↓ 999.9 TB/s" : "99%", secondaryValue: dualMetric ? "↑ 999.9 TB/s" : nil,
chart: {
PanelTrendChart(dates: dates, first: Array(repeating: 0.3, count: 60),
PanelTrendChart(dates: dates, first: Array(repeating: 0.8, count: 60),
second: Array(repeating: 0.6, count: 60), color: .blue)
}) {
DetailMarker(probe: probe).frame(height: 40)
}
}
@MainActor private static func detailsFixture(kind: Int, probe: DetailProbe) -> some View {
let memory = MemoryMetrics(total: 48 << 30, used: 26 << 30, wired: 3 << 30, compressed: 1 << 30,
swapUsed: 0, pressure: 1)
let details = kind == 0 ? AnyView(MemoryDetailsView(memory: memory))
: AnyView(StorageDetailsView(disk: .init(total: 1_000_000_000_000, available: 999_000_000_000),
health: .init(remainingLife: 0.98, powerOnHours: 99999),
io: .init(read: 999_900_000_000, written: 999_900_000_000)))
return ResourceCard(title: kind == 0 ? "metric.memory" : "metric.disk", symbol: "memorychip", color: .blue,
value: "26.0 / 48 GiB", chart: { Color.clear }) {
details.background(DetailMarker(probe: probe).allowsHitTesting(false))
}
}
@MainActor private static func descendants(_ view: NSView) -> [NSView] {
[view] + view.subviews.flatMap(descendants)
}
+1 -1
View File
@@ -70,7 +70,7 @@ CHECKS["ResourceCardChecks"] = [
"kymo/UI/Charts/ChartTooltipLayer.swift", "kymo/Core/Extensions/MetricFormat.swift",
]
CHECKS["ResourceCardChecks"] = list(dict.fromkeys(CORE + CHECKS["ResourceCardChecks"] + [
"kymo/Features/MenuBar/MemoryDetailsView.swift",
"kymo/Features/MenuBar/MemoryDetailsView.swift", "kymo/Features/MenuBar/StorageDetailsView.swift",
]))
for name in ("PanelLayoutChecks", "PanelWindowChecks"):