Selaa lähdekoodia

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 3 kuukautta sitten
vanhempi
sitoutus
390fa1e357
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7 1
      meetings_app/ViewController.swift

+ 7 - 1
meetings_app/ViewController.swift

@@ -1917,7 +1917,7 @@ private extension ViewController {
         row.orientation = .horizontal
         row.spacing = 12
         row.alignment = .top
-        row.distribution = .fill
+        row.distribution = .gravityAreas
         row.setContentHuggingPriority(.defaultHigh, for: .horizontal)
         row.heightAnchor.constraint(equalToConstant: 150).isActive = true
         scheduleCardsStack = row
@@ -1953,6 +1953,8 @@ private extension ViewController {
         card.translatesAutoresizingMaskIntoConstraints = false
         card.widthAnchor.constraint(equalToConstant: cardWidth).isActive = true
         card.heightAnchor.constraint(equalToConstant: 150).isActive = true
+        card.setContentHuggingPriority(.required, for: .horizontal)
+        card.setContentCompressionResistancePriority(.required, for: .horizontal)
 
         let icon = roundedContainer(cornerRadius: 8, color: palette.meetingBadge)
         icon.translatesAutoresizingMaskIntoConstraints = false
@@ -2027,6 +2029,10 @@ private extension ViewController {
         hit.isBordered = false
         hit.bezelStyle = .regularSquare
         hit.identifier = NSUserInterfaceItemIdentifier(meeting.meetURL.absoluteString)
+        hit.widthAnchor.constraint(equalToConstant: cardWidth).isActive = true
+        hit.heightAnchor.constraint(equalToConstant: 150).isActive = true
+        hit.setContentHuggingPriority(.required, for: .horizontal)
+        hit.setContentCompressionResistancePriority(.required, for: .horizontal)
         hit.addSubview(card)
         NSLayoutConstraint.activate([
             card.leadingAnchor.constraint(equalTo: hit.leadingAnchor),