mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
- adjust new settings layout
This commit is contained in:
@@ -263,13 +263,15 @@ class ApplicationSettings: NSView {
|
||||
statsName.stringValue = "Stats"
|
||||
statsName.isSelectable = true
|
||||
|
||||
let versionNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
|
||||
let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
|
||||
|
||||
let statsVersion: NSTextField = TextView(frame: NSRect(x: 0, y: 0, width: leftPanel.frame.width, height: 16))
|
||||
statsVersion.alignment = .center
|
||||
statsVersion.font = NSFont.systemFont(ofSize: 12, weight: .regular)
|
||||
let versionNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
|
||||
statsVersion.stringValue = "\(LocalizedString("Version")) \(versionNumber)"
|
||||
statsVersion.isSelectable = true
|
||||
statsVersion.toolTip = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
|
||||
statsVersion.toolTip = "Build number: \(buildNumber)"
|
||||
|
||||
infoView.addSubview(statsName)
|
||||
infoView.addSubview(statsVersion)
|
||||
|
||||
@@ -33,9 +33,9 @@ class SettingsWindow: NSWindow, NSWindowDelegate {
|
||||
self.animationBehavior = .default
|
||||
self.collectionBehavior = .moveToActiveSpace
|
||||
self.titlebarAppearsTransparent = true
|
||||
self.appearance = NSAppearance(named: .vibrantDark)
|
||||
// self.center()
|
||||
self.setIsVisible(true)
|
||||
self.appearance = NSAppearance(named: .darkAqua)
|
||||
self.center()
|
||||
self.setIsVisible(false)
|
||||
|
||||
let windowController = NSWindowController()
|
||||
windowController.window = self
|
||||
@@ -155,10 +155,9 @@ private class SettingsView: NSView {
|
||||
self.mainView.layer?.cornerRadius = 3
|
||||
self.mainView.layer?.maskedCorners = [.layerMaxXMinYCorner]
|
||||
|
||||
sidebar.addSubview(self.menuView)
|
||||
sidebar.addSubview(self.navigationView)
|
||||
|
||||
self.addSubview(sidebar)
|
||||
self.addSubview(self.menuView)
|
||||
self.addSubview(self.navigationView)
|
||||
self.addSubview(self.mainView)
|
||||
|
||||
self.openMenu("Stats")
|
||||
@@ -299,12 +298,12 @@ private class MenuView: NSView {
|
||||
}
|
||||
imageView.frame = NSRect(x: 8, y: (self.height - 18)/2, width: 18, height: 18)
|
||||
imageView.wantsLayer = true
|
||||
imageView.contentTintColor = .secondaryLabelColor
|
||||
imageView.contentTintColor = .labelColor
|
||||
|
||||
let titleView = TextView(frame: NSMakeRect(34, (self.height - 16)/2, 100, 17))
|
||||
let titleView = TextView(frame: NSMakeRect(34, (self.height - 16)/2, 100, 16))
|
||||
titleView.alignment = .natural
|
||||
titleView.textColor = .labelColor
|
||||
titleView.font = NSFont.systemFont(ofSize: 14, weight: .regular)
|
||||
titleView.font = NSFont.systemFont(ofSize: 13, weight: .regular)
|
||||
titleView.stringValue = title
|
||||
|
||||
self.addSubview(imageView)
|
||||
@@ -322,17 +321,14 @@ private class MenuView: NSView {
|
||||
self.activate()
|
||||
}
|
||||
|
||||
public func activate() {
|
||||
NotificationCenter.default.post(name: .openSettingsView, object: nil, userInfo: ["module": self.title])
|
||||
self.layer?.backgroundColor = .init(gray: 0.1, alpha: 0.4)
|
||||
self.active = true
|
||||
}
|
||||
|
||||
public func reset() {
|
||||
self.imageView?.contentTintColor = .secondaryLabelColor
|
||||
self.layer?.backgroundColor = .clear
|
||||
self.active = false
|
||||
}
|
||||
|
||||
public func activate() {
|
||||
NotificationCenter.default.post(name: .openSettingsView, object: nil, userInfo: ["module": self.title])
|
||||
|
||||
self.imageView?.contentTintColor = .labelColor
|
||||
self.layer?.backgroundColor = .init(gray: 0.1, alpha: 0.5)
|
||||
self.active = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class UpdateWindow: NSWindow, NSWindowDelegate {
|
||||
self.viewController.view.frame.width,
|
||||
self.viewController.view.frame.height
|
||||
),
|
||||
styleMask: [.closable, .titled],
|
||||
styleMask: [.closable, .titled, .fullSizeContentView],
|
||||
backing: .buffered,
|
||||
defer: true
|
||||
)
|
||||
@@ -57,7 +57,7 @@ private class UpdateViewController: NSViewController {
|
||||
private var update: UpdateView
|
||||
|
||||
public init() {
|
||||
self.update = UpdateView(frame: NSRect(x: 0, y: 0, width: 280, height: 150))
|
||||
self.update = UpdateView(frame: NSRect(x: 0, y: 0, width: 280, height: 176))
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.view = self.update
|
||||
}
|
||||
@@ -84,6 +84,13 @@ private class UpdateView: NSView {
|
||||
override init(frame: NSRect) {
|
||||
super.init(frame: CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.width, height: frame.height))
|
||||
self.wantsLayer = true
|
||||
|
||||
let sidebar = NSVisualEffectView(frame: NSMakeRect(0, 0, self.frame.width, self.frame.height))
|
||||
sidebar.material = .sidebar
|
||||
sidebar.blendingMode = .behindWindow
|
||||
sidebar.state = .active
|
||||
|
||||
self.addSubview(sidebar)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -92,10 +99,10 @@ private class UpdateView: NSView {
|
||||
|
||||
public func newVersion(_ version: version_s) {
|
||||
self.version = version
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20))
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20 - 26))
|
||||
|
||||
let title: NSTextField = TextView(frame: NSRect(x: 0, y: view.frame.height - 20, width: view.frame.width, height: 18))
|
||||
title.font = NSFont.systemFont(ofSize: 14, weight: .semibold)
|
||||
title.font = NSFont.systemFont(ofSize: 14, weight: .medium)
|
||||
title.alignment = .center
|
||||
title.stringValue = LocalizedString("New version available")
|
||||
|
||||
@@ -140,10 +147,10 @@ private class UpdateView: NSView {
|
||||
}
|
||||
|
||||
public func noUpdates() {
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20))
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20 - 26))
|
||||
|
||||
let title: NSTextField = TextView(frame: NSRect(x: 0, y: ((view.frame.height - 18)/2)+20, width: view.frame.width, height: 18))
|
||||
title.font = NSFont.systemFont(ofSize: 14, weight: .regular)
|
||||
title.font = NSFont.systemFont(ofSize: 14, weight: .light)
|
||||
title.alignment = .center
|
||||
title.stringValue = LocalizedString("The latest version of Stats installed")
|
||||
|
||||
@@ -159,7 +166,7 @@ private class UpdateView: NSView {
|
||||
}
|
||||
|
||||
public func clear() {
|
||||
self.subviews.forEach{ $0.removeFromSuperview() }
|
||||
self.subviews.filter{ !($0 is NSVisualEffectView) }.forEach{ $0.removeFromSuperview() }
|
||||
}
|
||||
|
||||
@objc private func download(_ sender: Any) {
|
||||
@@ -169,7 +176,7 @@ private class UpdateView: NSView {
|
||||
|
||||
self.clear()
|
||||
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20))
|
||||
let view: NSView = NSView(frame: NSRect(x: 10, y: 10, width: self.frame.width - 20, height: self.frame.height - 20 - 26))
|
||||
|
||||
let title: NSTextField = TextView(frame: NSRect(x: 0, y: view.frame.height - 28, width: view.frame.width, height: 18))
|
||||
title.font = NSFont.systemFont(ofSize: 14, weight: .semibold)
|
||||
|
||||
Reference in New Issue
Block a user