From 13e0fc421b35f44fabebe6b0ed56b3796946fb78 Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Fri, 27 Oct 2023 13:15:17 +0200 Subject: [PATCH] CAListView is CACollectionViewDelegate --- Sources/CommonAppleKit/CAListView.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/CommonAppleKit/CAListView.swift b/Sources/CommonAppleKit/CAListView.swift index 490d077..088feb4 100644 --- a/Sources/CommonAppleKit/CAListView.swift +++ b/Sources/CommonAppleKit/CAListView.swift @@ -8,7 +8,7 @@ import Foundation -open class CAListView: CACollectionView, CACollectionViewDataSource { +open class CAListView: CACollectionView, CACollectionViewDataSource, CACollectionViewDelegate { private let cellId: String #if canImport(UIKit) @@ -35,6 +35,7 @@ open class CAListView: CACollectionView, CACollectionViewD #if canImport(UIKit) dataSource = self #endif + delegate = self } required public init?(coder _: NSCoder) { @@ -49,7 +50,15 @@ open class CAListView: 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]