浏览代码

Fix Settings page not updating when Light theme is selected.

Tag settings UI for reliable appearance refresh and honor explicit light/dark mode in isDark.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 2 周之前
父节点
当前提交
de56ac43ec
共有 2 个文件被更改,包括 40 次插入19 次删除
  1. 8 1
      App for Indeed/Services/AppAppearanceManager.swift
  2. 32 18
      App for Indeed/Views/DashboardView.swift

+ 8 - 1
App for Indeed/Services/AppAppearanceManager.swift

@@ -55,7 +55,14 @@ final class AppAppearanceManager {
55 55
 
56 56
     /// Whether the app is currently rendering with a dark appearance (respects System mode).
57 57
     var isDark: Bool {
58
-        NSApp.effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua
58
+        switch mode {
59
+        case .light:
60
+            false
61
+        case .dark:
62
+            true
63
+        case .system:
64
+            NSApp.effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua
65
+        }
59 66
     }
60 67
 
61 68
     var mode: Mode {

+ 32 - 18
App for Indeed/Views/DashboardView.swift

@@ -19,6 +19,14 @@ private enum PremiumSheetLayout {
19 19
     static let overscanExtraTop: CGFloat = 0.5
20 20
 }
21 21
 
22
+private enum SettingsAppearanceID {
23
+    static let section = "dashboard.settings.section"
24
+    static let sectionHeader = "dashboard.settings.sectionHeader"
25
+    static let rowTitle = "dashboard.settings.rowTitle"
26
+    static let iconTile = "dashboard.settings.iconTile"
27
+    static let divider = "dashboard.settings.divider"
28
+}
29
+
22 30
 final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDelegate, NSSharingServiceDelegate {
23 31
     /// Indeed.com-inspired neutrals and brand blue; values follow light / dark / system appearance.
24 32
     private enum Theme {
@@ -292,27 +300,26 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
292 300
     }
293 301
 
294 302
     private func refreshSettingsPageAppearance(in root: NSView) {
295
-        for case let field as NSTextField in root.subviewsRecursive() where !field.isEditable {
296
-            switch field.font?.pointSize {
297
-            case 12, 14:
298
-                field.textColor = Theme.secondaryText
303
+        for view in root.subviewsRecursive() {
304
+            switch view.identifier?.rawValue {
305
+            case SettingsAppearanceID.section:
306
+                view.layer?.backgroundColor = Theme.settingsGroupBackground.cgColor
307
+                view.layer?.borderColor = Theme.border.cgColor
308
+            case SettingsAppearanceID.divider:
309
+                view.layer?.backgroundColor = Theme.settingsDivider.cgColor
310
+            case SettingsAppearanceID.iconTile:
311
+                view.layer?.backgroundColor = Theme.settingsIconBackground.cgColor
312
+                for case let icon as NSImageView in view.subviews {
313
+                    icon.contentTintColor = Theme.brandBlue
314
+                }
315
+            case SettingsAppearanceID.sectionHeader:
316
+                (view as? NSTextField)?.textColor = Theme.secondaryText
317
+            case SettingsAppearanceID.rowTitle:
318
+                (view as? NSTextField)?.textColor = Theme.primaryText
299 319
             default:
300 320
                 break
301 321
             }
302 322
         }
303
-        for case let stack as NSStackView in root.subviewsRecursive() where stack.orientation == .vertical && stack.layer?.cornerRadius == 14 {
304
-            stack.layer?.backgroundColor = Theme.settingsGroupBackground.cgColor
305
-            stack.layer?.borderColor = Theme.border.cgColor
306
-            for case let divider as NSView in stack.arrangedSubviews where divider.bounds.height <= 1.5 && divider.wantsLayer {
307
-                divider.layer?.backgroundColor = Theme.settingsDivider.cgColor
308
-            }
309
-        }
310
-        for case let tile as NSView in root.subviewsRecursive() where tile.layer?.cornerRadius == 9 && tile.bounds.width == 38 {
311
-            tile.layer?.backgroundColor = Theme.settingsIconBackground.cgColor
312
-            for case let icon as NSImageView in tile.subviews {
313
-                icon.contentTintColor = Theme.brandBlue
314
-            }
315
-        }
316 323
     }
317 324
 
318 325
     private func rebuildFeatureShortcutCards() {
@@ -1669,6 +1676,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1669 1676
         appearanceTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1670 1677
         appearanceTitle.textColor = Theme.secondaryText
1671 1678
         appearanceTitle.alignment = .left
1679
+        appearanceTitle.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.sectionHeader)
1672 1680
 
1673 1681
         let themeSegment = makeAppearanceModeSegment()
1674 1682
         appearanceModeSegment = themeSegment
@@ -1691,6 +1699,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1691 1699
         aboutTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1692 1700
         aboutTitle.textColor = Theme.secondaryText
1693 1701
         aboutTitle.alignment = .left
1702
+        aboutTitle.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.sectionHeader)
1694 1703
 
1695 1704
         let aboutSection = makeSettingsSection(rows: [
1696 1705
             makeSettingsRow(title: "Website", systemImage: "globe", accessory: nil, tapAction: #selector(didTapWebsite)),
@@ -1750,6 +1759,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1750 1759
         section.alignment = .leading
1751 1760
         section.translatesAutoresizingMaskIntoConstraints = false
1752 1761
         section.wantsLayer = true
1762
+        section.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.section)
1753 1763
         section.layer?.backgroundColor = Theme.settingsGroupBackground.cgColor
1754 1764
         section.layer?.cornerRadius = 14
1755 1765
         section.layer?.borderWidth = 1
@@ -1764,6 +1774,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1764 1774
                 let divider = NSView()
1765 1775
                 divider.translatesAutoresizingMaskIntoConstraints = false
1766 1776
                 divider.wantsLayer = true
1777
+                divider.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.divider)
1767 1778
                 divider.layer?.backgroundColor = Theme.settingsDivider.cgColor
1768 1779
                 section.addArrangedSubview(divider)
1769 1780
                 NSLayoutConstraint.activate([
@@ -1785,6 +1796,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1785 1796
         let iconTile = NSView()
1786 1797
         iconTile.translatesAutoresizingMaskIntoConstraints = false
1787 1798
         iconTile.wantsLayer = true
1799
+        iconTile.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.iconTile)
1788 1800
         iconTile.layer?.backgroundColor = Theme.settingsIconBackground.cgColor
1789 1801
         iconTile.layer?.cornerRadius = 9
1790 1802
 
@@ -1796,8 +1808,9 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1796 1808
 
1797 1809
         let titleLabel = NSTextField(labelWithString: title)
1798 1810
         titleLabel.font = .systemFont(ofSize: 14, weight: .medium)
1799
-        titleLabel.textColor = Theme.secondaryText
1811
+        titleLabel.textColor = Theme.primaryText
1800 1812
         titleLabel.alignment = .left
1813
+        titleLabel.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.rowTitle)
1801 1814
 
1802 1815
         let rowStack = NSStackView()
1803 1816
         rowStack.orientation = .horizontal
@@ -1840,6 +1853,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1840 1853
             rowButton.setButtonType(.momentaryChange)
1841 1854
             rowButton.focusRingType = .none
1842 1855
             rowButton.wantsLayer = true
1856
+            rowButton.appearance = NSApp.appearance
1843 1857
             rowButton.layer?.backgroundColor = .clear
1844 1858
             row.addSubview(rowButton)
1845 1859
             NSLayoutConstraint.activate([