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
+13 -2
View File
@@ -20,6 +20,7 @@ final class NotesController: NSViewController, NSTextViewDelegate {
private let actions = ApplicationActionsController()
private let editor = NotesTextView()
private let status = NSTextField(labelWithString: "")
private var themeObservation: ThemeObservation?
private let noteTitle = NSTextField(labelWithString: "Untitled Note")
private let vimButton = NSButton(title: "Vim Off", target: nil, action: nil)
private let formatting = NSStackView()
@@ -185,6 +186,15 @@ final class NotesController: NSViewController, NSTextViewDelegate {
scroll.heightAnchor.constraint(greaterThanOrEqualToConstant: 80),
footer.heightAnchor.constraint(equalToConstant: 36),
])
themeObservation = ThemeObservation { [weak self] in
guard let self else { return }
self.noteTitle.textColor = ThemePalette.secondaryText
self.vimButton.contentTintColor = ThemePalette.secondaryText
self.status.textColor = ThemePalette.error
for case let button as NSButton in self.formatting.arrangedSubviews {
button.contentTintColor = ThemePalette.secondaryText
}
}
guard let store else {
editor.isEditable = false
for control in [browseButton, actionsButton] { control.isEnabled = false }
@@ -371,11 +381,12 @@ final class NotesController: NSViewController, NSTextViewDelegate {
alert.informativeText = "This permanently deletes the note and its embedded images. This cannot be undone."
alert.addButton(withTitle: "Cancel").keyEquivalent = "\u{1b}"
let delete = alert.addButton(withTitle: "Delete Note")
delete.contentTintColor = ThemePalette.error
let theme = ThemeObservation { [weak delete] in delete?.contentTintColor = ThemePalette.error }
delete.keyEquivalent = "\r"
alert.window.initialFirstResponder = delete
alert.window.defaultButtonCell = delete.cell as? NSButtonCell
alert.beginSheetModal(for: window) { [weak self] response in
alert.beginSheetModal(for: window) { [weak self, theme] response in
defer { withExtendedLifetime(theme) {} }
guard let self else { return }
defer { self.focusEditor() }
guard response == .alertSecondButtonReturn, self.selectedID == id,