Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Magic Switch/View/MenuBar/DropdownContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ final class DropdownContentView: NSView {
stack.orientation = .vertical
stack.alignment = .leading
stack.spacing = 2
stack.edgeInsets = NSEdgeInsets(top: 6, left: Self.inset, bottom: 6, right: Self.inset)
stack.edgeInsets = NSEdgeInsets(top: 3, left: Self.inset, bottom: 2, right: Self.inset)
stack.translatesAutoresizingMaskIntoConstraints = false
addSubview(stack)
NSLayoutConstraint.activate([
Expand Down Expand Up @@ -175,12 +175,18 @@ final class DropdownContentView: NSView {
stack.addArrangedSubview(makeDivider())
}

// A hair more space above the Settings row than the default inter-row gap.
if let last = stack.arrangedSubviews.last {
stack.setCustomSpacing(stack.spacing + 1, after: last)
}
let settingsRow = makeActionRow(title: "Settings…") { [weak self] in
self?.dismissThen { self?.onOpenSettings() }
}
stack.addArrangedSubview(settingsRow)
// Sit Quit flush against Settings, like consecutive peripheral rows.
stack.setCustomSpacing(0, after: settingsRow)
stack.addArrangedSubview(
makeActionRow(symbol: "gearshape", title: "Settings…") { [weak self] in
self?.dismissThen { self?.onOpenSettings() }
})
stack.addArrangedSubview(
makeActionRow(symbol: "power", title: "Quit") { [weak self] in
makeActionRow(title: "Quit") { [weak self] in
self?.dismissThen { self?.onQuit() }
})

Expand Down Expand Up @@ -326,15 +332,14 @@ final class DropdownContentView: NSView {
}

private func makeActionRow(
symbol: String, title: String, onClick: @escaping () -> Void
title: String, onClick: @escaping () -> Void
) -> NSView {
let row = MenuRowControl(onClick: onClick)
let content = NSStackView()
content.orientation = .horizontal
content.distribution = .fill
content.spacing = 8
content.alignment = .centerY
content.addArrangedSubview(symbolView(symbol, color: .labelColor))
content.addArrangedSubview(textLabel(title, color: .labelColor))
content.addArrangedSubview(spacer())
return clickableRow(row, content: content)
Expand Down