Skip to content

feat(reader): redesign EPUB reader chrome and progress scrubbing - #1351

Merged
everpcpc merged 4 commits into
mainfrom
feat/epub-reader-chrome
Nov 28, 2026
Merged

everpcpc merged 4 commits into
mainfrom
feat/epub-reader-chrome

Conversation

@everpcpc

@everpcpc everpcpc commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Redesigns the iOS EPUB reader controls after Apple Books, with faster, more stable navigation and zero page reflow when toggling controls.

  • Reader controls now sit in dedicated top and bottom bars outside the page content: Close and Bookmark at the top corners, chapter pages remaining at the top center, and a book-wide progress bar with X of Y page counter and an ellipsis menu (Contents, Theme, Settings, Book Info) at the bottom.
  • Long-press the bottom progress bar to expand and thicken it with chapter dividers and a live callout showing the destination chapter and page as you drag. Releasing jumps there with haptic feedback on grab, release, and page crossings.
  • Jumping via the progress bar, table of contents, bookmarks, or in-book links now remembers where you came from, marks that spot on the progress bar, and offers a one-tap Return button at the bottom-left corner.
  • Showing or hiding the controls slides and fades them smoothly in place without resizing, re-paginating, or flashing the page.
  • Reading header/footer labels remain customizable in EPUB settings; controls-state labels are now fixed to chapter pages remaining and book page position. The Contents sheet opens directly on Bookmarks when a book has bookmarks but no table of contents.
  • Chapter titles now carry over to split chapter files, and measured chapter page counts are cached locally so book-wide page totals are available sooner on reopening.

Side effects: Contents · %@ and epub.overlay.controls are no longer used and are marked stale in Localizable.xcstrings; adds %lld of %lld, Chapter %lld, and epub.overlay.item.book_page across all 10 supported languages. Removes the unused iOS native overlay label plumbing (native overlay labels remain macOS-only).

Validation: make format, make build (iOS/macOS/tvOS), make localize with no missing translations, and iPhone simulator verification across WebView and CoreText engines (toggle stability, long-press scrubbing, return jumps, menu sheets, light/dark themes).

Includes make bump to build 692.

@everpcpc
everpcpc merged commit 60bfba9 into main Nov 28, 2026
3 checks passed
@everpcpc
everpcpc deleted the feat/epub-reader-chrome branch November 28, 2026 05:47
dyphire added a commit to kmworks/kmreader-android that referenced this pull request Nov 28, 2026
…e count (#90)

Ports the navigation half of the iOS reader redesign (kmworks/kmreader#1351)
without its chrome rework: the reader now remembers where every explicit jump
started, names its position in pages across the whole book, and keeps split
chapters under one title.

Return stack. `linkBackStack` lived in the EPUB screen and carried a
(chapterIndex, fraction) pair per in-book link, so the return affordance existed
for links only: a jump through the table of contents, a bookmark or the progress
slider was one-way, and the stack died with the composition. It is now
`EpubPositionHistory` — pure push/pop over an immutable list, 50 entries, a 0.005
fraction tolerance so a tap repeated on the same page does not stack — with the
state owned by the view model. Every explicit jump pushes (toc, bookmark,
slider, in-book link) and nothing else does: page turns and chapter seams stay
out, so "return" always means "the place I jumped from" rather than "undo my
last page turn". `goToChapter` records only when the chapter actually changes; a
same-chapter anchor jump records in the UI, where the page genuinely travels.

Whole-book page count. The reader knew a chapter's page count from the paged
measure pass and nothing else: "Chapter 3 / 12" was as good as it got, and a
scrolled chapter had no page at all. `EpubBookPages` turns per-chapter counts
into a running offset list; `resolveEpubBookPages` mixes measured chapters with
estimates — a chapter the server placed N positions in gets N x (pages this
session has measured / positions those same chapters carried), which absorbs the
reader's font size without needing a text-density model — and the result lands in
`EpubBookPageProgress(currentPage, totalPages)`. The overlay gained a
`BOOK_POSITION` item ("Book 421 / 1,204", all three locales) and the
chrome-visible footer now defaults to it, which is where iOS puts its "X of Y".

Page-count cache. Reopening a book restarted the total from zero, because only
the visited chapters had counts. `EpubPageCountStore` persists href -> pages per
book (memory LRU plus cacheDir/epub-page-counts, the same atomic-rename shape as
the positions index). Its identity is the spine AND a layout signature (flow
style, font size, line height, margins, columns, viewport width, page insets)
pushed in by the UI: a page count is a property of the layout that produced it,
so a font-size change re-measures instead of printing a stale total.

Chapter titles. A chapter split across several spine files named only its head;
the tails fell back to "Chapter 13", "Chapter 14" in the contents. Titles now
resolve as manifest link -> toc entry for that file (deeper entry wins) ->
nearest preceding titled spine item -> positional fallback, and inheritance stops
at chapters that carry a title of their own, so front matter cannot borrow the
chapter that follows it.

Also fixes a pothole this work exposed: a seek that landed inside the current
chapter queued `scrollToFraction`, which only a chapter load consumes. The
numbers moved while the page stood still, and the queued value also hid the
WebView behind its 12s reveal backstop. `seekTo` now returns the fraction for the
caller to scroll the live page with and leaves the reload path to chapter
switches.

Deliberately not ported from the iOS PR: the persistent top/bottom bar shell, the
long-press scrubber with chapter ticks and callouts, and the fixed controls
labels. The iOS preference-key precomputation has no counterpart here and was not
added — overlay preferences serialize only on write, the page theme converts to
JS once per chapter load or on a real theme change, and metrics are throttled to
200ms in the page JS, so nothing serializes per frame.

Validated with :app:compileDebugKotlin, :app:testDebugUnitTest (16 new cases),
:app:assembleDebug and :app:lintDebug. No device run yet: the jump/return
behaviour and the page numbers on a real book still need eyes.
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.

1 participant