fix: reload tint colors while running

This commit is contained in:
2026-10-22 16:07:22 +02:00
parent c48ef4c018
commit 1b171c7b52
18 changed files with 877 additions and 61 deletions
+12 -2
View File
@@ -3,7 +3,8 @@ import CoreText
@MainActor
final class ShortcutIndicator: NSStackView {
init(_ keys: String..., backgroundColor: NSColor? = nil, fontSize: CGFloat = 12, keySize: CGFloat = 18) {
private var themeObservation: ThemeObservation?
init(_ keys: String..., hasBackground: Bool = false, fontSize: CGFloat = 12, keySize: CGFloat = 18) {
super.init(frame: .zero)
orientation = .horizontal
alignment = .centerY
@@ -21,7 +22,7 @@ final class ShortcutIndicator: NSStackView {
badge.layer?.cornerRadius = 5
badge.layer?.borderWidth = 1
badge.layer?.borderColor = ThemePalette.secondaryText.withAlphaComponent(0.35).cgColor
badge.layer?.backgroundColor = backgroundColor?.cgColor
badge.layer?.backgroundColor = hasBackground ? ThemePalette.keyBackground.cgColor : nil
badge.setAccessibilityElement(false)
badge.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
@@ -30,6 +31,15 @@ final class ShortcutIndicator: NSStackView {
])
addArrangedSubview(badge)
}
themeObservation = ThemeObservation { [weak self] in
guard let self else { return }
for case let badge as NSTextField in self.arrangedSubviews {
badge.textColor = ThemePalette.secondaryText
badge.layer?.borderColor = ThemePalette.secondaryText.withAlphaComponent(0.35).cgColor
badge.layer?.backgroundColor = hasBackground ? ThemePalette.keyBackground.cgColor : nil
badge.needsDisplay = true
}
}
}
func setSingleKey(_ key: String) {