Parcourir la Source

Fix CV maker group toggle resizing on selection

Use fillEqually on the group tabs stack and relax pillLarge chip
horizontal hugging so Design-Based and Profession-Based stay equal
width. Center the inner icon/label/badge stack in large pills.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 il y a 3 semaines
Parent
commit
04186498f9
1 fichiers modifiés avec 19 ajouts et 6 suppressions
  1. 19 6
      App for Indeed/Views/CVMakerPageView.swift

+ 19 - 6
App for Indeed/Views/CVMakerPageView.swift

@@ -607,6 +607,7 @@ final class CVMakerPageView: NSView {
607 607
         groupTabsRow.orientation = .horizontal
608 608
         groupTabsRow.spacing = 8
609 609
         groupTabsRow.alignment = .centerY
610
+        groupTabsRow.distribution = .fillEqually
610 611
         groupTabsRow.translatesAutoresizingMaskIntoConstraints = false
611 612
         configureGroupTabs()
612 613
 
@@ -1051,12 +1052,24 @@ private final class CVChipButton: NSView {
1051 1052
 
1052 1053
         addSubview(stack)
1053 1054
         let horizontalInset: CGFloat = style == .pillLarge ? 16 : 12
1054
-        NSLayoutConstraint.activate([
1055
-            stack.leadingAnchor.constraint(equalTo: leadingAnchor, constant: horizontalInset),
1056
-            stack.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -horizontalInset),
1057
-            stack.centerYAnchor.constraint(equalTo: centerYAnchor)
1058
-        ])
1059
-        setContentHuggingPriority(.required, for: .horizontal)
1055
+        if style == .pillLarge {
1056
+            // Group toggle shares a row: equal widths from the parent stack; keep
1057
+            // icon + label + badge centered so selection state does not reshuffle width.
1058
+            NSLayoutConstraint.activate([
1059
+                stack.centerXAnchor.constraint(equalTo: centerXAnchor),
1060
+                stack.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: horizontalInset),
1061
+                stack.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor, constant: -horizontalInset),
1062
+                stack.centerYAnchor.constraint(equalTo: centerYAnchor)
1063
+            ])
1064
+            setContentHuggingPriority(.defaultLow, for: .horizontal)
1065
+        } else {
1066
+            NSLayoutConstraint.activate([
1067
+                stack.leadingAnchor.constraint(equalTo: leadingAnchor, constant: horizontalInset),
1068
+                stack.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -horizontalInset),
1069
+                stack.centerYAnchor.constraint(equalTo: centerYAnchor)
1070
+            ])
1071
+            setContentHuggingPriority(.required, for: .horizontal)
1072
+        }
1060 1073
         applyState()
1061 1074
     }
1062 1075