The title itself might a bit misleading and I believe the problem is best explained with an example.
Take Facebook's feed, for instance. Every item consists of the following:
- Header (user's name, etc), static height
- Main content (text, attachment), dynamic height
- Footer (number of likes and a couple of buttons), static height
At a minimum, the main content has one of the following:
- Title, optional
- Textual preview, optional
- Attachment (of variable height), usually an image, optional
So, a few possible combinations of parts:
- Title
- Title, text
- Title, text, attachment
- Text
- Text, attachment
- etc
I've come up with two approaches:
1. Sections for each post, cells for parts
Note: the UIKit-provided header and footer wouldn't do, as I need specific spacing between each item. Therefore, I'd use these to get the spacing needed.
Also, I'm using RxSwift. This approach breaks the simplicity of data binding to the table view, although there's always a more complex alternative.
2. Multiple cell types
Not sure. Separate cell type for each possible combination of the above? Seems like an overkill.
3. Single cell type
The easiest approach. But, considering all the optional parts, there's quite a few constraints to switch and tweak (depending on the attachment height). UIStackView is not an option evidently, since the attachment must take the whole screen width, whilst the other parts use custom padding on each axis.
I'm looking for an outside perspective here, mainly from those who happen to have solved a similar problem in the past. An example of code would also be lovely (especially if it's scalable).
Target: iOS 13+.
Will AutoLayout perform alright in each of these?
What approach would you use?