- 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
128 lines
3.1 KiB
Swift
128 lines
3.1 KiB
Swift
|
|
import Foundation
|
|
|
|
public struct RDEPUBSearchMatch: Codable, Equatable {
|
|
|
|
public var href: String
|
|
|
|
public var progression: Double
|
|
|
|
public var previewText: String
|
|
|
|
public var localMatchIndex: Int
|
|
|
|
public var rangeLocation: Int?
|
|
|
|
public var rangeLength: Int
|
|
|
|
public var rangeAnchor: RDEPUBTextRangeAnchor?
|
|
|
|
public var cfi: String?
|
|
|
|
public var rangeCFI: String?
|
|
|
|
public init(
|
|
href: String,
|
|
progression: Double,
|
|
previewText: String,
|
|
localMatchIndex: Int,
|
|
rangeLocation: Int? = nil,
|
|
rangeLength: Int,
|
|
rangeAnchor: RDEPUBTextRangeAnchor? = nil,
|
|
cfi: String? = nil,
|
|
rangeCFI: String? = nil
|
|
) {
|
|
self.href = href
|
|
self.progression = progression
|
|
self.previewText = previewText
|
|
self.localMatchIndex = localMatchIndex
|
|
self.rangeLocation = rangeLocation
|
|
self.rangeLength = rangeLength
|
|
self.rangeAnchor = rangeAnchor
|
|
self.cfi = cfi
|
|
self.rangeCFI = rangeCFI
|
|
}
|
|
}
|
|
|
|
public struct RDEPUBSearchResult: Codable, Equatable {
|
|
|
|
public var keyword: String
|
|
|
|
public var totalMatchCount: Int
|
|
|
|
public var currentMatchIndex: Int?
|
|
|
|
public var currentMatch: RDEPUBSearchMatch?
|
|
|
|
public init(
|
|
keyword: String,
|
|
totalMatchCount: Int,
|
|
currentMatchIndex: Int?,
|
|
currentMatch: RDEPUBSearchMatch?
|
|
) {
|
|
self.keyword = keyword
|
|
self.totalMatchCount = totalMatchCount
|
|
self.currentMatchIndex = currentMatchIndex
|
|
self.currentMatch = currentMatch
|
|
}
|
|
}
|
|
|
|
public struct RDEPUBSearchState: Codable, Equatable {
|
|
|
|
public var keyword: String
|
|
|
|
public var matches: [RDEPUBSearchMatch]
|
|
|
|
public var currentMatchIndex: Int?
|
|
|
|
public init(keyword: String, matches: [RDEPUBSearchMatch], currentMatchIndex: Int? = nil) {
|
|
self.keyword = keyword
|
|
self.matches = matches
|
|
self.currentMatchIndex = currentMatchIndex
|
|
}
|
|
|
|
public var currentMatch: RDEPUBSearchMatch? {
|
|
guard let currentMatchIndex,
|
|
matches.indices.contains(currentMatchIndex) else {
|
|
return nil
|
|
}
|
|
return matches[currentMatchIndex]
|
|
}
|
|
|
|
public var result: RDEPUBSearchResult {
|
|
RDEPUBSearchResult(
|
|
keyword: keyword,
|
|
totalMatchCount: matches.count,
|
|
currentMatchIndex: currentMatchIndex.map { $0 + 1 },
|
|
currentMatch: currentMatch
|
|
)
|
|
}
|
|
}
|
|
|
|
public struct RDEPUBSearchPresentationResource: Codable, Equatable {
|
|
|
|
public var href: String
|
|
|
|
public var matchCount: Int
|
|
|
|
public var activeLocalMatchIndex: Int?
|
|
|
|
public init(href: String, matchCount: Int, activeLocalMatchIndex: Int? = nil) {
|
|
self.href = href
|
|
self.matchCount = matchCount
|
|
self.activeLocalMatchIndex = activeLocalMatchIndex
|
|
}
|
|
}
|
|
|
|
public struct RDEPUBSearchPresentation: Codable, Equatable {
|
|
|
|
public var keyword: String
|
|
|
|
public var resources: [RDEPUBSearchPresentationResource]
|
|
|
|
public init(keyword: String, resources: [RDEPUBSearchPresentationResource]) {
|
|
self.keyword = keyword
|
|
self.resources = resources
|
|
}
|
|
}
|