I am trying to use composable collection view layouts to build an interface that has sections and then "sub-sections". Imagine a photo picker with a section for each month, and then a separate sub-section for each day within the month. The month header would be sticky, while the headers on each date section would not.
I know iOS 14 has support for outline-style collection views which would probably work for representing sub-sections, but I'm hoping to do this in a way that's compatible with iOS 13.
My thought was that I could do something like this:
The problem that I'm having is that I see no way for the group layout to know which item it's starting at. Ideally, I'd like for the custom group layout provider to receive an itemIndex parameter. If it's 0, I'd know I'm looking at day 1. If it's 7, I'd be able to do the math to know that we've moved on to day 2, etc.
Unfortunately, I see no way for the group to know that. I cannot assume that the group provider will be called only once sequentially for each group instance in the section; I already tried that and was quickly proven wrong.
Is there a better way to do this?
Notes on alternatives I've tried:
I could instead just provide a series of custom groups, each tailored to have the correct number of items for that group, like so:
I know iOS 14 has support for outline-style collection views which would probably work for representing sub-sections, but I'm hoping to do this in a way that's compatible with iOS 13.
My thought was that I could do something like this:
Section
(Sticky boundary item of kind "month-header")
Day Group (see below)
Day Group
(Non-sticky boundary item of kind "day-header")
Custom layout that provides the layout for each day view
The problem that I'm having is that I see no way for the group layout to know which item it's starting at. Ideally, I'd like for the custom group layout provider to receive an itemIndex parameter. If it's 0, I'd know I'm looking at day 1. If it's 7, I'd be able to do the math to know that we've moved on to day 2, etc.
Unfortunately, I see no way for the group to know that. I cannot assume that the group provider will be called only once sequentially for each group instance in the section; I already tried that and was quickly proven wrong.
Is there a better way to do this?
Notes on alternatives I've tried:
I could instead just provide a series of custom groups, each tailored to have the correct number of items for that group, like so:
Section
(Sticky boundary item of kind "month-header")
Day Group 1
Day Group 2
...
Day Group 31
Day Group 1
(Non-sticky boundary item of kind "day-header-1" to serve as day header)
Custom layout for day 1
Day Group 2
(Non-sticky boundary item of kind "day-header-2" to serve as day header)
Custom layout for day 2
Day Group ...