Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About ReloadData #168

Open
mozartee opened this issue Jul 12, 2023 · 0 comments
Open

About ReloadData #168

mozartee opened this issue Jul 12, 2023 · 0 comments

Comments

@mozartee
Copy link

mozartee commented Jul 12, 2023

Some of my code:

        let titleProvider = LabelProvider(text: "CollectionKit", font: .boldSystemFont(ofSize: 32))
        let contentProvider = LabelProvider(text: "A modern swift framework for building reusable collection view components.", font: .boldSystemFont(ofSize: 28))

        let buttonProvider = ButtonProvider(title: "Reload", sizeStrategy: (.fill, .absolute(50)), insert: UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)) { _ in
            let label = UILabel()
            label.text = "change the text"
            contentProvider.views.append(label)
        }

...

  let sections = [
            waterfallProvider,
            gridProvider,
            wrapProvider
        ] as [Provider]
        let composedHeaderProvider = ComposedHeaderProvider(
            headerViewSource: { (view: UILabel, _, index) in
                view.text = headers[index]
                view.font = .boldSystemFont(ofSize: 21)
                view.backgroundColor = .white
            },
            headerSizeSource: { _, _, size -> CGSize in
                CGSize(width: size.width, height: 40)
            },
            sections: sections
        )
        composedHeaderProvider.isSticky = false

        let composedProvider = ComposedProvider(
            layout: FlowLayout(spacing: 10).inset(by: UIEdgeInsets(top: 0, left: 20, bottom: safeAreaBottom(), right: 20)),
            sections: [
                spaceProvider,
                titleProvider,
                contentProvider,
                buttonProvider,
                composedHeaderProvider
            ]
        )

        collectionView.provider = composedProvider 

When I reload with contentProvider.views.append(label), the whole provider reload. Is that right? I need reload some widget like Flutter.

I had seen Note that if you assign an array to the dataSource and later update that array instead. It won't actually update the CollectionView in the Readme, but it's wrong with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant