FluidGroup / DataSources

💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)
MIT License
569 stars 30 forks source link

Best way to handle Dynamic Section in DataSource. #6

Closed steve21124 closed 7 years ago

steve21124 commented 7 years ago

the current code does not has dynamic section https://gist.github.com/steve21124/2b750015ab27df99474fd48bc435ab56

What do you think the best way to handle dynamic section? Like adding new sections

    • Create array of sections that store sectionX (Where X = 0..n) ?
    • Create array of models that stores sectionXModels (where X = 0...n) ?

or any other better idea?

steve21124 commented 7 years ago

here is sample to do dynamic section https://gist.github.com/steve21124/f9a2338447f850344c18da83aa9d84ca

steve21124 commented 7 years ago

seems like still having issues in dynamically adding section "Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3692.2/UICollectionView.m:5990"

after initialization. this cause above error

        let section0 = Section(ModelM.self, isEqual: { $0.identity == $1.identity })
        var section0Models: [ModelM] = [] {
            didSet {
                _dataSource.update(
                    in: section0,
                    items: section0Models,
                    updateMode: .partial(animated: true),
                    completion: {
                        print(self._dataSource.numberOfItems(in: 0))
                })
            }
        }
        _dataSource.add(section: section0)
        for _ in 0..<20 {
            section0Models.append(ModelM(identity: UUID().uuidString, title: String.randomEmoji()))
        }
        sectionModels.add(section0)

I am not sure if the library able to handle dynamic section or not

steve21124 commented 7 years ago

additional info which might fix it https://stackoverflow.com/questions/12611292/uicollectionview-assertion-failure

muukii commented 7 years ago

@steve21124 Hi, Steve DataSources has not supported add/remove section dynamically. We should improve the architecture.

steve21124 commented 7 years ago

Thanks. May be that can be added to readme. Not supporting dynamic section adding yet

haashem commented 6 years ago

@muukii supporting dynamic sections is really needed. when do you think it will be available?