Skip to content

Commit

Permalink
#6 Fix missing dispatch dequeue event for collection's header/footer
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed May 12, 2019
1 parent 7fdaa6e commit da93946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 18 additions & 2 deletions Sources/Collection/CollectionDirector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,24 @@ public extension CollectionDirector {

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let adapter = adapterForHeaderFooter(kind, indexPath: indexPath)
return adapter?.dequeueHeaderFooterForDirector(self, type: kind, indexPath: indexPath) ?? UICollectionReusableView()
}
let view = adapter?.dequeueHeaderFooterForDirector(self, type: kind, indexPath: indexPath) ?? UICollectionReusableView()
let _ = adapter?.dispatch(.dequeue, isHeader: (kind == UICollectionView.elementKindSectionHeader), view: view, section: sections[indexPath.section], index: indexPath.section)
return view
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
guard let size = sections[section].headerView?.dispatch(.referenceSize, isHeader: true, view: nil, section: sections[section], index: section) as? CGSize else {
return .zero
}
return size
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
guard let size = sections[section].footerView?.dispatch(.referenceSize, isHeader: false, view: nil, section: sections[section], index: section) as? CGSize else {
return .zero
}
return size
}

func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath) {
let adapter = adapterForHeaderFooter(elementKind, indexPath: indexPath)
Expand Down
16 changes: 0 additions & 16 deletions Sources/Collection/FlowCollectionDirector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,4 @@ public extension FlowCollectionDirector {
return value
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
guard let size = sections[section].headerView?.dispatch(.referenceSize, isHeader: true, view: nil, section: sections[section], index: section) as? CGSize else {
return .zero
}
return size
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
guard let size = sections[section].footerView?.dispatch(.referenceSize, isHeader: false, view: nil, section: sections[section], index: section) as? CGSize else {
return .zero
}
return size
}



}

0 comments on commit da93946

Please sign in to comment.