diff --git a/Sources/OpenLessApp/Settings/SettingsView.swift b/Sources/OpenLessApp/Settings/SettingsView.swift index 281b4573..aca9a748 100644 --- a/Sources/OpenLessApp/Settings/SettingsView.swift +++ b/Sources/OpenLessApp/Settings/SettingsView.swift @@ -51,10 +51,8 @@ struct SettingsView: View { } var body: some View { - HStack(spacing: 0) { + HStack(spacing: 18) { FixedSidebar(selection: $navigation.selection) - .padding(.leading, 18) - .padding(.vertical, 18) Group { switch navigation.selection { case .home: HomeTab() @@ -65,6 +63,7 @@ struct SettingsView: View { } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) } + .padding(18) .background(WindowCanvasBackground()) .frame(minWidth: 1040, minHeight: 700) } @@ -138,6 +137,7 @@ private struct FixedSidebar: View { .padding(.top, 0) .padding(.bottom, 12) .frame(width: 264) + .frame(maxHeight: .infinity, alignment: .top) .glassPanel(cornerRadius: 32) .onAppear { refresh() } .onReceive(NotificationCenter.default.publisher(for: .openLessHistoryChanged)) { _ in refresh() } diff --git a/Sources/OpenLessApp/Settings/SettingsWindowController.swift b/Sources/OpenLessApp/Settings/SettingsWindowController.swift index 9186274f..813d36c0 100644 --- a/Sources/OpenLessApp/Settings/SettingsWindowController.swift +++ b/Sources/OpenLessApp/Settings/SettingsWindowController.swift @@ -2,15 +2,17 @@ import AppKit import SwiftUI @MainActor -final class SettingsWindowController { +final class SettingsWindowController: NSObject, NSWindowDelegate { private var window: NSWindow? private let navigation = SettingsNavigationModel() func show(tab: OpenLessMainTab = .home) { + NSApp.setActivationPolicy(.regular) navigation.selection = tab if let window = window { window.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) + alignTrafficLights(in: window) return } let hosting = NSHostingController(rootView: SettingsView(navigation: navigation)) @@ -26,6 +28,7 @@ final class SettingsWindowController { win.tabbingMode = .disallowed win.center() win.isReleasedWhenClosed = false + win.delegate = self self.window = win win.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) @@ -35,6 +38,20 @@ final class SettingsWindowController { } } + func windowWillClose(_ notification: Notification) { + NSApp.setActivationPolicy(.accessory) + } + + func windowDidResize(_ notification: Notification) { + guard let window = notification.object as? NSWindow else { return } + alignTrafficLights(in: window) + } + + func windowDidBecomeKey(_ notification: Notification) { + guard let window = notification.object as? NSWindow else { return } + alignTrafficLights(in: window) + } + private func alignTrafficLights(in window: NSWindow) { let buttons: [NSButton?] = [ window.standardWindowButton(.closeButton),