ReadViewSDK/.planning/phases/06-page-geometry-and-interaction-hit-layer/06-02-PLAN.md
2026-05-22 14:20:33 +08:00

3.4 KiB

phase plan type wave depends_on files_modified autonomous requirements
6 06-02 execute 2
06-01
Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift
Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift
Sources/RDReaderView/EPUBUI/RDEPUBSelectionOverlayView.swift
Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift
true
LAYOUT-02
LAYOUT-03

Phase 6-02: Selection Overlay and Hit Flow

Move native text selection presentation onto a custom overlay backed by page geometry while keeping the controller-owned selection state, persistence, and absolute offset payload unchanged.

<must_haves>

  • Selection rendering is driven by overlay geometry, not by the default UITextView selection chrome.
  • RDEPUBReaderController remains the single owner of current selection, persistence, and menu actions.
  • Selections still round-trip through RDEPUBTextOffsetRangeInfo and preserve absolute offsets. </must_haves>
execute Add `RDEPUBSelectionOverlayView` and embed it in `RDEPUBTextContentView` as the visual selection surface. Use the page geometry from 06-01 to draw the selected range and page-local hit regions, while leaving `UITextView` as the text host and input source. - Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift - Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift - Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift - Sources/RDReaderView/EPUBTextRendering/RDEPUBTextLayoutFrame.swift - A dedicated overlay view or layer exists for native selection presentation. - Overlay updates when a new selection is made, when the page is reconfigured, and when selection is cleared. - The visible selection treatment no longer depends on `UITextView`'s default selection chrome as the primary presentation path. execute Update the `RDEPUBTextContentView` delegate flow so selection changes still produce `RDEPUBSelection` objects with absolute offsets, `RDEPUBReaderController` still normalizes and persists them, and copy/highlight/annotate menu actions continue to work through the same controller-owned selection state. - Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift - Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift - Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift - Sources/RDReaderView/EPUBTextRendering/RDEPUBTextBookBuilder.swift - `currentSelection` still updates when the user changes the selection. - Selection menu actions still route through the controller and continue to create highlights or annotations. - Clearing the selection clears both the overlay state and the controller's current selection. - Build and run `ReadViewDemo` on the simulator. - Select text in a native reflowable sample and confirm the overlay is the visible selection surface. - Trigger copy/highlight/annotate actions and confirm the controller still receives a valid selection payload.

<success_criteria>

  • Selection presentation is overlay-backed.
  • Selection state still round-trips through absolute offsets.
  • Reader interaction behavior remains stable for native text pages. </success_criteria>