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

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 2 месяцев назад
Родитель
Сommit
d06150a32a
1 измененных файлов с 18 добавлено и 2 удалено
  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 {
     private let savedJobsDocumentView = JobListingsDocumentView()
     private let savedJobsStack = NSStackView()
     private let settingsPageContainer = NSView()
-    private let themeControl = NSSegmentedControl(labels: ["System", "Light", "Dark"], trackingMode: .selectOne, target: nil, action: nil)
+    private let themeControl = NSSegmentedControl()
 
     private var currentSidebarItems: [SidebarItem] = []
     private var selectedSidebarIndex: Int = 0
@@ -1145,10 +1145,26 @@ final class DashboardView: NSView, NSTextFieldDelegate {
     }
 
     private func makeThemeControl() -> NSSegmentedControl {
+        themeControl.segmentCount = 3
+        themeControl.trackingMode = .selectOne
+        themeControl.setLabel("System", forSegment: 0)
+        themeControl.setLabel("Light", forSegment: 1)
+        themeControl.setLabel("Dark", forSegment: 2)
         themeControl.target = self
         themeControl.action = #selector(didChangeThemeSelection(_:))
-        themeControl.selectedSegment = 0
+        switch NSApp.appearance?.bestMatch(from: [.darkAqua, .aqua]) {
+        case .darkAqua:
+            themeControl.selectedSegment = 2
+        case .aqua:
+            themeControl.selectedSegment = 1
+        default:
+            themeControl.selectedSegment = 0
+        }
         themeControl.segmentStyle = .rounded
+        themeControl.segmentDistribution = .fillEqually
+        themeControl.setWidth(68, forSegment: 0)
+        themeControl.setWidth(68, forSegment: 1)
+        themeControl.setWidth(68, forSegment: 2)
         themeControl.controlSize = .large
         themeControl.font = .systemFont(ofSize: 13, weight: .semibold)
         themeControl.translatesAutoresizingMaskIntoConstraints = false