Kaynağa Gözat

Prevent single schedule card from stretching.

Keep meeting cards at fixed dimensions with required layout priorities so a single card renders at normal size like multi-card layouts.

Made-with: Cursor
huzaifahayat12 1 hafta önce
ebeveyn
işleme
390fa1e357
1 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 7 1
      meetings_app/ViewController.swift

+ 7 - 1
meetings_app/ViewController.swift

@@ -1917,7 +1917,7 @@ private extension ViewController {
1917 1917
         row.orientation = .horizontal
1918 1918
         row.spacing = 12
1919 1919
         row.alignment = .top
1920
-        row.distribution = .fill
1920
+        row.distribution = .gravityAreas
1921 1921
         row.setContentHuggingPriority(.defaultHigh, for: .horizontal)
1922 1922
         row.heightAnchor.constraint(equalToConstant: 150).isActive = true
1923 1923
         scheduleCardsStack = row
@@ -1953,6 +1953,8 @@ private extension ViewController {
1953 1953
         card.translatesAutoresizingMaskIntoConstraints = false
1954 1954
         card.widthAnchor.constraint(equalToConstant: cardWidth).isActive = true
1955 1955
         card.heightAnchor.constraint(equalToConstant: 150).isActive = true
1956
+        card.setContentHuggingPriority(.required, for: .horizontal)
1957
+        card.setContentCompressionResistancePriority(.required, for: .horizontal)
1956 1958
 
1957 1959
         let icon = roundedContainer(cornerRadius: 8, color: palette.meetingBadge)
1958 1960
         icon.translatesAutoresizingMaskIntoConstraints = false
@@ -2027,6 +2029,10 @@ private extension ViewController {
2027 2029
         hit.isBordered = false
2028 2030
         hit.bezelStyle = .regularSquare
2029 2031
         hit.identifier = NSUserInterfaceItemIdentifier(meeting.meetURL.absoluteString)
2032
+        hit.widthAnchor.constraint(equalToConstant: cardWidth).isActive = true
2033
+        hit.heightAnchor.constraint(equalToConstant: 150).isActive = true
2034
+        hit.setContentHuggingPriority(.required, for: .horizontal)
2035
+        hit.setContentCompressionResistancePriority(.required, for: .horizontal)
2030 2036
         hit.addSubview(card)
2031 2037
         NSLayoutConstraint.activate([
2032 2038
             card.leadingAnchor.constraint(equalTo: hit.leadingAnchor),