refactor: share footer action pill across launcher tools
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import AppKit
|
||||
|
||||
@MainActor
|
||||
final class ActionPill: NSView {
|
||||
init(primaryButton: NSButton, actionsButton: NSButton) {
|
||||
super.init(frame: .zero)
|
||||
wantsLayer = true
|
||||
layer?.cornerRadius = 18
|
||||
layer?.borderWidth = 0.5
|
||||
layer?.borderColor = SunsetPalette.accent.withAlphaComponent(0.35).cgColor
|
||||
layer?.backgroundColor = SunsetPalette.background.withAlphaComponent(0.25).cgColor
|
||||
for button in [primaryButton, actionsButton] {
|
||||
button.isBordered = false
|
||||
button.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
button.contentTintColor = SunsetPalette.text
|
||||
}
|
||||
primaryButton.keyEquivalent = "\r"
|
||||
primaryButton.keyEquivalentModifierMask = []
|
||||
actionsButton.title = "Actions"
|
||||
actionsButton.keyEquivalent = "k"
|
||||
actionsButton.keyEquivalentModifierMask = .command
|
||||
let returnKey = ShortcutIndicator("↵")
|
||||
let actionKeys = ShortcutIndicator("⌘", "K")
|
||||
for control in [primaryButton, returnKey, actionsButton, actionKeys] {
|
||||
control.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(control)
|
||||
}
|
||||
NSLayoutConstraint.activate([
|
||||
heightAnchor.constraint(equalToConstant: 36),
|
||||
primaryButton.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 14),
|
||||
primaryButton.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
returnKey.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 8),
|
||||
returnKey.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
actionsButton.leadingAnchor.constraint(equalTo: returnKey.trailingAnchor, constant: 14),
|
||||
actionsButton.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
actionKeys.leadingAnchor.constraint(equalTo: actionsButton.trailingAnchor, constant: 8),
|
||||
actionKeys.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
actionKeys.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -12),
|
||||
])
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("Conjure creates action pills programmatically") }
|
||||
}
|
||||
Reference in New Issue
Block a user