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
@@ -4,6 +4,8 @@ import AppKit
final class TranslationSettingsController: NSViewController {
private let keyField = NSSecureTextField()
private let status = NSTextField(wrappingLabelWithString: "")
private var statusIsError = false
private var themeObservation: ThemeObservation?
private let credentials: TranslationController.Credentials
init(credentials: TranslationController.Credentials = .keychain) {
@@ -55,6 +57,14 @@ final class TranslationSettingsController: NSViewController {
for label in [status, myMemory, openAI] {
label.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true
}
themeObservation = ThemeObservation { [weak self] in
save.contentTintColor = ThemePalette.accent
forget.contentTintColor = ThemePalette.accent
myMemory.textColor = ThemePalette.secondaryText
openAI.textColor = ThemePalette.secondaryText
guard let self else { return }
self.status.textColor = self.statusIsError ? ThemePalette.error : ThemePalette.secondaryText
}
do {
setStatus(try credentials.load() == nil ? "No OpenAI API key saved." : "OpenAI API key saved in Keychain.")
} catch { setStatus(error.localizedDescription, isError: true) }
@@ -84,6 +94,7 @@ final class TranslationSettingsController: NSViewController {
}
private func setStatus(_ message: String, isError: Bool = false) {
statusIsError = isError
status.stringValue = message
status.textColor = isError ? ThemePalette.error : ThemePalette.secondaryText
}