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

Commit f3c34ce1 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Android (Google) Code Review
Browse files

Merge changes I806a00ef,I38152f77 into main

* changes:
  Use the slow spatial spec in OffsetOverscrollEffect
  Use DecayAnimationSpec to animate to SwipeAnimation targetOffset
parents 1d61cdf3 d5abe5e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import kotlinx.coroutines.CoroutineScope
@Composable
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
fun rememberOffsetOverscrollEffect(
    animationSpec: AnimationSpec<Float> = MaterialTheme.motionScheme.defaultSpatialSpec()
    animationSpec: AnimationSpec<Float> = MaterialTheme.motionScheme.slowSpatialSpec()
): OffsetOverscrollEffect {
    val animationScope = rememberCoroutineScope()
    return remember(animationScope, animationSpec) {
@@ -51,7 +51,7 @@ fun rememberOffsetOverscrollEffect(
@Composable
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
fun rememberOffsetOverscrollEffectFactory(
    animationSpec: AnimationSpec<Float> = MaterialTheme.motionScheme.defaultSpatialSpec()
    animationSpec: AnimationSpec<Float> = MaterialTheme.motionScheme.slowSpatialSpec()
): OverscrollFactory {
    val animationScope = rememberCoroutineScope()
    return remember(animationScope, animationSpec) {
+8 −1
Original line number Diff line number Diff line
@@ -127,7 +127,14 @@ internal class DraggableHandler(
                directionChangeSlop = layoutImpl.directionChangeSlop,
            )

        return createSwipeAnimation(layoutImpl, result, isUpOrLeft, orientation, gestureContext)
        return createSwipeAnimation(
            layoutImpl,
            result,
            isUpOrLeft,
            orientation,
            gestureContext,
            layoutImpl.decayAnimationSpec,
        )
    }

    private fun resolveSwipeSource(startedPosition: Offset): SwipeSource.Resolved? {
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ internal fun PredictiveBackHandler(
                distance = 1f,
                gestureContext =
                    ProvidedGestureContext(dragOffset = 0f, direction = InputDirection.Max),
                decayAnimationSpec = layoutImpl.decayAnimationSpec,
            )

        animateProgress(
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.compose.animation.scene

import androidx.annotation.FloatRange
import androidx.compose.animation.rememberSplineBasedDecay
import androidx.compose.foundation.LocalOverscrollFactory
import androidx.compose.foundation.OverscrollEffect
import androidx.compose.foundation.OverscrollFactory
@@ -747,6 +748,7 @@ internal fun SceneTransitionLayoutForTesting(
    val layoutDirection = LocalLayoutDirection.current
    val defaultEffectFactory = checkNotNull(LocalOverscrollFactory.current)
    val animationScope = rememberCoroutineScope()
    val decayAnimationSpec = rememberSplineBasedDecay<Float>()
    val layoutImpl = remember {
        SceneTransitionLayoutImpl(
                state = state as MutableSceneTransitionLayoutStateImpl,
@@ -762,6 +764,7 @@ internal fun SceneTransitionLayoutForTesting(
                lookaheadScope = lookaheadScope,
                directionChangeSlop = directionChangeSlop,
                defaultEffectFactory = defaultEffectFactory,
                decayAnimationSpec = decayAnimationSpec,
            )
            .also { onLayoutImpl?.invoke(it) }
    }
@@ -801,6 +804,7 @@ internal fun SceneTransitionLayoutForTesting(
        layoutImpl.swipeSourceDetector = swipeSourceDetector
        layoutImpl.swipeDetector = swipeDetector
        layoutImpl.transitionInterceptionThreshold = transitionInterceptionThreshold
        layoutImpl.decayAnimationSpec = decayAnimationSpec
    }

    layoutImpl.Content(modifier)
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.compose.animation.scene

import androidx.annotation.VisibleForTesting
import androidx.compose.animation.core.DecayAnimationSpec
import androidx.compose.foundation.OverscrollFactory
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
@@ -82,6 +83,7 @@ internal class SceneTransitionLayoutImpl(
    internal var swipeSourceDetector: SwipeSourceDetector,
    internal var swipeDetector: SwipeDetector,
    internal var transitionInterceptionThreshold: Float,
    internal var decayAnimationSpec: DecayAnimationSpec<Float>,
    builder: SceneTransitionLayoutScope<InternalContentScope>.() -> Unit,

    /**
Loading