Skip to content

Sync. #383

Open
osphvdhwj wants to merge 6 commits intoAnimetailapp:masterfrom
osphvdhwj:master
Open

Sync. #383
osphvdhwj wants to merge 6 commits intoAnimetailapp:masterfrom
osphvdhwj:master

Conversation

@osphvdhwj
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hold-to-drag speed feature to the video player, allowing users to dynamically adjust playback speed between 1.0x and 4.0x via long-press and horizontal drag gestures. It also adds a visual overlay with an animated chevron to indicate the active speed. Feedback focuses on improving code maintainability by extracting duplicated logic in the drag event handlers and replacing magic numbers with named constants.

Comment on lines 218 to +233
isLongPressing = true
viewModel.pause()
viewModel.sheetShown.update { Sheets.Screenshot }
}
},
onDragEnd = {
if (isHoldingDoubleSpeed) {
isHoldingDoubleSpeed = false
MPVLib.setPropertyDouble("speed", capturedOriginalSpeed)
viewModel.playerUpdate.update { PlayerUpdates.None }
}
if (isLongPressing) isLongPressing = false
},
onDragCancel = {
if (isHoldingDoubleSpeed) {
isHoldingDoubleSpeed = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic in onDragEnd and onDragCancel is identical. To improve maintainability and avoid duplication, you could extract this logic into a local function or a lambda defined within the pointerInput scope.

Comment on lines +238 to +244
},
onDrag = { change, dragAmount ->
if (isHoldingDoubleSpeed) {
change.consume()
dragTotalX += dragAmount.x
val dragSensitivity = 0.005f
val speedDelta = dragTotalX * dragSensitivity
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for hold-to-drag speed uses several magic numbers (0.005f, 2.0f, 1.0f, 4.0f, 0.1f, 10.0f). It would be beneficial for readability and maintainability to extract these into named constants at the top of the file or in a companion object.

For example:

private const val DRAG_SENSITIVITY = 0.005f
private const val INITIAL_HOLD_SPEED = 2.0f
private const val MIN_DRAG_SPEED = 1.0f
private const val MAX_DRAG_SPEED = 4.0f
private const val SPEED_UPDATE_THRESHOLD = 0.1f

This applies to lines 123, 210, 211, and this onDrag block.

@Dark25
Copy link
Copy Markdown
Collaborator

Dark25 commented Apr 14, 2026

Hi, can you give me a description and title of what you would like to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants