- Rename source module from RDReaderView to RDEpubReaderView - Move all source files from Sources/RDReaderView/ to Sources/RDEpubReaderView/ - Update podspec: RDReaderView.podspec -> RDEpubReaderView.podspec - Update Podfile, demo project, and CocoaPods config for new pod name - Delete old RDReaderView pod support files from ReadViewDemo/Pods - Add new RDEpubReaderView pod support files - Update documentation (API ref, architecture, UML, conventions, etc.) - Add FixedLayoutRotationTests - Update .gitignore: exclude .DS_Store, manual unpack backups, _ssoft-output
43 lines
1.8 KiB
Swift
43 lines
1.8 KiB
Swift
|
|
import UIKit
|
|
|
|
extension RDEpubReaderView: UICollectionViewDataSource, RDEpubReaderFlowLayoutDelegate, RDEpubReaderFlowLayoutDataSoure {
|
|
|
|
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
if let identifer = pageReuseIdentifier(for: indexPath.row) {
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifer, for: IndexPath(item: indexPath.row, section: 0)) as! RDEpubReaderContentCell
|
|
let preloadedView = preloadController.takePreloadedView(for: indexPath.row)
|
|
let reusableView = cell.containerView ?? preloadedView
|
|
cell.containerView = contentViewForPage(indexPath.row, reusableView: reusableView)
|
|
|
|
if pageDirection == .rightToLeft && currentDisplayType != .verticalScroll {
|
|
cell.contentView.transform = CGAffineTransform(scaleX: -1, y: 1)
|
|
} else {
|
|
cell.contentView.transform = .identity
|
|
}
|
|
return cell
|
|
}
|
|
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(UICollectionViewCell.self), for: indexPath)
|
|
|
|
return cell
|
|
}
|
|
|
|
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
return numberOfPages()
|
|
}
|
|
|
|
public func pageNum(flowLayout: RDEpubReaderFlowLayout, pageIndex: Int) {
|
|
if currentPage >= 0, currentPage != pageIndex {
|
|
predictedPageDirection = pageIndex >= currentPage
|
|
}
|
|
currentPage = pageIndex
|
|
primePageCache(around: pageIndex, preferredForward: predictedPageDirection)
|
|
}
|
|
|
|
public func heigtOfVerticalScrollPage(flowLayout: RDEpubReaderFlowLayout, pageIndex: Int) -> CGFloat? {
|
|
return nil
|
|
}
|
|
}
|