forked from readium/swift-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/render custom spread pages properties #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
lbeus
wants to merge
17
commits into
develop
Choose a base branch
from
feature/render-custom-sperad-pages-properties
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6856320
Extend EPUBNavigatorDelegate to support rendering custom native overlay
lbeus bb8ad55
Regenerate EPUB bundled script
lbeus b9f17be
Update guides
lbeus 18834d0
Rename navigator delegate method for adding custom overlay
lbeus 43a5ae7
Allow providing external page view
lbeus f8eda40
Fix lint warnings
lbeus 08acf63
Handle spreads in landscape
lbeus e5da564
Remove unused code
lbeus 6993f93
Update documentation
lbeus 465fb26
Remove commented out code
lbeus 0ff0cb9
Remove OPFParser changes
lbeus 942097e
Remove commented out code
lbeus d24c5c5
Update documentation
lbeus 056b2fb
Add did scroll event support
lbeus 3ea75b5
Fix lint warnings
lbeus 0dce7ca
Merge branch 'develop' into feature/spread-render-customization
lbeus a4649ef
Merge branch 'feature/spread-render-customization' into feature/rende…
lbeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // | ||
| // Copyright 2025 Readium Foundation. All rights reserved. | ||
| // Use of this source code is governed by the BSD-style license | ||
| // available in the top-level LICENSE file of the project. | ||
| // | ||
|
|
||
| import Foundation | ||
| import ReadiumShared | ||
| import UIKit | ||
|
|
||
| class CustomTypeSpreadViewWrapper: UIView, Loggable, PageView, EPUBSpreadViewContainer { | ||
| let spread: EPUBSpread | ||
|
|
||
| init(spread: EPUBSpread) { | ||
| self.spread = spread | ||
| super.init(frame: .zero) | ||
| } | ||
|
|
||
| @available(*, unavailable) | ||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| func progression(in index: ReadingOrder.Index) -> ClosedRange<Double> { | ||
| // To be overridden in subclasses if the resource supports a progression. | ||
| 0 ... 1 | ||
| } | ||
|
|
||
| func go(to location: PageLocation) async { | ||
| // Custom layout resources are always fully visible so we don't use the location | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // | ||
| // Copyright 2025 Readium Foundation. All rights reserved. | ||
| // Use of this source code is governed by the BSD-style license | ||
| // available in the top-level LICENSE file of the project. | ||
| // | ||
|
|
||
| import ReadiumShared | ||
|
|
||
| protocol EPUBSpreadViewContainer { | ||
| var spread: EPUBSpread { get } | ||
| func progression(in index: ReadingOrder.Index) -> ClosedRange<Double> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # EPUBNavigatorDelegate | ||
|
|
||
| Readium allows rendering EPUB spine elements in a custom way (e.g. PDF is rendered using PDFKit instead of being loaded in WKWebView). | ||
| Client can provide custom view for given spread using | ||
| ```swift | ||
| func navigator(_ navigator: EPUBNavigatorViewController, viewControllersForReadingOrderLinks links: [Link]) -> (left: UIViewController?, center: UIViewController?, right: UIViewController?) | ||
| ``` | ||
| delegate method. | ||
|
|
||
| Returned tuple contains left and right pages if spread has 2 pages. Center property is used in case spread has 1 page. | ||
| In case any of spread pages doesn't require custom view ```nil``` is returned for such page, and readium will fallback to webview rendering. | ||
|
|
||
| ```links``` contains array of EPUB spine element links (if spread has 2 pages it will have 2 links, otherwise 1 link). | ||
| EPUB document could hold JSON resource which contains mapping of spine element links to metadata model needed to perform custom rendering (e.g. asset hrefs, custom view type info ...) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken,
publication.readingOrderis an array, right? If so, you might want to use safe index here.