-
Notifications
You must be signed in to change notification settings - Fork 188
Add PDF fit preference
#680
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
Conversation
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.
Pull request overview
This PR adds a new fit preference for PDF documents to control how pages are scaled within the viewport, along with redesigning the Fit enum and adjusting content inset behavior for different devices.
- Introduces a
fitpreference (auto/page/width) for PDF documents to control page scaling, effective only in scroll mode - Redesigns the
Fitenum from cover/contain/width/height to auto/page/width (breaking change) - Changes PDF navigator content inset behavior: iPhones retain safe area insets (for notch/Dynamic Island), while iPads/macOS display edge-to-edge
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/Navigator/Preferences/Types.swift | Redesigned Fit enum with new values and updated documentation |
| Sources/Navigator/PDF/Preferences/PDFPreferences.swift | Added fit property to preferences struct with proper initialization and merging |
| Sources/Navigator/PDF/Preferences/PDFSettings.swift | Added fit to settings with proper defaults (.auto) and fallback chain |
| Sources/Navigator/PDF/Preferences/PDFPreferencesEditor.swift | Added fit preference editor with supported values and effectiveness condition |
| Sources/Navigator/PDF/PDFDocumentView.swift | Implemented scale factor calculations, content inset logic, and caching for the fit preference |
| Sources/Navigator/PDF/PDFNavigatorViewController.swift | Updated scale factor logic to use new fit preference and handle rotation properly |
| TestApp/Sources/Reader/Common/Preferences/UserPreferences.swift | Integrated fit preference into test app UI with updated enum values |
| CHANGELOG.md | Documented the new feature and breaking changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Changelog
Added
Navigator
fitpreference for PDF documents to control how pages are scaled within the viewport.Changed
Navigator
Fitenum has been redesigned to fit the PDF implementation.Fitenum values.VisualNavigatorDelegate.navigatorContentInset(_:).Implementation notes
I hit a wall implementing the
fitpreference with Apple’s PDFKit. While it works in scroll mode, the paginated mode has critical limitations (maybe because Apple doesn't use it in their own apps like Preview).We could try hacking the internal PDFView view hierarchy, but it would be extremely fragile.