feat(menubar): 实现趋势面板外侧详情与三语外观设置

接入有界趋势、平滑滚动、菜单式外侧详情、底部操作与三语文案,装配独立外观设置和 Dock 生命周期。
合并跟随系统外观刷新、自选颜色入口与色块绘制修复,保留用户确认的配色联动、重启保存及滚动验收。
多场景视觉与长期资源验证边界仍记录于 docs。
This commit is contained in:
2026-10-30 00:45:34 +08:00
parent 631b412d15
commit 0c846a2127
31 changed files with 2033 additions and 42 deletions
@@ -0,0 +1,53 @@
import SwiftUI
import AppKit
/// A native hit target avoids Form/plain-Button hit-testing ambiguity on the swatch.
struct CustomColorWell: NSViewRepresentable {
let preferences: AppearancePreferences
let picker: CustomColorPicker
func makeNSView(context: Context) -> SwatchButton {
let button = SwatchButton()
button.setAccessibilityLabel(String(localized: "accent.custom"))
return button
}
func updateNSView(_ button: SwatchButton, context: Context) {
button.open = { picker.show(for: preferences) }
button.swatchColor = NSColor(srgbRed: preferences.red, green: preferences.green, blue: preferences.blue, alpha: 1)
}
func sizeThatFits(_ proposal: ProposedViewSize, nsView: SwatchButton, context: Context) -> CGSize? {
CGSize(width: 44, height: 26)
}
final class SwatchButton: NSButton {
var swatchColor = NSColor.systemBlue { didSet { needsDisplay = true } }
override var intrinsicContentSize: NSSize { NSSize(width: 44, height: 26) }
override func draw(_ dirtyRect: NSRect) {
// Draw the actual RGB color inside bounds; no scalable SF Symbol/cell image.
let shape = NSBezierPath(roundedRect: bounds.insetBy(dx: 4, dy: 4), xRadius: 4, yRadius: 4)
(isHighlighted ? swatchColor.withAlphaComponent(0.7) : swatchColor).setFill()
shape.fill()
NSColor.separatorColor.setStroke()
shape.lineWidth = 1
shape.stroke()
}
var open: () -> Void = {}
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
bezelStyle = .rounded
isBordered = false
wantsLayer = true
layer?.masksToBounds = true
title = ""
target = self
action = #selector(openPicker)
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
@objc func openPicker() { open() }
}
}