---
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
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.
- 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.
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.
- Selection presentation is overlay-backed.
- Selection state still round-trips through absolute offsets.
- Reader interaction behavior remains stable for native text pages.