Skip to content

Commit

Permalink
CAListView is CACollectionViewDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Oct 27, 2023
1 parent 9a5645e commit 13e0fc4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/CommonAppleKit/CAListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

open class CAListView<Cell: CAListViewCell>: CACollectionView, CACollectionViewDataSource {
open class CAListView<Cell: CAListViewCell>: CACollectionView, CACollectionViewDataSource, CACollectionViewDelegate {
private let cellId: String

#if canImport(UIKit)
Expand All @@ -35,6 +35,7 @@ open class CAListView<Cell: CAListViewCell>: CACollectionView, CACollectionViewD
#if canImport(UIKit)
dataSource = self
#endif
delegate = self
}

required public init?(coder _: NSCoder) {
Expand All @@ -49,7 +50,15 @@ open class CAListView<Cell: CAListViewCell>: CACollectionView, CACollectionViewD
public func collectionView(_ collectionView: CACollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> CACollectionViewCell {
fatalError()
}

public func collectionView(_ collectionView: CACollectionView, willDisplay item: CACollectionViewCell, forRepresentedObjectAt indexPath: IndexPath) {

}
#elseif canImport(UIKit)
public func collectionView(_ collectionView: CACollectionView, didSelectItemAt indexPath: IndexPath) {

}

public func collectionView(_ collectionView: CACollectionView, cellForItemAt indexPath: IndexPath) -> CACollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath)
(cell as? CAListViewCell)?.representedObject = content[indexPath.item]
Expand Down

0 comments on commit 13e0fc4

Please sign in to comment.