diff --git a/Sources/CommonAppleKit/CAListView.swift b/Sources/CommonAppleKit/CAListView.swift index 64241bb..80db415 100644 --- a/Sources/CommonAppleKit/CAListView.swift +++ b/Sources/CommonAppleKit/CAListView.swift @@ -19,7 +19,7 @@ open class CAListView, CellRootView>: CAColle } #endif - public init(frame: CGRect, itemSize: CGSize, cellId: String) { + public init(frame: CGRect, itemSize: CGSize, cellId: String = String(describing: Cell.self)) { self.cellId = cellId let layout = CACollectionViewFlowLayout() layout.itemSize = itemSize @@ -57,7 +57,7 @@ open class CAListView, CellRootView>: CAColle public func collectionView(_ collectionView: CACollectionView, cellForItemAt indexPath: IndexPath) -> CACollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) - (cell as? CAListViewCell)?.representedObject = content[indexPath.item] + (cell as? Cell)?.representedObject = content[indexPath.item] return cell } #endif diff --git a/Sources/CommonAppleKit/CAListViewCell.swift b/Sources/CommonAppleKit/CAListViewCell.swift index 4143d4e..cc7fb0a 100644 --- a/Sources/CommonAppleKit/CAListViewCell.swift +++ b/Sources/CommonAppleKit/CAListViewCell.swift @@ -11,13 +11,13 @@ import Foundation open class CAListViewCell: CACollectionViewCell { public unowned var rootView: RootView! - open func createRootView() -> RootView { - RootView(frame: .zero) + open func createRootView(frame: CARect) -> RootView { + RootView(frame: frame) } #if canImport(AppKit) open override func loadView() { - let rootView = createRootView() + let rootView = createRootView(frame: frame) view = rootView self.rootView = rootView } @@ -27,7 +27,7 @@ open class CAListViewCell: CACollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) - let rootView = createRootView() + let rootView = createRootView(frame: frame) contentView.addSubview(rootView) self.rootView = rootView rootView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true diff --git a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift index cdbe0c6..4992168 100644 --- a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift +++ b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift @@ -89,7 +89,7 @@ final class CommonAppleKitTests: XCTestCase { } func testScrollableListView() { - let listView = CAScrollableListView(frame: .zero, itemSize: .init(width: 200, height: 100), cellId: "id") + let listView = CAScrollableListView(frame: .zero, itemSize: .init(width: 200, height: 100)) listView.content = [] } }