Explorar el Código

Fix theme selector segments disappearing in Settings.

Build the theme control with explicit segment labels, widths, and selection mapping so System/Light/Dark remain visible and reflect the active appearance.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 hace 3 semanas
padre
commit
d06150a32a
Se han modificado 1 ficheros con 18 adiciones y 2 borrados
  1. 18 2
      App for Indeed/Views/DashboardView.swift

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

@@ -109,7 +109,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
109 109
     private let savedJobsDocumentView = JobListingsDocumentView()
110 110
     private let savedJobsStack = NSStackView()
111 111
     private let settingsPageContainer = NSView()
112
-    private let themeControl = NSSegmentedControl(labels: ["System", "Light", "Dark"], trackingMode: .selectOne, target: nil, action: nil)
112
+    private let themeControl = NSSegmentedControl()
113 113
 
114 114
     private var currentSidebarItems: [SidebarItem] = []
115 115
     private var selectedSidebarIndex: Int = 0
@@ -1145,10 +1145,26 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1145 1145
     }
1146 1146
 
1147 1147
     private func makeThemeControl() -> NSSegmentedControl {
1148
+        themeControl.segmentCount = 3
1149
+        themeControl.trackingMode = .selectOne
1150
+        themeControl.setLabel("System", forSegment: 0)
1151
+        themeControl.setLabel("Light", forSegment: 1)
1152
+        themeControl.setLabel("Dark", forSegment: 2)
1148 1153
         themeControl.target = self
1149 1154
         themeControl.action = #selector(didChangeThemeSelection(_:))
1150
-        themeControl.selectedSegment = 0
1155
+        switch NSApp.appearance?.bestMatch(from: [.darkAqua, .aqua]) {
1156
+        case .darkAqua:
1157
+            themeControl.selectedSegment = 2
1158
+        case .aqua:
1159
+            themeControl.selectedSegment = 1
1160
+        default:
1161
+            themeControl.selectedSegment = 0
1162
+        }
1151 1163
         themeControl.segmentStyle = .rounded
1164
+        themeControl.segmentDistribution = .fillEqually
1165
+        themeControl.setWidth(68, forSegment: 0)
1166
+        themeControl.setWidth(68, forSegment: 1)
1167
+        themeControl.setWidth(68, forSegment: 2)
1152 1168
         themeControl.controlSize = .large
1153 1169
         themeControl.font = .systemFont(ofSize: 13, weight: .semibold)
1154 1170
         themeControl.translatesAutoresizingMaskIntoConstraints = false