Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from kiva/compositional-layout
Browse files Browse the repository at this point in the history
Support UICollectionViewCompositionalLayout
  • Loading branch information
kean authored Apr 3, 2021
2 parents 1f960f9 + 9dba2c6 commit 23949ee
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,19 @@ public protocol Preheated {

extension UICollectionView: Preheated {
public var orientation: ScrollOrientation {
switch (collectionViewLayout as! UICollectionViewFlowLayout).scrollDirection {
case .vertical: return .vertical
case .horizontal: return .horizontal
if let layout = collectionViewLayout as? UICollectionViewFlowLayout {
switch layout.scrollDirection {
case .vertical: return .vertical
case .horizontal: return .horizontal
}
} else if #available(iOS 13.0, tvOS 13.0, *), let layout = collectionViewLayout as? UICollectionViewCompositionalLayout {
switch layout.configuration.scrollDirection {
case .vertical: return .vertical
case .horizontal: return .horizontal
}
}

preconditionFailure("Unknown collection view scroll orientation")
}

public func indexPaths(in rect: CGRect) -> [IndexPath] {
Expand Down

0 comments on commit 23949ee

Please sign in to comment.