I am super excited about the new compositional layout apis in collection view, however it's not clear how to handle an important use case in my app: hierarchical data.
Here's a made-up example of a hierarchical data model:
I'm displaying a list of fruit. For each type of fruit (apple, banana, ...), I have:
+ a variable number of varieties
+ a variable number of favorite dishes
In my list, I want each variety and each dish to have its own thumbnail image.
From a layout perspective, compositional layout is perfect for this; but from a data model perspective ...
Each fruit could be a separate section; but within each section you have to flatten your data, indexing varieties and dishes in a single collection. That feels ugly and error-prone.
Now imagine we want a single list that covers fruit, vegetables, and herbs. If we make each main category a section, then within each category we have to flatten all our names, varieties and dishes into one big list. That feels really ugly and error-prone.
Alternatively, we could define a separate section for every distinct data set:
1. Apple
2. Apple varieties
3. Apple dishes
4. Banana
5. Banana varieties
6. Banana dishes
...
But this also loses the nested quality of the data. Eg., we couldn't have separate sections for our categories.
I'm wondering if I'm thinking about this correctly or perhaps missing something?