mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: adjusted settings window to the new macOS design
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user