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
|
|
@ -530,6 +530,20 @@ fun PaginatedReaderScreen(
|
|||
var debouncedTextAlign by remember { mutableStateOf(textAlign) }
|
||||
|
||||
var anchorLocatorForReconfig by remember { mutableStateOf<Locator?>(null) }
|
||||
val currentPaginatorRef = remember { mutableStateOf<IPaginator?>(null) }
|
||||
|
||||
val previousConstraints = remember { arrayOf(this.constraints) }
|
||||
if (previousConstraints[0] != this.constraints) {
|
||||
val activePaginator = currentPaginatorRef.value
|
||||
if (activePaginator is BookPaginator) {
|
||||
val currentPage = pagerState.currentPage
|
||||
val locator = activePaginator.getLocatorForPage(currentPage)
|
||||
if (locator != null) {
|
||||
anchorLocatorForReconfig = locator
|
||||
}
|
||||
}
|
||||
previousConstraints[0] = this.constraints
|
||||
}
|
||||
|
||||
val textStyle = remember(
|
||||
baseTextStyle,
|
||||
|
|
@ -556,8 +570,6 @@ fun PaginatedReaderScreen(
|
|||
)
|
||||
}
|
||||
|
||||
val currentPaginatorRef = remember { mutableStateOf<IPaginator?>(null) }
|
||||
|
||||
LaunchedEffect(fontSizeMultiplier, lineHeightMultiplier, fontFamily, textAlign) {
|
||||
if (fontSizeMultiplier != debouncedFontSizeMult || lineHeightMultiplier != debouncedLineHeightMult || fontFamily != debouncedFontFamily || textAlign != debouncedTextAlign) {
|
||||
Timber.d("Formatting changed. Waiting for debounce.")
|
||||
|
|
@ -2902,7 +2914,7 @@ private fun PaginatedTextSelectionMenu(
|
|||
onHighlight: ((HighlightColor) -> Unit)?,
|
||||
onDelete: (() -> Unit)?,
|
||||
@Suppress("unused") isProUser: Boolean,
|
||||
isOss: Boolean,
|
||||
@Suppress("unused") isOss: Boolean,
|
||||
activeHighlightPalette: List<HighlightColor> = emptyList(),
|
||||
onOpenPaletteManager: (() -> Unit)? = null
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue