Uses uniform height for SourceDetailContentViewController News items (iOS 17+)

This commit is contained in:
Riley Testut
2023-10-16 19:12:42 -05:00
committed by Magesh K
parent 20cf2326c6
commit f9911d285d

View File

@@ -96,11 +96,13 @@ private extension SourceDetailContentViewController
case .news:
guard !source.newsItems.isEmpty else { return nil }
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(50)) // Underestimate height to prevent jumping size abruptly.
// Underestimate height to prevent jumping size abruptly.
let heightDimension: NSCollectionLayoutDimension = if #available(iOS 17, *) { .uniformAcrossSiblings(estimate: 50) } else { .estimated(50) }
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: heightDimension)
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupWidth = layoutEnvironment.container.contentSize.width - sectionInset * 2
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(groupWidth), heightDimension: .estimated(50))
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(groupWidth), heightDimension: heightDimension)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let buttonSize = NSCollectionLayoutSize(widthDimension: .estimated(60), heightDimension: .estimated(20))