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.distribution = .fill
|
||||||
self.spacing = Constants.Settings.margin
|
self.spacing = Constants.Settings.margin
|
||||||
self.edgeInsets = NSEdgeInsets(
|
self.edgeInsets = NSEdgeInsets(
|
||||||
top: Constants.Settings.margin,
|
top: 0,
|
||||||
left: Constants.Settings.margin,
|
left: Constants.Settings.margin,
|
||||||
bottom: Constants.Settings.margin,
|
bottom: Constants.Settings.margin,
|
||||||
right: Constants.Settings.margin
|
right: Constants.Settings.margin
|
||||||
@@ -312,13 +312,19 @@ private class WidgetSelectorView: NSStackView {
|
|||||||
private var background: NSVisualEffectView = {
|
private var background: NSVisualEffectView = {
|
||||||
let view = NSVisualEffectView(frame: NSRect.zero)
|
let view = NSVisualEffectView(frame: NSRect.zero)
|
||||||
view.blendingMode = .withinWindow
|
view.blendingMode = .withinWindow
|
||||||
view.material = .contentBackground
|
if #available(macOS 26.0, *) {
|
||||||
|
view.material = .titlebar
|
||||||
|
} else {
|
||||||
|
view.material = .contentBackground
|
||||||
|
}
|
||||||
view.state = .active
|
view.state = .active
|
||||||
view.wantsLayer = true
|
view.wantsLayer = true
|
||||||
view.layer?.cornerRadius = 5
|
view.layer?.cornerRadius = 5
|
||||||
return view
|
return view
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
private var separator: NSView?
|
||||||
|
|
||||||
fileprivate init(module: String, widgets: [SWidget], stateCallback: @escaping () -> Void) {
|
fileprivate init(module: String, widgets: [SWidget], stateCallback: @escaping () -> Void) {
|
||||||
self.module = module
|
self.module = module
|
||||||
self.stateCallback = stateCallback
|
self.stateCallback = stateCallback
|
||||||
@@ -366,8 +372,9 @@ private class WidgetSelectorView: NSStackView {
|
|||||||
let separator = NSView()
|
let separator = NSView()
|
||||||
separator.identifier = NSUserInterfaceItemIdentifier(rawValue: "separator")
|
separator.identifier = NSUserInterfaceItemIdentifier(rawValue: "separator")
|
||||||
separator.wantsLayer = true
|
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.addArrangedSubview(separator)
|
||||||
|
self.separator = separator
|
||||||
|
|
||||||
inactive.forEach { (widget: WidgetPreview) in
|
inactive.forEach { (widget: WidgetPreview) in
|
||||||
self.addArrangedSubview(widget)
|
self.addArrangedSubview(widget)
|
||||||
@@ -379,7 +386,7 @@ private class WidgetSelectorView: NSStackView {
|
|||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
self.heightAnchor.constraint(equalToConstant: Constants.Widget.height + (Constants.Settings.margin*2)),
|
self.heightAnchor.constraint(equalToConstant: Constants.Widget.height + (Constants.Settings.margin*2)),
|
||||||
separator.widthAnchor.constraint(equalToConstant: 1),
|
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() {
|
override func updateLayer() {
|
||||||
self.background.setFrameSize(self.frame.size)
|
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) {
|
override func mouseUp(with event: NSEvent) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ApplicationSettings: NSStackView {
|
|||||||
|
|
||||||
let scrollView = ScrollableStackView(orientation: .vertical)
|
let scrollView = ScrollableStackView(orientation: .vertical)
|
||||||
scrollView.stackView.edgeInsets = NSEdgeInsets(
|
scrollView.stackView.edgeInsets = NSEdgeInsets(
|
||||||
top: Constants.Settings.margin,
|
top: 0,
|
||||||
left: Constants.Settings.margin,
|
left: Constants.Settings.margin,
|
||||||
bottom: Constants.Settings.margin,
|
bottom: Constants.Settings.margin,
|
||||||
right: Constants.Settings.margin
|
right: Constants.Settings.margin
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class Dashboard: NSStackView {
|
|||||||
|
|
||||||
let scrollView = ScrollableStackView(orientation: .vertical)
|
let scrollView = ScrollableStackView(orientation: .vertical)
|
||||||
scrollView.stackView.edgeInsets = NSEdgeInsets(
|
scrollView.stackView.edgeInsets = NSEdgeInsets(
|
||||||
top: Constants.Settings.margin,
|
top: 0,
|
||||||
left: Constants.Settings.margin,
|
left: Constants.Settings.margin,
|
||||||
bottom: Constants.Settings.margin,
|
bottom: Constants.Settings.margin,
|
||||||
right: Constants.Settings.margin
|
right: Constants.Settings.margin
|
||||||
|
|||||||
@@ -71,7 +71,9 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate {
|
|||||||
self.toolbar = newToolbar
|
self.toolbar = newToolbar
|
||||||
self.contentViewController = sidebarViewController
|
self.contentViewController = sidebarViewController
|
||||||
self.titlebarAppearsTransparent = true
|
self.titlebarAppearsTransparent = true
|
||||||
self.backgroundColor = .clear
|
if #unavailable(macOS 26.0) {
|
||||||
|
self.backgroundColor = .clear
|
||||||
|
}
|
||||||
self.positionCenter()
|
self.positionCenter()
|
||||||
self.setIsVisible(false)
|
self.setIsVisible(false)
|
||||||
|
|
||||||
@@ -80,7 +82,6 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate {
|
|||||||
windowController.loadWindow()
|
windowController.loadWindow()
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
self.sidebarView.widthAnchor.constraint(equalToConstant: 180),
|
|
||||||
self.mainView.widthAnchor.constraint(equalToConstant: 540),
|
self.mainView.widthAnchor.constraint(equalToConstant: 540),
|
||||||
self.mainView.container.widthAnchor.constraint(equalToConstant: 540),
|
self.mainView.container.widthAnchor.constraint(equalToConstant: 540),
|
||||||
self.mainView.container.topAnchor.constraint(equalTo: (self.contentLayoutGuide as! NSLayoutGuide).topAnchor),
|
self.mainView.container.topAnchor.constraint(equalTo: (self.contentLayoutGuide as! NSLayoutGuide).topAnchor),
|
||||||
@@ -126,6 +127,7 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate {
|
|||||||
switchButton.state = .on
|
switchButton.state = .on
|
||||||
switchButton.action = #selector(self.toggleEnable)
|
switchButton.action = #selector(self.toggleEnable)
|
||||||
switchButton.target = self
|
switchButton.target = self
|
||||||
|
switchButton.controlSize = .small
|
||||||
toggleBtn = switchButton
|
toggleBtn = switchButton
|
||||||
} else {
|
} else {
|
||||||
let button: NSButton = NSButton()
|
let button: NSButton = NSButton()
|
||||||
@@ -143,6 +145,7 @@ class SettingsWindow: NSWindow, NSWindowDelegate, NSToolbarDelegate {
|
|||||||
let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier)
|
let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier)
|
||||||
toolbarItem.toolTip = localizedString("Toggle the module")
|
toolbarItem.toolTip = localizedString("Toggle the module")
|
||||||
toolbarItem.view = toggleBtn
|
toolbarItem.view = toggleBtn
|
||||||
|
toolbarItem.isBordered = false
|
||||||
|
|
||||||
return toolbarItem
|
return toolbarItem
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user