apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.35k stars 160 forks source link

added display callbacks #205

Closed hassanvfx closed 3 years ago

hassanvfx commented 3 years ago

Overview

The following PR implements the following modifiers both for UICollectionView and UITableView:

example:

        ASCollectionView(data: model.items, dataID: \.self) { item, context in

                InstaCard(model: instaCardModel(for: item),
                          geo: geo,
                          item: item){
                    model.open(newsItem: item)
                }

            }
            .layout {
                .list(itemSize:.estimated(123))
            }
            .onPullToRefresh { (finish) in
                model.loadNews()
                DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                    finish()
                }
            }
            .onWillDisplay{ _, indexPath in
                player(at: indexPath)?.play()
            }
            .onDidDisplay{ _, indexPath in
                player(at: indexPath)?.pause()
            }