From cc22c3c72934f0e41268b2563581fe1b2429d596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matoga?= Date: Fri, 30 Aug 2019 16:48:15 +0200 Subject: [PATCH] Change background color of the stack views when dark mode is enabled --- .../TCCProfileViewController.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/View Controllers/TCCProfileViewController.swift b/Source/View Controllers/TCCProfileViewController.swift index 9a41cc1..a90d1b1 100644 --- a/Source/View Controllers/TCCProfileViewController.swift +++ b/Source/View Controllers/TCCProfileViewController.swift @@ -234,12 +234,29 @@ class TCCProfileViewController: NSViewController { } private func setupStackViewsWithBackground(stackViews: [NSStackView]) { + let darkModeEnabled = isDarkModeEnabled() + for stackView in stackViews { stackView.wantsLayer = true - stackView.layer?.backgroundColor = NSColor(red: 0.955, green: 0.96, blue: 0.96, alpha: 1.0).cgColor + if darkModeEnabled { + stackView.layer?.backgroundColor = NSColor(red: 0.157, green: 0.165, blue: 0.173, alpha: 1.0).cgColor + } else { + stackView.layer?.backgroundColor = NSColor(red: 0.955, green: 0.96, blue: 0.96, alpha: 1.0).cgColor + } } } + private func isDarkModeEnabled() -> Bool { + var darkModeEnabled = false + if #available(OSX 10.14, *) { + if view.effectiveAppearance.name == .darkAqua { + darkModeEnabled = true + } + } + + return darkModeEnabled + } + private func setupDescriptions() { addressBookHelpButton.setHelpMessage(ProfilesDescriptions.addressBook.rawValue) photosHelpButton.setHelpMessage(ProfilesDescriptions.photos.rawValue)