fix: reload tint colors while running
This commit is contained in:
@@ -16,6 +16,8 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
private let status = NSTextField(wrappingLabelWithString: "Finding associated files…")
|
||||
private let remove = NSButton(title: "Uninstall application", target: nil, action: nil)
|
||||
private let back = NSButton(title: "Back", target: nil, action: nil)
|
||||
private var themeObservation: ThemeObservation?
|
||||
private var statusIsError = false
|
||||
private var candidates: [UninstallCandidate] = []
|
||||
private var visible: [UninstallCandidate] = []
|
||||
private var selected: Set<URL> = []
|
||||
@@ -176,6 +178,18 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
footer.bottomAnchor.constraint(equalTo: content.bottomAnchor, constant: -8),
|
||||
footer.heightAnchor.constraint(equalToConstant: 36)
|
||||
])
|
||||
themeObservation = ThemeObservation { [weak self, weak context, weak guidance, weak pill] in
|
||||
guard let self else { return }
|
||||
context?.textColor = ThemePalette.text
|
||||
guidance?.textColor = ThemePalette.secondaryText
|
||||
self.search.applyTheme()
|
||||
(self.search.currentEditor() as? NSTextView)?.insertionPointColor = ThemePalette.accent
|
||||
self.status.textColor = self.statusIsError ? ThemePalette.error : ThemePalette.secondaryText
|
||||
self.back.contentTintColor = ThemePalette.secondaryText
|
||||
self.remove.contentTintColor = ThemePalette.error
|
||||
pill?.layer?.borderColor = ThemePalette.accent.withAlphaComponent(0.35).cgColor
|
||||
pill?.layer?.backgroundColor = ThemePalette.background.withAlphaComponent(0.25).cgColor
|
||||
}
|
||||
}
|
||||
|
||||
func applyDiscoveryResult(_ result: Result<[UninstallCandidate], Error>, preservingSelection: Bool = false) {
|
||||
@@ -205,6 +219,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
|
||||
private func updateStatus() {
|
||||
status.textColor = ThemePalette.secondaryText
|
||||
statusIsError = false
|
||||
remove.isEnabled = false
|
||||
switch discoveryState {
|
||||
case .loading:
|
||||
@@ -212,6 +227,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
case .failed(let message):
|
||||
status.stringValue = message
|
||||
status.textColor = ThemePalette.error
|
||||
statusIsError = true
|
||||
case .ready:
|
||||
let chosen = candidates.filter { selected.contains($0.url) }
|
||||
let size = chosen.compactMap(\.size).reduce(Int64(0), +)
|
||||
@@ -260,7 +276,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
cell.toggle.isEnabled = candidate.isSelectable && !busy
|
||||
cell.toggle.setAccessibilityLabel("Select \(candidate.url.lastPathComponent)")
|
||||
cell.name.stringValue = candidate.url.lastPathComponent
|
||||
cell.name.textColor = candidate.isSelectable ? ThemePalette.text : ThemePalette.secondaryText
|
||||
cell.selectable = candidate.isSelectable
|
||||
let path = (candidate.url.deletingLastPathComponent().path as NSString).abbreviatingWithTildeInPath
|
||||
cell.detail.stringValue = candidate.reason.map { "\(path) · \($0)" } ?? path
|
||||
cell.size.stringValue = candidate.size.map { ByteCountFormatter.string(fromByteCount: $0, countStyle: .file) } ?? "—"
|
||||
@@ -319,6 +335,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
}
|
||||
do {
|
||||
status.textColor = ThemePalette.secondaryText
|
||||
statusIsError = false
|
||||
status.stringValue = "Waiting for application to quit…"
|
||||
for app in running where !app.isTerminated {
|
||||
guard app.terminate() else { throw ReviewError("\(app.localizedName ?? application.name) could not quit. No files were moved.") }
|
||||
@@ -369,6 +386,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate,
|
||||
if canRecover { alert.addButton(withTitle: "Retry recovery") }
|
||||
guard await alert.beginSheetModal(for: window) == .alertSecondButtonReturn, canRecover else { return }
|
||||
status.textColor = ThemePalette.secondaryText
|
||||
statusIsError = false
|
||||
status.stringValue = "Recovering pending uninstall…"
|
||||
let report = await uninstaller.recover()
|
||||
changed?()
|
||||
@@ -425,6 +443,14 @@ private final class UninstallFileCell: NSTableCellView {
|
||||
let detail = NSTextField(labelWithString: "")
|
||||
let size = NSTextField(labelWithString: "")
|
||||
let fileIcon: IconView
|
||||
private var themeObservation: ThemeObservation?
|
||||
var selectable = true { didSet { applyTheme() } }
|
||||
|
||||
private func applyTheme() {
|
||||
name.textColor = selectable ? ThemePalette.text : ThemePalette.secondaryText
|
||||
detail.textColor = ThemePalette.secondaryText
|
||||
size.textColor = ThemePalette.secondaryText
|
||||
}
|
||||
|
||||
init() {
|
||||
let font = NSFont.systemFont(ofSize: 14, weight: .medium)
|
||||
@@ -456,6 +482,7 @@ private final class UninstallFileCell: NSTableCellView {
|
||||
row.topAnchor.constraint(equalTo: topAnchor, constant: 4),
|
||||
row.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -4)
|
||||
])
|
||||
themeObservation = ThemeObservation { [weak self] in self?.applyTheme() }
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("Conjure creates uninstall rows programmatically") }
|
||||
|
||||
Reference in New Issue
Block a user