ReadViewSDK/Sources/RDReaderView/ReaderView/RDReaderViewProtocols.swift
shen 948004eed1 docs: 补充注释、修正过时文档、清理重复内容
源码注释:
- 为 ~60 个 Swift 文件补充缺失的 doc comment(file header、类型、属性、方法)
- 修正 4 处错误注释:翻页模式数量、搜索行为描述、手势识别器描述、悬空文档块

文档维护:
- 删除重复文档:WXRead/读书EPUB阅读器实现架构.md(与微信读书版完全一致)
- 合并重叠文档:阅读器规划.md → 阅读器功能开发计划.md(单一真值)
- 修正过时内容:所有文档中"四种翻页模式"→"三种",移除 horizontalCoverScroll
- 更新架构图:补齐 EPUBUI/ReaderController、Paging/、Typesetter/ 等子目录
- 更新 index.md 索引:新增开发计划和架构对比文档引用
2026-06-01 09:33:23 +08:00

111 lines
4.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// RDReaderViewProtocols.swift
// ReadViewSDK
//
//
//
import UIKit
///
/// RDReaderView
/// RDReaderView
@objc public protocol RDReaderDataSource: NSObjectProtocol {
///
func pageCountOfReaderView(readerView: RDReaderView) -> Int
///
func pageContentView(readerView: RDReaderView, pageNum: Int, containerView: UIView?) -> UIView
/// UICollectionViewCell
func pageIdentifier(readerView: RDReaderView, pageNum: Int) -> String?
/// /
@objc optional func topToolView(readerView: RDReaderView) -> UIView?
/// /
@objc optional func bottomToolView(readerView: RDReaderView) -> UIView?
}
///
/// EPUB ``RDReaderDataSource``便 PDF
@objc public protocol RDReaderPageProvider: NSObjectProtocol {
///
func numberOfPages(in readerView: RDReaderView) -> Int
/// reusableView
func readerView(_ readerView: RDReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView
/// UICollectionViewCell
@objc optional func pageIdentifier(in readerView: RDReaderView, index: Int) -> String?
///
@objc optional func readerViewTopChrome(_ readerView: RDReaderView) -> UIView?
///
@objc optional func readerViewBottomChrome(_ readerView: RDReaderView) -> UIView?
}
///
///
@objc public protocol RDReaderDelegate: NSObjectProtocol {
///
func pageNum(readerView: RDReaderView, pageNum: Int)
///
@objc optional func readerViewOrientationWillChange(readerView: RDReaderView, isLandscape: Bool)
}
///
///
public protocol RDReaderPageNavigating: AnyObject {
///
var currentPage: Int { get }
///
func reloadPages()
///
func transition(to page: Int, animated: Bool)
}
// MARK: -
extension RDReaderView {
/// RDReaderView 使
public enum DisplayType {
/// 仿使 UIPageViewController
case pageCurl
/// 使 UICollectionView +
case horizontalScroll
/// 使 UICollectionView
case verticalScroll
}
///
public enum PageDirection {
/// /
case leftToRight
///
case rightToLeft
}
}
// MARK: - Legacy
///
/// ``RDReaderDataSource`` ``RDReaderPageProvider``
final class RDReaderLegacyDataSourceAdapter: NSObject, RDReaderPageProvider {
///
weak var dataSource: RDReaderDataSource?
func numberOfPages(in readerView: RDReaderView) -> Int {
dataSource?.pageCountOfReaderView(readerView: readerView) ?? 0
}
func readerView(_ readerView: RDReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView {
dataSource?.pageContentView(readerView: readerView, pageNum: index, containerView: reusableView) ?? UIView()
}
func pageIdentifier(in readerView: RDReaderView, index: Int) -> String? {
dataSource?.pageIdentifier(readerView: readerView, pageNum: index)
}
func readerViewTopChrome(_ readerView: RDReaderView) -> UIView? {
dataSource?.topToolView?(readerView: readerView)
}
func readerViewBottomChrome(_ readerView: RDReaderView) -> UIView? {
dataSource?.bottomToolView?(readerView: readerView)
}
}