feat(menubar): 调整两排卡片布局并加入复合曲线与数值动效
This commit is contained in:
@@ -7,11 +7,11 @@ import AppKit
|
||||
NSAppearance(named: appearance)!.performAsCurrentDrawingAppearance {
|
||||
for name in ["PanelCard", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery"] {
|
||||
guard let color = NSColor(named: NSColor.Name(name), bundle: bundle)?.usingColorSpace(.sRGB) else { fatalError("Missing color: \(name)") }
|
||||
precondition(abs(color.alphaComponent - 1) < 0.001, "Transparent \(name)")
|
||||
precondition(abs(color.alphaComponent - (name == "PanelCard" ? 0.68 : 1)) < 0.005, "Unexpected alpha \(name)")
|
||||
if name == "MetricGPU" && appearance == .darkAqua { precondition(color.blueComponent > 0.99) }
|
||||
}
|
||||
}
|
||||
}
|
||||
print("PASS: compiled light/dark semantic colors exist, fully opaque, GPU blue component is normalized")
|
||||
print("PASS: compiled light/dark semantic colors exist, card translucent/semantic colors opaque, GPU blue component is normalized")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import Foundation
|
||||
|
||||
@main struct PanelCurveChecks {
|
||||
static func main() {
|
||||
let dates = (0..<60).map { Date(timeIntervalSinceReferenceDate: Double($0 * 2)) }
|
||||
precondition(PanelCurveGeometry.isAppend(from: Array(dates.prefix(2)), to: Array(dates.prefix(3))))
|
||||
precondition(PanelCurveGeometry.isAppend(from: dates, to: Array(dates.dropFirst()) + [dates.last!.addingTimeInterval(2)]))
|
||||
precondition(!PanelCurveGeometry.isAppend(from: dates, to: Array(dates.dropFirst()) + [dates.last!.addingTimeInterval(8)]))
|
||||
precondition(!PanelCurveGeometry.isAppend(from: dates, to: dates))
|
||||
let runs = PanelCurveGeometry.runs(dates: Array(dates.prefix(6)), values: [0, 0.5, nil, .nan, 0.8, 1])
|
||||
precondition(runs.count == 2 && runs[0].count == 2 && runs[1].count == 2)
|
||||
precondition(PanelCurveGeometry.runs(dates: [dates[0], dates[4]], values: [0.3, 0.5]).count == 2)
|
||||
precondition(PanelCurveGeometry.runs(dates: [dates[1], dates[0]], values: [0.3, 0.5]).count == 2)
|
||||
precondition(PanelCurveGeometry.runs(dates: dates, values: []).isEmpty)
|
||||
print("PASS: timestamp append/full history, pause/reset, missing/nonfinite data, short series and disconnected curves")
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,12 @@ import CoreGraphics
|
||||
precondition(visible.insetBy(dx: 16, dy: 16).contains(PanelLayout.constrainedFrame(frame, visible: visible)))
|
||||
}
|
||||
}
|
||||
for size in [CGSize(width: 1240, height: 820), CGSize(width: 1160, height: 810)] {
|
||||
let square = PanelLayout.resourceRowHeight(size: size)
|
||||
let wide = PanelLayout.firstRowWideCardWidth(size: size)
|
||||
precondition(square >= 220 && square <= 230)
|
||||
precondition(abs(2 * wide + square + 16 - (size.width - 20)) < 0.001)
|
||||
}
|
||||
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
|
||||
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
|
||||
let path: String? = index == 42 ? "/test/needle" : nil
|
||||
|
||||
+12
-1
@@ -134,4 +134,15 @@ swiftc -parse-as-library -module-cache-path /private/tmp/kymo-unified-cache \
|
||||
/private/tmp/kymo-panel-asset-checks /absolute/path/to/kymo.app
|
||||
```
|
||||
|
||||
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,防止整数色值被解释为 1/255。
|
||||
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,防止整数色值被解释为 1/255,并确认卡片半透明、指标色不透明。
|
||||
|
||||
复合图几何检查(真实时间追加、满历史平移、暂停断线、缺失/非有限值):
|
||||
|
||||
```bash
|
||||
swiftc -module-cache-path /private/tmp/kymo-check-cache \
|
||||
kymo/UI/Charts/PanelCurveGeometry.swift kymoTests/PanelCurveChecks.swift \
|
||||
-o /private/tmp/kymo-panel-curve-checks
|
||||
/private/tmp/kymo-panel-curve-checks
|
||||
```
|
||||
|
||||
该检查不证明悬浮事件投递或动画观感。
|
||||
|
||||
@@ -12,9 +12,14 @@ import Foundation
|
||||
snapshot.network = [NetworkInterfaceMetrics(name: "en0", received: 1, sent: 1, download: 12, upload: 8),
|
||||
NetworkInterfaceMetrics(name: "utun0", received: 1, sent: 1, download: 99, upload: 99)]
|
||||
precondition(snapshot.downloadRate == 12 && snapshot.uploadRate == 8)
|
||||
snapshot.cpu = CPUMetrics(usage: 0.6, user: 0.4, system: 0.2, cores: [])
|
||||
var history = MetricHistory()
|
||||
for _ in 0..<65 { history.append(snapshot) }
|
||||
precondition(history.samples.count == 60 && history.interfaces["0:en0"]?.count == 60)
|
||||
precondition(history.samples.last?.cpuUser == 0.4 && history.samples.last?.cpuSystem == 0.2)
|
||||
snapshot.cpu = nil
|
||||
history.append(snapshot)
|
||||
precondition(history.samples.last?.cpuUser == nil && history.samples.last?.cpuSystem == nil)
|
||||
snapshot.network = []
|
||||
history.append(snapshot)
|
||||
precondition(history.interfaces.isEmpty && snapshot.downloadRate == nil)
|
||||
|
||||
Reference in New Issue
Block a user