Просмотр исходного кода

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
Родитель
Сommit
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
     /// Whether the app is currently rendering with a dark appearance (respects System mode).
56
     /// Whether the app is currently rendering with a dark appearance (respects System mode).
57
     var isDark: Bool {
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
     var mode: Mode {
68
     var mode: Mode {

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

@@ -19,6 +19,14 @@ private enum PremiumSheetLayout {
19
     static let overscanExtraTop: CGFloat = 0.5
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
 final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDelegate, NSSharingServiceDelegate {
30
 final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDelegate, NSSharingServiceDelegate {
23
     /// Indeed.com-inspired neutrals and brand blue; values follow light / dark / system appearance.
31
     /// Indeed.com-inspired neutrals and brand blue; values follow light / dark / system appearance.
24
     private enum Theme {
32
     private enum Theme {
@@ -292,27 +300,26 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
292
     }
300
     }
293
 
301
 
294
     private func refreshSettingsPageAppearance(in root: NSView) {
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
             default:
319
             default:
300
                 break
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
     private func rebuildFeatureShortcutCards() {
325
     private func rebuildFeatureShortcutCards() {
@@ -1669,6 +1676,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1669
         appearanceTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1676
         appearanceTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1670
         appearanceTitle.textColor = Theme.secondaryText
1677
         appearanceTitle.textColor = Theme.secondaryText
1671
         appearanceTitle.alignment = .left
1678
         appearanceTitle.alignment = .left
1679
+        appearanceTitle.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.sectionHeader)
1672
 
1680
 
1673
         let themeSegment = makeAppearanceModeSegment()
1681
         let themeSegment = makeAppearanceModeSegment()
1674
         appearanceModeSegment = themeSegment
1682
         appearanceModeSegment = themeSegment
@@ -1691,6 +1699,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1691
         aboutTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1699
         aboutTitle.font = .systemFont(ofSize: 12, weight: .semibold)
1692
         aboutTitle.textColor = Theme.secondaryText
1700
         aboutTitle.textColor = Theme.secondaryText
1693
         aboutTitle.alignment = .left
1701
         aboutTitle.alignment = .left
1702
+        aboutTitle.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.sectionHeader)
1694
 
1703
 
1695
         let aboutSection = makeSettingsSection(rows: [
1704
         let aboutSection = makeSettingsSection(rows: [
1696
             makeSettingsRow(title: "Website", systemImage: "globe", accessory: nil, tapAction: #selector(didTapWebsite)),
1705
             makeSettingsRow(title: "Website", systemImage: "globe", accessory: nil, tapAction: #selector(didTapWebsite)),
@@ -1750,6 +1759,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1750
         section.alignment = .leading
1759
         section.alignment = .leading
1751
         section.translatesAutoresizingMaskIntoConstraints = false
1760
         section.translatesAutoresizingMaskIntoConstraints = false
1752
         section.wantsLayer = true
1761
         section.wantsLayer = true
1762
+        section.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.section)
1753
         section.layer?.backgroundColor = Theme.settingsGroupBackground.cgColor
1763
         section.layer?.backgroundColor = Theme.settingsGroupBackground.cgColor
1754
         section.layer?.cornerRadius = 14
1764
         section.layer?.cornerRadius = 14
1755
         section.layer?.borderWidth = 1
1765
         section.layer?.borderWidth = 1
@@ -1764,6 +1774,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1764
                 let divider = NSView()
1774
                 let divider = NSView()
1765
                 divider.translatesAutoresizingMaskIntoConstraints = false
1775
                 divider.translatesAutoresizingMaskIntoConstraints = false
1766
                 divider.wantsLayer = true
1776
                 divider.wantsLayer = true
1777
+                divider.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.divider)
1767
                 divider.layer?.backgroundColor = Theme.settingsDivider.cgColor
1778
                 divider.layer?.backgroundColor = Theme.settingsDivider.cgColor
1768
                 section.addArrangedSubview(divider)
1779
                 section.addArrangedSubview(divider)
1769
                 NSLayoutConstraint.activate([
1780
                 NSLayoutConstraint.activate([
@@ -1785,6 +1796,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1785
         let iconTile = NSView()
1796
         let iconTile = NSView()
1786
         iconTile.translatesAutoresizingMaskIntoConstraints = false
1797
         iconTile.translatesAutoresizingMaskIntoConstraints = false
1787
         iconTile.wantsLayer = true
1798
         iconTile.wantsLayer = true
1799
+        iconTile.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.iconTile)
1788
         iconTile.layer?.backgroundColor = Theme.settingsIconBackground.cgColor
1800
         iconTile.layer?.backgroundColor = Theme.settingsIconBackground.cgColor
1789
         iconTile.layer?.cornerRadius = 9
1801
         iconTile.layer?.cornerRadius = 9
1790
 
1802
 
@@ -1796,8 +1808,9 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1796
 
1808
 
1797
         let titleLabel = NSTextField(labelWithString: title)
1809
         let titleLabel = NSTextField(labelWithString: title)
1798
         titleLabel.font = .systemFont(ofSize: 14, weight: .medium)
1810
         titleLabel.font = .systemFont(ofSize: 14, weight: .medium)
1799
-        titleLabel.textColor = Theme.secondaryText
1811
+        titleLabel.textColor = Theme.primaryText
1800
         titleLabel.alignment = .left
1812
         titleLabel.alignment = .left
1813
+        titleLabel.identifier = NSUserInterfaceItemIdentifier(SettingsAppearanceID.rowTitle)
1801
 
1814
 
1802
         let rowStack = NSStackView()
1815
         let rowStack = NSStackView()
1803
         rowStack.orientation = .horizontal
1816
         rowStack.orientation = .horizontal
@@ -1840,6 +1853,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
1840
             rowButton.setButtonType(.momentaryChange)
1853
             rowButton.setButtonType(.momentaryChange)
1841
             rowButton.focusRingType = .none
1854
             rowButton.focusRingType = .none
1842
             rowButton.wantsLayer = true
1855
             rowButton.wantsLayer = true
1856
+            rowButton.appearance = NSApp.appearance
1843
             rowButton.layer?.backgroundColor = .clear
1857
             rowButton.layer?.backgroundColor = .clear
1844
             row.addSubview(rowButton)
1858
             row.addSubview(rowButton)
1845
             NSLayoutConstraint.activate([
1859
             NSLayoutConstraint.activate([