Просмотр исходного кода

Style job Save button to match reference UI

Use white fill with soft search-bar border instead of tinted hover and
selection fills. Add SaveJobButtonCell with balanced insets and spacing
between heart and title. Route Save through SaveJobPayloadButton for the
custom cell.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 недель назад: 3
Родитель
Сommit
0ee799c9e7
1 измененных файлов с 34 добавлено и 15 удалено
  1. 34 15
      App for Indeed/Views/DashboardView.swift

+ 34 - 15
App for Indeed/Views/DashboardView.swift

@@ -812,7 +812,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
812
         applyButton.setContentCompressionResistancePriority(.required, for: .horizontal)
812
         applyButton.setContentCompressionResistancePriority(.required, for: .horizontal)
813
 
813
 
814
         let savedOn = isJobSaved(job)
814
         let savedOn = isJobSaved(job)
815
-        let savedButton = JobPayloadButton(title: savedOn ? "Saved" : "Save", target: self, action: #selector(didTapJobSaved(_:)))
815
+        let savedButton = SaveJobPayloadButton(title: savedOn ? "Saved" : "Save", target: self, action: #selector(didTapJobSaved(_:)))
816
         savedButton.jobPayload = job
816
         savedButton.jobPayload = job
817
         savedButton.cardContext = context
817
         savedButton.cardContext = context
818
         savedButton.setButtonType(.toggle)
818
         savedButton.setButtonType(.toggle)
@@ -925,20 +925,13 @@ final class DashboardView: NSView, NSTextFieldDelegate {
925
 
925
 
926
     private func styleJobSavedButton(_ button: NSButton) {
926
     private func styleJobSavedButton(_ button: NSButton) {
927
         button.wantsLayer = true
927
         button.wantsLayer = true
928
-        button.layer?.cornerRadius = 8
929
-        let on = button.state == .on
928
+        button.layer?.cornerRadius = 10
930
         let hovering = (button as? HoverableButton)?.isHovering ?? false
929
         let hovering = (button as? HoverableButton)?.isHovering ?? false
931
-        if on {
932
-            button.layer?.backgroundColor = (hovering ? Theme.selectionFillHover : Theme.selectionFill).cgColor
933
-            button.layer?.borderWidth = 1
934
-            button.layer?.borderColor = Theme.brandBlue.cgColor
935
-            button.contentTintColor = Theme.brandBlue
936
-        } else {
937
-            button.layer?.backgroundColor = (hovering ? Theme.proCardFill : Theme.cardBackground).cgColor
938
-            button.layer?.borderWidth = 1
939
-            button.layer?.borderColor = Theme.brandBlue.cgColor
940
-            button.contentTintColor = Theme.brandBlue
941
-        }
930
+        // Reference: white surface, soft blue outline, brand blue icon + label (no tinted fill on hover).
931
+        button.layer?.backgroundColor = Theme.cardBackground.cgColor
932
+        button.layer?.borderWidth = 1
933
+        button.layer?.borderColor = (hovering ? Theme.searchBarBorderHover : Theme.searchBarBorder).cgColor
934
+        button.contentTintColor = Theme.brandBlue
942
     }
935
     }
943
 
936
 
944
     @objc private func didTapJobApply(_ sender: NSButton) {
937
     @objc private func didTapJobApply(_ sender: NSButton) {
@@ -2674,11 +2667,37 @@ private final class FeatureShortcutCardView: NSView {
2674
 }
2667
 }
2675
 
2668
 
2676
 /// `NSButton` that carries a `JobListing` for card actions (`representedObject` is unavailable on `NSButton` in this target).
2669
 /// `NSButton` that carries a `JobListing` for card actions (`representedObject` is unavailable on `NSButton` in this target).
2677
-private final class JobPayloadButton: HoverableButton {
2670
+private class JobPayloadButton: HoverableButton {
2678
     var jobPayload: JobListing?
2671
     var jobPayload: JobListing?
2679
     var cardContext: JobListingCardContext = .homeSearchResults
2672
     var cardContext: JobListingCardContext = .homeSearchResults
2680
 }
2673
 }
2681
 
2674
 
2675
+/// Insets image + title so the Save pill matches the reference (balanced padding, not flush to the stroke).
2676
+private final class SaveJobButtonCell: NSButtonCell {
2677
+    private let horizontalInset: CGFloat = 10
2678
+    private let verticalInset: CGFloat = 3
2679
+    private let imageTitleGap: CGFloat = 5
2680
+
2681
+    override func imageRect(forBounds rect: NSRect) -> NSRect {
2682
+        super.imageRect(forBounds: rect.insetBy(dx: horizontalInset, dy: verticalInset))
2683
+    }
2684
+
2685
+    override func titleRect(forBounds rect: NSRect) -> NSRect {
2686
+        let padded = rect.insetBy(dx: horizontalInset, dy: verticalInset)
2687
+        var t = super.titleRect(forBounds: padded)
2688
+        t.origin.x += imageTitleGap
2689
+        t.size.width = max(0, t.size.width - imageTitleGap)
2690
+        return t
2691
+    }
2692
+}
2693
+
2694
+private final class SaveJobPayloadButton: JobPayloadButton {
2695
+    override class var cellClass: AnyClass? {
2696
+        get { SaveJobButtonCell.self }
2697
+        set { }
2698
+    }
2699
+}
2700
+
2682
 /// `NSButton` with a tracking area that reports hover transitions and (optionally) swaps in a pointing-hand cursor while hovered.
2701
 /// `NSButton` with a tracking area that reports hover transitions and (optionally) swaps in a pointing-hand cursor while hovered.
2683
 private class HoverableButton: NSButton {
2702
 private class HoverableButton: NSButton {
2684
     var hoverHandler: ((Bool) -> Void)?
2703
     var hoverHandler: ((Bool) -> Void)?