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

Commit d163a3a5 authored by omarmt's avatar omarmt
Browse files

Add Transition.canOverscroll()

This method is used to understand if any transformations have been
defined in the overscroll spec and therefore if we can perform the
overscroll gesture.

Test: Just a refactor
Bug: 336710600
Flag: com.android.systemui.scene_container
Change-Id: Ife8ede54a6db6d01c53e19b1b1f8d287fbb09f44
parent 73f32757
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -713,9 +713,7 @@ private class SwipeTransition(
        val hasReachedTargetScene =
            (targetScene == toScene && progress >= 1f) ||
                (targetScene == fromScene && progress <= 0f)
        val skipAnimation =
            hasReachedTargetScene &&
                currentOverscrollSpec?.transformationSpec?.transformations?.isEmpty() == true
        val skipAnimation = hasReachedTargetScene && !canOverscroll()

        return startOffsetAnimation {
            val animatable = Animatable(dragOffset, OffsetVisibilityThreshold)
@@ -768,12 +766,7 @@ private class SwipeTransition(

                                        // Immediately stop this transition if we are bouncing on a
                                        // scene that does not bounce.
                                        val overscrollSpec = currentOverscrollSpec
                                        if (
                                            overscrollSpec != null &&
                                                overscrollSpec.transformationSpec.transformations
                                                    .isEmpty()
                                        ) {
                                        if (!canOverscroll()) {
                                            snapToScene(targetScene)
                                        }
                                    }
+6 −0
Original line number Diff line number Diff line
@@ -219,6 +219,12 @@ sealed interface TransitionState {
                }
            }

        /** Returns if the [progress] value of this transition can go beyond range `[0; 1]` */
        fun canOverscroll(): Boolean {
            val overscrollSpec = currentOverscrollSpec ?: return true
            return overscrollSpec.transformationSpec.transformations.isNotEmpty()
        }

        /**
         * An animatable that animates from 1f to 0f. This will be used to nicely animate the sudden
         * jump of values when this transitions interrupts another one.