refactor: rename RDReaderView -> RDEpubReaderView, update pod config and docs
- 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
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
public enum RDEPUBFixedLayoutFit: String, Codable {
|
||||
case auto
|
||||
case page
|
||||
case width
|
||||
}
|
||||
|
||||
public enum RDEPUBFixedLayoutSpreadMode: String, Codable {
|
||||
case automatic
|
||||
case always
|
||||
case never
|
||||
}
|
||||
|
||||
public struct RDEPUBPresentationStyle: Equatable {
|
||||
|
||||
public var viewportSize: CGSize
|
||||
|
||||
public var contentInsets: UIEdgeInsets
|
||||
|
||||
public var fontSize: CGFloat
|
||||
|
||||
public var lineHeightMultiple: CGFloat
|
||||
|
||||
public var numberOfColumns: Int
|
||||
|
||||
public var columnGap: CGFloat
|
||||
|
||||
public var themeBackgroundColor: String?
|
||||
|
||||
public var themeTextColor: String?
|
||||
|
||||
public init(
|
||||
viewportSize: CGSize,
|
||||
contentInsets: UIEdgeInsets,
|
||||
fontSize: CGFloat,
|
||||
lineHeightMultiple: CGFloat,
|
||||
numberOfColumns: Int = 1,
|
||||
columnGap: CGFloat = 20,
|
||||
themeBackgroundColor: String? = nil,
|
||||
themeTextColor: String? = nil
|
||||
) {
|
||||
self.viewportSize = viewportSize
|
||||
self.contentInsets = contentInsets
|
||||
self.fontSize = fontSize
|
||||
self.lineHeightMultiple = lineHeightMultiple
|
||||
self.numberOfColumns = max(1, numberOfColumns)
|
||||
self.columnGap = max(0, columnGap)
|
||||
self.themeBackgroundColor = themeBackgroundColor
|
||||
self.themeTextColor = themeTextColor
|
||||
}
|
||||
}
|
||||
|
||||
public struct RDEPUBReflowableRenderRequest: Equatable {
|
||||
|
||||
public var spineIndex: Int
|
||||
|
||||
public var href: String
|
||||
|
||||
public var pageIndex: Int
|
||||
|
||||
public var totalPagesInChapter: Int
|
||||
|
||||
public var presentation: RDEPUBPresentationStyle
|
||||
|
||||
public var targetLocation: RDEPUBLocation?
|
||||
|
||||
public var targetHighlightRangeInfo: String?
|
||||
|
||||
public var highlights: [RDEPUBHighlight]
|
||||
|
||||
public var searchPresentation: RDEPUBSearchPresentation?
|
||||
|
||||
public init(
|
||||
spineIndex: Int,
|
||||
href: String,
|
||||
pageIndex: Int,
|
||||
totalPagesInChapter: Int,
|
||||
presentation: RDEPUBPresentationStyle,
|
||||
targetLocation: RDEPUBLocation? = nil,
|
||||
targetHighlightRangeInfo: String? = nil,
|
||||
highlights: [RDEPUBHighlight] = [],
|
||||
searchPresentation: RDEPUBSearchPresentation? = nil
|
||||
) {
|
||||
self.spineIndex = spineIndex
|
||||
self.href = href
|
||||
self.pageIndex = pageIndex
|
||||
self.totalPagesInChapter = totalPagesInChapter
|
||||
self.presentation = presentation
|
||||
self.targetLocation = targetLocation
|
||||
self.targetHighlightRangeInfo = targetHighlightRangeInfo
|
||||
self.highlights = highlights
|
||||
self.searchPresentation = searchPresentation
|
||||
}
|
||||
}
|
||||
|
||||
public struct RDEPUBFixedRenderRequest: Equatable {
|
||||
|
||||
public var spread: EPUBFixedSpread
|
||||
|
||||
public var viewportSize: CGSize
|
||||
|
||||
public var contentInset: UIEdgeInsets
|
||||
|
||||
public var backgroundColorCSS: String?
|
||||
|
||||
public var fit: RDEPUBFixedLayoutFit
|
||||
|
||||
public var searchPresentation: RDEPUBSearchPresentation?
|
||||
|
||||
public init(
|
||||
spread: EPUBFixedSpread,
|
||||
viewportSize: CGSize,
|
||||
contentInset: UIEdgeInsets,
|
||||
backgroundColorCSS: String? = nil,
|
||||
fit: RDEPUBFixedLayoutFit = .page,
|
||||
searchPresentation: RDEPUBSearchPresentation? = nil
|
||||
) {
|
||||
self.spread = spread
|
||||
self.viewportSize = viewportSize
|
||||
self.contentInset = contentInset
|
||||
self.backgroundColorCSS = backgroundColorCSS
|
||||
self.fit = fit
|
||||
self.searchPresentation = searchPresentation
|
||||
}
|
||||
}
|
||||
|
||||
public enum RDEPUBRenderRequest: Equatable {
|
||||
|
||||
case reflowable(RDEPUBReflowableRenderRequest)
|
||||
|
||||
case fixed(RDEPUBFixedRenderRequest)
|
||||
|
||||
public var isFixedLayout: Bool {
|
||||
if case .fixed = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public var primarySpineIndex: Int {
|
||||
switch self {
|
||||
case .reflowable(let request):
|
||||
return request.spineIndex
|
||||
case .fixed(let request):
|
||||
return request.spread.primaryResource.spineIndex
|
||||
}
|
||||
}
|
||||
|
||||
public var primaryHref: String {
|
||||
switch self {
|
||||
case .reflowable(let request):
|
||||
return request.href
|
||||
case .fixed(let request):
|
||||
return request.spread.primaryResource.href
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user