fix: reload tint colors while running
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user