README and documentationIGListKit version: 2.1.0There is a similar issue (#464) which is closed and doesn't have an answer to my question. Tried posting a reply there but didn't get any feedback in a week - thus creating a new issue.
I'm facing the same challenge as @rcholic: following HorizontalSectionController example I've implemented a vertical list which has got horizontally swipeable sections with additional cells showing some supplementary information. Basically what I'm trying to implement is something similar to Instagram's own photos collection which leads to the change of the little dots mark below indicating currently showing cell.
I intend on implementing this "dotsView" as a separate cell which needs to receive "cell changed" events from the swipe section. The reason for using separate cells & embedded section is that views are fairly complicated and I'd prefer setting up individual cells instead of one massive cell with scroll view
I'm also struggling to get the index of the currently showing cell within embedded section. Embedded section's adapter's delegate methods are only called on display of the section itself but not after the swipes within the section
@drinkius as long as the cells are within the same section controller, you can wire up the section controller as the collectionViewDelegate on the embedded adapter. Here's some psuedocode:
class MySectionController: IGListSectionController, UICollectionViewDelegate
// track the displayed cell
var visibleIndex = 0
let adapter: IGListAdapter = {
let adapter = // init
adapter.dataSource = self
adapter.collectionViewDelegate = self
return adapter
}()
override func cellForItem(at index: Int) -> UICollectionViewCell {
let cell = // dequeue the cell
if let cell = cell as? EmbeddedCell {
adapter.collectionView = cell.collectionView
} else if let cell = cell as? DotCell {
cell.updateSelectedDot(dot: visibleIndex, animated: false)
}
}
func collectionView(_ collectionView: UICollectionView,
willDisplay cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
visibleIndex = indexPath.section
if let cell = collectionContext?.cellForItem(index: 1, sectionController: self) as? DotCell {
cell.updateSelectedDot(dot: visibleIndex, animated: true)
}
}
}
Going to close as resolved. 馃槃
Love you IGLISTKIT <3
Most helpful comment
@drinkius as long as the cells are within the same section controller, you can wire up the section controller as the collectionViewDelegate on the embedded adapter. Here's some psuedocode: