Skip to content

Add ContentInsetPolicy to configure the navigators' content insets - #960

Merged
mickael-menu merged 2 commits into
developfrom
fix/margins-insets
Dec 2, 2026
Merged

mickael-menu merged 2 commits into
developfrom
fix/margins-insets

Conversation

@mickael-menu

Copy link
Copy Markdown
Member

Replaces VisualNavigatorDelegate.navigatorContentInset(_:), EPUBNavigatorDelegate.navigator(_:contentInsetFor:) and EPUBNavigatorViewController.Configuration.contentInset with a ContentInsetPolicy in the navigator configurations: reflowableContentInsetPolicy and fixedContentInsetPolicy for EPUB, contentInsetPolicy for PDF.

Apps can extend the clearingSystemBars(minimum:) and clearingCutoutEdges presets with map(_:) 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

  • New ContentInsetPolicy to compute the insets around the publication content, given in the navigator configuration. Extend the clearingSystemBars(minimum:) and clearingCutoutEdges presets with map(_:), or write your own.

Changed

  • On iPhone, the fixed layouts (EPUB FXL, PDF, etc.) only clear the cutouts along a whole edge, such as the notch or the Dynamic Island. From iOS 27.1, this replaces the whole safe area of the window, so the pages don't move when the status bar is toggled.

Removed

  • VisualNavigatorDelegate.navigatorContentInset(_:), EPUBNavigatorDelegate.navigator(_:contentInsetFor:) and EPUBNavigatorViewController.Configuration.contentInset are removed. Use a ContentInsetPolicy in the navigator configuration instead.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 ContentInsetPolicy presets and composable customization with map(_:).
  • 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

@mickael-menu
mickael-menu merged commit 4a52c7f into develop Dec 2, 2026
12 of 16 checks passed
@mickael-menu
mickael-menu deleted the fix/margins-insets branch December 2, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants