Im trying to use a compositional layout to create random count of group like here
In other words I need to have a first group with 10 elements, second - 5 elements, third - 8 elements, for example. All elements are calculated in another business logic, they can change.
Where: Blue - header
Red - section
Green - group
black - cell
How can I manage this ? I have played with nested groups but it seems that not suitable for me? It would be better if I go away from compos layout and try another ideas?
Example code which I try to use, but it seems that we can not set "estimated" count for group?
let layout = UICollectionViewCompositionalLayout {
(_: Int, _: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in
let trailingItem = NSCollectionLayoutItem(
layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(0)
)
)
trailingItem.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
let trailingGroup = NSCollectionLayoutGroup.vertical(
layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(0.1),
heightDimension: .fractionalHeight(1)
),
subitem: trailingItem, count: 10
)
let nestedGroup = NSCollectionLayoutGroup.horizontal(
layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .fractionalHeight(1)
),
subitems: [trailingGroup]
)
let section = NSCollectionLayoutSection(group: nestedGroup)
section.orthogonalScrollingBehavior = .groupPagingCentered
return section
}