Position persistence during orientation change (#64)
* Fixed PDF reading position restoration during orientation change * Refactored navigation logic in `EpubReaderScreen` and `PaginatedReader` to improve position restoration and UI consistency. - Renamed `isNavigatingToBookmark` to `isNavigatingToPosition` and updated the overlay UI to reflect general position navigation. - Added an orientation change listener to restore the reading position in `VERTICAL_SCROLL` mode using the last known locator. - Improved highlight navigation in `VERTICAL_SCROLL` and `PAGINATED` modes, including chunk injection logic for highlights and fallback pagination logic. - Implemented an anchor locator mechanism in `PaginatedReader` to preserve the reading position during layout constraint changes (e.g., orientation or resizing).
This commit is contained in:
parent
843a77d0ef
commit
74e2cec415
6 changed files with 235 additions and 119 deletions
|
|
@ -419,6 +419,7 @@ internal fun PdfVerticalReader(
|
|||
|
||||
state.snapToPageHandler = { index ->
|
||||
val clampedPanY = calculateTargetPanY(index)
|
||||
Timber.tag("PdfPositionDebug").d("VerticalReader: snapToPage($index) called. ClampedPanY: $clampedPanY")
|
||||
if (clampedPanY != null) {
|
||||
panYAnimatable.snapTo(clampedPanY)
|
||||
}
|
||||
|
|
@ -1210,9 +1211,7 @@ internal fun PdfVerticalReader(
|
|||
|
||||
LaunchedEffect(visiblePages, screenHeight) {
|
||||
snapshotFlow {
|
||||
Pair(
|
||||
panYAnimatable.value, zoomAnimatable.value
|
||||
)
|
||||
Pair(panYAnimatable.value, zoomAnimatable.value)
|
||||
}.collectLatest { (panY, zoom) ->
|
||||
if (visiblePages.isNotEmpty()) {
|
||||
state.firstVisiblePage = visiblePages.first().index
|
||||
|
|
@ -1228,6 +1227,7 @@ internal fun PdfVerticalReader(
|
|||
}
|
||||
|
||||
if (mostVisible != null && mostVisible.index != state.currentPage) {
|
||||
Timber.tag("PdfPositionDebug").v("VerticalReader: Page changed to ${mostVisible.index} (PanY: $panY)")
|
||||
state.currentPage = mostVisible.index
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue