Repository navigation
Add ContentInsetPolicy to configure the navigators' content insets - #960
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the configurable content inset policy changes.
No open issues 🎉
What changed in this PR
Introduces configurable content inset policies for Readium’s EPUB and PDF navigators, replacing delegate-based customization.
Changes:
- Adds
ContentInsetPolicypresets and composable customization withmap(_:). - Updates fixed-layout EPUB and PDF defaults to clear edge cutouts on iPhone.
- Adds policy tests and migration documentation.
| File | Description |
|---|---|
| Tests/NavigatorTests/Toolkit/CutoutInsetsTests.swift | Tests separate edge and hole cutouts and device fallbacks. |
| Tests/NavigatorTests/Toolkit/ContentInsetPolicyTests.swift | Tests presets, minimum insets, and policy mapping. |
| Sources/Navigator/VisualNavigator.swift | Removes the inset delegate method. |
| Sources/Navigator/Toolkit/CutoutInsets.swift | Separates edge and hole cutouts. |
| Sources/Navigator/Toolkit/ContentInsetPolicy.swift | Adds policies, context, presets, and mapping. |
| Sources/Navigator/PDF/PDFNavigatorViewController.swift | Adds configurable PDF inset policy. |
| Sources/Navigator/PDF/PDFDocumentView.swift | Uses navigator-provided insets. |
| Sources/Navigator/EPUB/Preferences/EPUBPreferences.swift | Clarifies page-margin documentation. |
| Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | Replaces legacy customization with per-layout policies. |
| docs/Migration Guide.md | Explains migration and restoring previous defaults. |
| docs/Guides/Navigator/Preferences.md | Updates inset customization guidance. |
| docs/Guides/Navigator/Navigator.md | Documents policy usage and presets. |
| CHANGELOG.md | Records API and default-behavior changes. |
Review effort: Balanced
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replaces
VisualNavigatorDelegate.navigatorContentInset(_:),EPUBNavigatorDelegate.navigator(_:contentInsetFor:)andEPUBNavigatorViewController.Configuration.contentInsetwith aContentInsetPolicyin the navigator configurations:reflowableContentInsetPolicyandfixedContentInsetPolicyfor EPUB,contentInsetPolicyfor PDF.Apps can extend the
clearingSystemBars(minimum:)andclearingCutoutEdgespresets withmap(_:)without losing the cutout handling, and the policy context gives the screen cutouts. On iPhone, EPUB fixed layouts and PDF documents now only clear the cutouts along an edge, so pages don't move when the status bar is toggled and aren't shrunk on a folded iPhone Duo.Changelog
Added
ContentInsetPolicyto compute the insets around the publication content, given in the navigator configuration. Extend theclearingSystemBars(minimum:)andclearingCutoutEdgespresets withmap(_:), or write your own.Changed
Removed
VisualNavigatorDelegate.navigatorContentInset(_:),EPUBNavigatorDelegate.navigator(_:contentInsetFor:)andEPUBNavigatorViewController.Configuration.contentInsetare removed. Use aContentInsetPolicyin the navigator configuration instead.