|
|
@@ -31,7 +31,7 @@ final class ProfilesListPageView: NSView {
|
|
|
private let documentView = ProfilesListDocumentView()
|
|
|
private let contentStack = NSStackView()
|
|
|
private let emptyStateLabel = NSTextField(wrappingLabelWithString: "")
|
|
|
- private let addButton = ProfilesPrimaryButton(title: "Add new profile →", target: nil, action: nil)
|
|
|
+ private let addButton = ProfilesPrimaryButton(title: "Add new profile", showsTrailingArrow: true, target: nil, action: nil)
|
|
|
|
|
|
override var userInterfaceLayoutDirection: NSUserInterfaceLayoutDirection {
|
|
|
get { .leftToRight }
|
|
|
@@ -89,6 +89,9 @@ final class ProfilesListPageView: NSView {
|
|
|
addButton.target = self
|
|
|
addButton.action = #selector(didTapAdd)
|
|
|
addButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ // Keep the pill at intrinsic width so title + arrow stay grouped and centered; otherwise a wide stack pins text and icon to opposite edges.
|
|
|
+ addButton.setContentHuggingPriority(.required, for: .horizontal)
|
|
|
+ addButton.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
|
|
|
|
let titleSubtitleStack = NSStackView(views: [title, subtitle])
|
|
|
titleSubtitleStack.orientation = .vertical
|
|
|
@@ -253,6 +256,9 @@ private final class ProfileListRowView: NSView {
|
|
|
// MARK: - Primary CTA (matches profile page button)
|
|
|
|
|
|
private final class ProfilesPrimaryButton: NSButton {
|
|
|
+ /// Horizontal padding around title + icon. Extra trailing inset keeps the SF arrow off the capsule curve (`masksToBounds` can clip at the ends).
|
|
|
+ private static let intrinsicPadding = NSEdgeInsets(top: 12, left: 28, bottom: 12, right: 44)
|
|
|
+
|
|
|
private var trackingArea: NSTrackingArea?
|
|
|
private var didPushCursor = false
|
|
|
|
|
|
@@ -266,26 +272,50 @@ private final class ProfilesPrimaryButton: NSButton {
|
|
|
commonInit()
|
|
|
}
|
|
|
|
|
|
- convenience init(title: String, target: AnyObject?, action: Selector?) {
|
|
|
+ convenience init(title: String, showsTrailingArrow: Bool = false, target: AnyObject?, action: Selector?) {
|
|
|
self.init(frame: .zero)
|
|
|
self.title = title
|
|
|
self.target = target
|
|
|
self.action = action
|
|
|
+ if showsTrailingArrow {
|
|
|
+ imagePosition = .imageTrailing
|
|
|
+ let symbolConfig = NSImage.SymbolConfiguration(pointSize: 12, weight: .semibold)
|
|
|
+ image = NSImage(systemSymbolName: "arrow.right", accessibilityDescription: nil)?
|
|
|
+ .withSymbolConfiguration(symbolConfig)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private func commonInit() {
|
|
|
bezelStyle = .rounded
|
|
|
isBordered = false
|
|
|
- font = .systemFont(ofSize: 16, weight: .semibold)
|
|
|
+ font = .systemFont(ofSize: 15, weight: .semibold)
|
|
|
contentTintColor = .white
|
|
|
wantsLayer = true
|
|
|
- layer?.cornerRadius = 14
|
|
|
+ layer?.masksToBounds = true
|
|
|
if #available(macOS 11.0, *) {
|
|
|
layer?.cornerCurve = .continuous
|
|
|
}
|
|
|
layer?.backgroundColor = ProfilesListPalette.brandBlue.cgColor
|
|
|
}
|
|
|
|
|
|
+ override var intrinsicContentSize: NSSize {
|
|
|
+ let base = super.intrinsicContentSize
|
|
|
+ let p = Self.intrinsicPadding
|
|
|
+ // `NSButton` intrinsic width can sit a few points tight vs. the symbol’s painted bounds; add slack so the arrow never kisses the pill edge.
|
|
|
+ let trailingSlack: CGFloat = image != nil ? 10 : 0
|
|
|
+ return NSSize(
|
|
|
+ width: base.width + p.left + p.right + trailingSlack,
|
|
|
+ height: base.height + p.top + p.bottom
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override func layout() {
|
|
|
+ super.layout()
|
|
|
+ let h = bounds.height
|
|
|
+ guard h > 1 else { return }
|
|
|
+ layer?.cornerRadius = h / 2
|
|
|
+ }
|
|
|
+
|
|
|
override func updateTrackingAreas() {
|
|
|
super.updateTrackingAreas()
|
|
|
if let trackingArea { removeTrackingArea(trackingArea) }
|