Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dc3f705 authored by Omar Miatello's avatar Omar Miatello Committed by omarmt
Browse files

Revert^2 "PriorityNestedScrollConnection: make onStop suspendable and add onCancel"

This reverts commit 47f6e909.

Reason for revert: A fix will be applied on top of this revert

Change-Id: Ia313f5f30193ea5ac3c147302488ed45c68131f2
parent 13c0ec43
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -73,13 +73,19 @@ fun NotificationScrimNestedScrollConnection(
            snapScrimOffset(currentHeight + amountConsumed)
            amountConsumed
        },
        // Don't consume the velocity on pre/post fling
        onStop = { velocityAvailable ->
            onStop(velocityAvailable)
            if (scrimOffset() < minScrimOffset()) {
                animateScrimOffset(minScrimOffset())
            }
            { 0f }
            // Don't consume the velocity on pre/post fling
            0f
        },
        onCancel = {
            onStop(0f)
            if (scrimOffset() < minScrimOffset()) {
                animateScrimOffset(minScrimOffset())
            }
        },
    )
}
+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ fun NotificationStackNestedScrollConnection(
        },
        onStop = { velocityAvailable ->
            onStop(velocityAvailable)
            suspend { velocityAvailable }
            velocityAvailable
        },
        onCancel = { onStop(0f) },
    )
}
+14 −5
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ import com.android.compose.animation.scene.content.Content
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue

internal typealias SuspendedValue<T> = suspend () -> T

internal interface DraggableHandler {
    /**
     * Start a drag in the given [startedPosition], with the given [overSlop] and number of
@@ -737,10 +738,18 @@ internal class NestedScrollHandlerImpl(
            },
            onStop = { velocityAvailable ->
                val controller = dragController ?: error("Should be called after onStart")

                try {
                    controller
                        .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
                    .also { dragController = null }
                        .invoke()
                } finally {
                    dragController = null
                }
            },
            onCancel = {
                val controller = dragController ?: error("Should be called after onStart")
                controller.onStop(velocity = 0f, canChangeContent = canChangeScene)
                dragController = null
            },
        )
    }
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.unit.IntSize
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue
import kotlinx.coroutines.CompletableDeferred

+2 −1
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ fun LargeTopAppBarNestedScrollConnection(
            amountConsumed
        },
        // Don't consume the velocity on pre/post fling
        onStop = { { 0f } },
        onStop = { 0f },
        onCancel = { /* do nothing */ },
    )
}
Loading