Pdf auto scroll (#5)
* docs: Revamp README and add APK naming convention This commit introduces a complete overhaul of the `README.md` to improve project presentation. Key changes include: * Adds a new header with the app icon and a Google Play badge. * Updates the feature graphic and includes a note distinguishing the OSS version from the Play Store version. * Refines the "Open Source Libraries" section to be more structured. * Moves the main preview image into the `docs` directory. Additionally, the `app/build.gradle.kts` file is updated to configure a standardized naming convention for output APK files, including flavor, version, and build type. * refactor copyright headers and fix README icon alignment This commit introduces two main changes across the codebase: The `spotless/copyright.kt` template have been updated for consistency: * The author name is simplified from "Episteme Authors" to "Episteme". * The contact email prefix is shortened from "Electronic mail:" to "mail:". Second, the `README.md` file is adjusted to correct the vertical alignment of the app icon with the project title. * Added auto-scroll feature for PDF vertical reader
This commit is contained in:
parent
1f35cd8138
commit
1b048c9073
3 changed files with 127 additions and 7 deletions
|
|
@ -17,6 +17,7 @@
|
|||
*
|
||||
* mail: epistemereader@gmail.com
|
||||
*/
|
||||
// PdfVerticalReader.kt
|
||||
@file:Suppress("COMPOSE_APPLIER_CALL_MISMATCH", "VariableNeverRead")
|
||||
|
||||
package com.aryan.reader.pdf
|
||||
|
|
@ -210,7 +211,10 @@ internal fun PdfVerticalReader(
|
|||
onTextBoxSelect: (String) -> Unit = {},
|
||||
bottomContentPaddingPx: Float = 0f,
|
||||
topContentPaddingPx: Float = 0f,
|
||||
onTextBoxMoved: (String, Int, Rect) -> Unit = { _, _, _ -> }
|
||||
onTextBoxMoved: (String, Int, Rect) -> Unit = { _, _, _ -> },
|
||||
isAutoScrollPlaying: Boolean = false,
|
||||
autoScrollSpeed: Float = 1.0f,
|
||||
onInteractionListener: () -> Unit = {}
|
||||
) {
|
||||
SideEffect { Timber.tag("PdfDrawPerf").v("LIST: PdfVerticalReader Recomposing.") }
|
||||
var globalEraserPosition by remember { mutableStateOf<Offset?>(null) }
|
||||
|
|
@ -480,9 +484,46 @@ internal fun PdfVerticalReader(
|
|||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(isAutoScrollPlaying, autoScrollSpeed, totalDocHeight, screenHeight) {
|
||||
if (isAutoScrollPlaying) {
|
||||
val baseSpeedPxPerSec = 30f
|
||||
var lastFrameTime = withFrameNanos { it }
|
||||
|
||||
while (isActive) {
|
||||
val frameTime = withFrameNanos { it }
|
||||
val deltaSeconds = (frameTime - lastFrameTime) / 1_000_000_000f
|
||||
lastFrameTime = frameTime
|
||||
|
||||
if (deltaSeconds > 0.1f) continue
|
||||
|
||||
val pixelMove = (baseSpeedPxPerSec * autoScrollSpeed) * deltaSeconds
|
||||
|
||||
val currentPanY = panYAnimatable.value
|
||||
val currentZoom = zoomAnimatable.value
|
||||
val zoomedDocHeight = totalDocHeight * currentZoom
|
||||
|
||||
val minPanY = (screenHeight - footerHeightPx - zoomedDocHeight).coerceAtMost(headerHeightPx)
|
||||
|
||||
val newPanY = (currentPanY - pixelMove).coerceIn(minPanY, headerHeightPx)
|
||||
|
||||
panYAnimatable.snapTo(newPanY)
|
||||
|
||||
@Suppress("ControlFlowWithEmptyBody") if (newPanY <= minPanY + 0.1f) {
|
||||
// Reached end
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var highResScale by remember { mutableFloatStateOf(1f) }
|
||||
var isInteracting by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(isInteracting) {
|
||||
if (isInteracting && isAutoScrollPlaying) {
|
||||
onInteractionListener()
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(isInteracting) {
|
||||
Timber.tag("PdfTouchDebug").i("VerticalReader: isInteracting changed to $isInteracting")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue