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

Commit 47f6e909 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Revert "PriorityNestedScrollConnection: make onStop suspendable and add onCancel"

This reverts commit 5a834336.

Reason for revert: causes a crash [1]

[1] https://paste.googleplex.com/6223827163152384

Change-Id: I61376765490df4de205d9861c4ae7b89fc1edbbb
parent a994119a
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -73,19 +73,13 @@ fun NotificationScrimNestedScrollConnection(
            snapScrimOffset(currentHeight + amountConsumed)
            amountConsumed
        },
        // Don't consume the velocity on pre/post fling
        onStop = { velocityAvailable ->
            onStop(velocityAvailable)
            if (scrimOffset() < minScrimOffset()) {
                animateScrimOffset(minScrimOffset())
            }
            // Don't consume the velocity on pre/post fling
            0f
        },
        onCancel = {
            onStop(0f)
            if (scrimOffset() < minScrimOffset()) {
                animateScrimOffset(minScrimOffset())
            }
            { 0f }
        },
    )
}
+1 −2
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ fun NotificationStackNestedScrollConnection(
        },
        onStop = { velocityAvailable ->
            onStop(velocityAvailable)
            velocityAvailable
            suspend { velocityAvailable }
        },
        onCancel = { onStop(0f) },
    )
}
+5 −14
Original line number Diff line number Diff line
@@ -27,10 +27,9 @@ 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
@@ -735,18 +734,10 @@ internal class NestedScrollHandlerImpl(
            },
            onStop = { velocityAvailable ->
                val controller = dragController ?: error("Should be called after onStart")
                try {

                controller
                    .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
                        .invoke()
                } finally {
                    dragController = null
                }
            },
            onCancel = {
                val controller = dragController ?: error("Should be called after onStart")
                controller.onStop(velocity = 0f, canChangeContent = canChangeScene)
                dragController = null
                    .also { dragController = null }
            },
        )
    }
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ 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

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