Skip to content

Commit

Permalink
CAImageView
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Feb 19, 2024
1 parent ef0ed6c commit fe8506e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sources/CommonAppleKit/CAListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ open class CAListView<Cell: CAListViewCell<CellRootView>, CellRootView, CellData
}
#endif

public init(frame: CGRect, itemSize: CGSize, cellId: String = .init(describing: Cell.self), cellDelegate: CAListViewCellDelegate? = nil) {
public init(
frame: CGRect,
itemSize: CGSize,
minimumInteritemSpacing: CGFloat = 0,
minimumLineSpacing: CGFloat = 0,
cellId: String = .init(describing: Cell.self),
cellDelegate: CAListViewCellDelegate? = nil
) {
self.cellId = cellId
self.cellDelegate = cellDelegate
let layout = CACollectionViewFlowLayout()
layout.itemSize = itemSize
layout.minimumInteritemSpacing = minimumInteritemSpacing
layout.minimumLineSpacing = minimumLineSpacing
#if canImport(AppKit)
super.init(frame: frame)
collectionViewLayout = layout
Expand Down Expand Up @@ -72,7 +81,7 @@ open class CAListView<Cell: CAListViewCell<CellRootView>, CellRootView, CellData
}
#elseif canImport(UIKit)
public func collectionView(_ collectionView: CACollectionView, didSelectItemAt indexPath: IndexPath) {

cellDelegate?.onCellTap(data: content[indexPath.item])
}

public func collectionView(_ collectionView: CACollectionView, cellForItemAt indexPath: IndexPath) -> CACollectionViewCell {
Expand Down
1 change: 1 addition & 0 deletions Sources/CommonAppleKit/CAListViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation

public protocol CAListViewCellDelegate: AnyObject {
func onCellTap(data: Any?)
func onAction(data: Any?)
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/CommonAppleKit/CommonAppleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public typealias CAFont = UIFont
public typealias CAEdgeInsets = UIEdgeInsets
public typealias CAStackView = UIStackView
public typealias CAImageView = UIImageView

public extension CALabel {
var stringValue: String {
Expand Down Expand Up @@ -139,6 +140,7 @@
public typealias CAFont = NSFont
public typealias CAEdgeInsets = NSEdgeInsets
public typealias CAStackView = NSStackView
public typealias CAImageView = NSImageView

public extension CAImage {
@available(macOS 11.0, *)
Expand Down

0 comments on commit fe8506e

Please sign in to comment.