|
|
@@ -1149,6 +1149,10 @@ class ViewController: NSViewController {
|
|
|
stack.orientation = .vertical
|
|
|
stack.spacing = style == .home ? 12 : 16
|
|
|
stack.alignment = .centerX
|
|
|
+ stack.distribution = .fill
|
|
|
+ // Keep sidebar items pinned to the top; don't let extra height stretch/shift them.
|
|
|
+ stack.setContentHuggingPriority(.required, for: .vertical)
|
|
|
+ stack.setContentCompressionResistancePriority(.required, for: .vertical)
|
|
|
stack.translatesAutoresizingMaskIntoConstraints = false
|
|
|
sidebar.addSubview(stack)
|
|
|
|
|
|
@@ -1160,6 +1164,13 @@ class ViewController: NSViewController {
|
|
|
row.layer?.backgroundColor = selectedRow ? sidebarActiveBackground.withAlphaComponent(0.95).cgColor : NSColor.clear.cgColor
|
|
|
row.layer?.cornerRadius = style == .home ? 12 : 10
|
|
|
row.widthAnchor.constraint(equalToConstant: style == .home ? 68 : 70).isActive = true
|
|
|
+ // Prevent rows from stretching/collapsing when the window resizes.
|
|
|
+ row.setContentHuggingPriority(.required, for: .vertical)
|
|
|
+ row.setContentCompressionResistancePriority(.required, for: .vertical)
|
|
|
+ if style == .home {
|
|
|
+ // Must be tall enough for icon (26) + paddings + label without clipping.
|
|
|
+ row.heightAnchor.constraint(equalToConstant: 66).isActive = true
|
|
|
+ }
|
|
|
|
|
|
if style == .home {
|
|
|
let iconContainer = NSView()
|
|
|
@@ -1237,7 +1248,11 @@ class ViewController: NSViewController {
|
|
|
if style == .home {
|
|
|
let spacer = NSView()
|
|
|
spacer.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- spacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 12).isActive = true
|
|
|
+ // Keep sidebar icons at the same vertical positions even when the window grows.
|
|
|
+ // A flexible spacer will expand with height and push icons away from their default placement.
|
|
|
+ spacer.heightAnchor.constraint(equalToConstant: 12).isActive = true
|
|
|
+ spacer.setContentHuggingPriority(.required, for: .vertical)
|
|
|
+ spacer.setContentCompressionResistancePriority(.required, for: .vertical)
|
|
|
stack.addArrangedSubview(spacer)
|
|
|
|
|
|
let settingsBadge = NSView()
|
|
|
@@ -1274,6 +1289,7 @@ class ViewController: NSViewController {
|
|
|
stack.bottomAnchor.constraint(lessThanOrEqualTo: sidebar.bottomAnchor, constant: -18).isActive = true
|
|
|
} else {
|
|
|
stack.topAnchor.constraint(equalTo: sidebar.topAnchor, constant: 18).isActive = true
|
|
|
+ stack.bottomAnchor.constraint(lessThanOrEqualTo: sidebar.bottomAnchor, constant: -18).isActive = true
|
|
|
}
|
|
|
|
|
|
return sidebar
|