Explorar el Código

Sync window background on theme toggle.

Update NSWindow background/contentView colors when switching light/dark mode to prevent corner bleed.

Made-with: Cursor
huzaifahayat12 hace 3 meses
padre
commit
786d611488
Se han modificado 1 ficheros con 30 adiciones y 12 borrados
  1. 30 12
      zoom_app/ViewController.swift

+ 30 - 12
zoom_app/ViewController.swift

@@ -382,14 +382,7 @@ class ViewController: NSViewController {
         super.viewDidAppear()
         if let window = view.window {
             window.setContentSize(NSSize(width: 1020, height: 690))
-            // Match the outer window background to the app background so rounded shell corners
-            // don't reveal a lighter window color in Dark Mode.
-            window.backgroundColor = appBackground
-            window.isOpaque = true
-            if let contentView = window.contentView {
-                contentView.wantsLayer = true
-                contentView.layer?.backgroundColor = appBackground.cgColor
-            }
+            applyWindowBackgroundForCurrentTheme(window)
             // Use full-size content view so custom top chrome sits in the titlebar region.
             window.titleVisibility = .hidden
             window.titlebarAppearsTransparent = true
@@ -1593,6 +1586,9 @@ class ViewController: NSViewController {
         palette = Palette(isDarkMode: enabled)
         NSApp.appearance = NSAppearance(named: enabled ? .darkAqua : .aqua)
         view.appearance = NSAppearance(named: enabled ? .darkAqua : .aqua)
+        if let window = view.window {
+            applyWindowBackgroundForCurrentTheme(window)
+        }
 
         if isUserLoggedIn() {
             let keepSelected = selectedHomeSidebarItem
@@ -1603,6 +1599,17 @@ class ViewController: NSViewController {
         }
     }
 
+    private func applyWindowBackgroundForCurrentTheme(_ window: NSWindow) {
+        // Keep the window's backing in sync with the app's current theme, otherwise rounded
+        // shell corners can briefly show the previous mode's lighter/darker color.
+        window.backgroundColor = appBackground
+        window.isOpaque = true
+        if let contentView = window.contentView {
+            contentView.wantsLayer = true
+            contentView.layer?.backgroundColor = appBackground.cgColor
+        }
+    }
+
     private func systemPrefersDarkMode() -> Bool {
         let global = UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain)
         let style = global?["AppleInterfaceStyle"] as? String
@@ -2795,6 +2802,7 @@ class ViewController: NSViewController {
         let title = selectedHomeSidebarItem
 
         homeWelcomeLabel?.stringValue = title
+        homeWelcomeLabel?.isHidden = isSettings
 
         let dashboardViews: [NSView?] = [
             homeTimeLabelView,
@@ -2908,7 +2916,9 @@ class ViewController: NSViewController {
         button.isBordered = false
         button.bezelStyle = .shadowlessSquare
         button.focusRingType = .none
-        button.contentTintColor = NSColor(calibratedWhite: 0.84, alpha: 1)
+        button.contentTintColor = palette.isDarkMode
+            ? NSColor(calibratedWhite: 0.84, alpha: 1)
+            : NSColor(calibratedWhite: 0.22, alpha: 1)
         if let toolTip {
             button.toolTip = toolTip
         }
@@ -2932,11 +2942,19 @@ class ViewController: NSViewController {
         button.bezelStyle = .shadowlessSquare
         button.focusRingType = .none
         button.wantsLayer = true
-        button.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.06).cgColor
+        button.layer?.backgroundColor = (palette.isDarkMode
+            ? NSColor.white.withAlphaComponent(0.06)
+            : NSColor.black.withAlphaComponent(0.06)
+        ).cgColor
         button.layer?.cornerRadius = 10
         button.layer?.borderWidth = 1
-        button.layer?.borderColor = NSColor.white.withAlphaComponent(0.08).cgColor
-        let tint = NSColor(calibratedWhite: 0.9, alpha: 1)
+        button.layer?.borderColor = (palette.isDarkMode
+            ? NSColor.white.withAlphaComponent(0.08)
+            : NSColor.black.withAlphaComponent(0.12)
+        ).cgColor
+        let tint = palette.isDarkMode
+            ? NSColor(calibratedWhite: 0.9, alpha: 1)
+            : NSColor(calibratedWhite: 0.18, alpha: 1)
         let font = NSFont.systemFont(ofSize: 11, weight: .semibold)
         button.contentTintColor = tint
         button.font = font