Closed mobilinked closed 7 years ago
I hope it is ok to ask this here
All questions welcome!
what's the suitable way to update a specific cell related updated cell model object?
If you're modifying data that represents something at the cell-level, the modifications and storage should probably happen within the section controller and not up at the view controller. Within the section controller you can then do something like:
self.cells[0].name = "Hello!"
self.collectionContext?.reload(in: self, at: 0)
Does IGListKit support to move cell by gesture?
This is unsupported at the moment, but I'll open an issue to track this because I think its something we could add in the future pretty easily.
Thanks much @rnystrom, it works.
And I'd like to see there is delegate to control the moving, like the suggestion:
allowMove(from index: Int) -> Bool
allowMove(to index ...) -> Bool
And allow to disable/enable moving feature.
I have another question related to that.
If you add or remove CellModels from SectionModel -> [cells], from VC adapter.performUpdates(animated: true) doesn't update the UI. Only reloadData() works. But it's not what I wanted.
How can I update UI for updated cells array in SectionModel from VC.
Thanks!
@shuhrat10 performUpdates(animated:,completion:)
only works for section-level operations. If you want to do item updates you can do that directly from the section controller using the insert, delete, and reload operations. We're planning on adding moves in #145 for 3.0.0.
To make this more streamlined when your cells are powered by an array of view models, we're also planning #38 so this is more automated.
@rnystrom That will be awesome, I can't wait to see this functionality.
I hope it is ok to ask this here. Otherwise, please feel free to delete this thread.
Purpose
final class CellModel: IGListDiffable { let id: String var name: String ... }
self.data[0].cells[0].name = "****" adapter.performUpdates(animated: true)
self.data[0].cells[0].name = "****" adapter.reloadData()
let obj = self.data[0].cells[0] obj.name = "****" adapter.reloadObjects([obj])