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

77 lines
3.4 KiB
Markdown

---
phase: 6
plan: 06-02
type: execute
wave: 2
depends_on:
- 06-01
files_modified:
- Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift
- Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift
- Sources/RDReaderView/EPUBUI/RDEPUBSelectionOverlayView.swift
- Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift
autonomous: true
requirements:
- LAYOUT-02
- LAYOUT-03
---
# Phase 6-02: Selection Overlay and Hit Flow
<objective>
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.
</objective>
<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>
<tasks>
<task id="06-02-01">
<type>execute</type>
<action>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.</action>
<read_first>
- Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift
- Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift
- Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift
- Sources/RDReaderView/EPUBTextRendering/RDEPUBTextLayoutFrame.swift
</read_first>
<acceptance_criteria>
- 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.
</acceptance_criteria>
</task>
<task id="06-02-02">
<type>execute</type>
<action>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.</action>
<read_first>
- Sources/RDReaderView/EPUBUI/RDEPUBTextContentView.swift
- Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift
- Sources/RDReaderView/EPUBCore/RDEPUBReadingModels.swift
- Sources/RDReaderView/EPUBTextRendering/RDEPUBTextBookBuilder.swift
</read_first>
<acceptance_criteria>
- `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.
</acceptance_criteria>
</task>
</tasks>
<verification>
- 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.
</verification>
<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>