From 1d4afd97e137e8fcc17a4cefe5588ec558f7ead9 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 22 Sep 2025 21:22:54 +0200 Subject: [PATCH] feat: adjusted settings window to the new macOS design --- Kit/module/settings.swift | 16 ++++++++++++---- Stats/Views/AppSettings.swift | 2 +- Stats/Views/Dashboard.swift | 2 +- Stats/Views/Settings.swift | 7 +++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Kit/module/settings.swift b/Kit/module/settings.swift index 357c1aab..0ef52b78 100644 --- a/Kit/module/settings.swift +++ b/Kit/module/settings.swift @@ -73,7 +73,7 @@ open class Settings: NSStackView, Settings_p { self.distribution = .fill self.spacing = Constants.Settings.margin self.edgeInsets = NSEdgeInsets( - top: Constants.Settings.margin, + top: 0, left: Constants.Settings.margin, bottom: Constants.Settings.margin, right: Constants.Settings.margin @@ -312,13 +312,19 @@ private class WidgetSelectorView: NSStackView { private var background: NSVisualEffectView = { let view = NSVisualEffectView(frame: NSRect.zero) view.blendingMode = .withinWindow - view.material = .contentBackground + if #available(macOS 26.0, *) { + view.material = .titlebar + } else { + view.material = .contentBackground + } view.state = .active view.wantsLayer = true view.layer?.cornerRadius = 5 return view }() + private var separator: NSView? + fileprivate init(module: String, widgets: [SWidget], stateCallback: @escaping () -> Void) { self.module = module self.stateCallback = stateCallback @@ -366,8 +372,9 @@ private class WidgetSelectorView: NSStackView { let separator = NSView() separator.identifier = NSUserInterfaceItemIdentifier(rawValue: "separator") separator.wantsLayer = true - separator.layer?.backgroundColor = NSColor(red: 213/255, green: 213/255, blue: 213/255, alpha: 1).cgColor + separator.layer?.backgroundColor = NSColor.separatorColor.withAlphaComponent(isDarkMode ? 0.35 : 0.15).cgColor self.addArrangedSubview(separator) + self.separator = separator inactive.forEach { (widget: WidgetPreview) in self.addArrangedSubview(widget) @@ -379,7 +386,7 @@ private class WidgetSelectorView: NSStackView { NSLayoutConstraint.activate([ self.heightAnchor.constraint(equalToConstant: Constants.Widget.height + (Constants.Settings.margin*2)), separator.widthAnchor.constraint(equalToConstant: 1), - separator.heightAnchor.constraint(equalTo: self.heightAnchor, constant: -6) + separator.heightAnchor.constraint(equalTo: self.heightAnchor, constant: -18) ]) } @@ -389,6 +396,7 @@ private class WidgetSelectorView: NSStackView { override func updateLayer() { self.background.setFrameSize(self.frame.size) + self.separator?.layer?.backgroundColor = NSColor.separatorColor.withAlphaComponent(isDarkMode ? 0.35 : 0.15).cgColor } override func mouseUp(with event: NSEvent) { diff --git a/Stats/Views/AppSettings.swift b/Stats/Views/AppSettings.swift index 2c52bdb6..230666e3 100644 --- a/Stats/Views/AppSettings.swift +++ b/Stats/Views/AppSettings.swift @@ -65,7 +65,7 @@ class ApplicationSettings: NSStackView { let scrollView = ScrollableStackView(orientation: .vertical) scrollView.stackView.edgeInsets = NSEdgeInsets( - top: Constants.Settings.margin, + top: 0, left: Constants.Settings.margin, bottom: Constants.Settings.margin, right: Constants.Settings.margin diff --git a/Stats/Views/Dashboard.swift b/Stats/Views/Dashboard.swift index 7453b3f5..f310e08f 100644 --- a/Stats/Views/Dashboard.swift +++ b/Stats/Views/Dashboard.swift @@ -181,7 +181,7 @@ class Dashboard: NSStackView { let scrollView = ScrollableStackView(orientation: .vertical) scrollView.stackView.edgeInsets = NSEdgeInsets( - top: Constants.Settings.margin, + top: 0, left: Constants.Settings.margin, bottom: Constants.Settings.margin, right: Constants.Settings.margin diff --git a/Stats/Views/Settings.swift b/Stats/Views/Settings.swift index 03709bea..b670d408 100644 --- a/Stats/Views/Settings.swift +++ b/Stats/Views/Settings.swift @@ -71,7 +71,9 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate { self.toolbar = newToolbar self.contentViewController = sidebarViewController self.titlebarAppearsTransparent = true - self.backgroundColor = .clear + if #unavailable(macOS 26.0) { + self.backgroundColor = .clear + } self.positionCenter() self.setIsVisible(false) @@ -80,7 +82,6 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate { windowController.loadWindow() NSLayoutConstraint.activate([ - self.sidebarView.widthAnchor.constraint(equalToConstant: 180), self.mainView.widthAnchor.constraint(equalToConstant: 540), self.mainView.container.widthAnchor.constraint(equalToConstant: 540), self.mainView.container.topAnchor.constraint(equalTo: (self.contentLayoutGuide as! NSLayoutGuide).topAnchor), @@ -126,6 +127,7 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate { switchButton.state = .on switchButton.action = #selector(self.toggleEnable) switchButton.target = self + switchButton.controlSize = .small toggleBtn = switchButton } else { let button: NSButton = NSButton() @@ -143,6 +145,7 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate { let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier) toolbarItem.toolTip = localizedString("Toggle the module") toolbarItem.view = toggleBtn + toolbarItem.isBordered = false return toolbarItem default: