Sfoglia il codice sorgente

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 settimana fa
parent
commit
390fa1e357
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      meetings_app/ViewController.swift

+ 7 - 1
meetings_app/ViewController.swift

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