Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ private class NestedScrollToSceneNode( ) : DelegatingNode() { private var scrollBehaviorOwner: ScrollBehaviorOwner? = null private fun requireScrollBehaviorOwner(): ScrollBehaviorOwner { private fun findScrollBehaviorOwner(): ScrollBehaviorOwner? { var behaviorOwner = scrollBehaviorOwner if (behaviorOwner == null) { behaviorOwner = requireScrollBehaviorOwner(layoutImpl.draggableHandler(orientation)) behaviorOwner = findScrollBehaviorOwner(layoutImpl.draggableHandler(orientation)) scrollBehaviorOwner = behaviorOwner } return behaviorOwner Loading @@ -156,8 +156,8 @@ private class NestedScrollToSceneNode( // transition between scenes. We can assume that the behavior is only needed if // there is some remaining amount. if (available != Offset.Zero) { requireScrollBehaviorOwner() .updateScrollBehaviors( findScrollBehaviorOwner() ?.updateScrollBehaviors( topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, isExternalOverscrollGesture = isExternalOverscrollGesture, Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt +5 −8 Original line number Diff line number Diff line Loading @@ -172,15 +172,12 @@ private class SwipeToSceneNode( } /** Find the [ScrollBehaviorOwner] for the current orientation. */ internal fun DelegatableNode.requireScrollBehaviorOwner( internal fun DelegatableNode.findScrollBehaviorOwner( draggableHandler: DraggableHandlerImpl ): ScrollBehaviorOwner { val ancestorNode = checkNotNull(findNearestAncestor(draggableHandler.nestedScrollKey)) { "This should never happen! Couldn't find a ScrollBehaviorOwner. " + "Are we inside an SceneTransitionLayout?" } return ancestorNode as ScrollBehaviorOwner ): ScrollBehaviorOwner? { // If there are no scenes in a particular orientation, the corresponding ScrollBehaviorOwnerNode // is removed from the composition. return findNearestAncestor(draggableHandler.nestedScrollKey) as? ScrollBehaviorOwner } internal fun interface ScrollBehaviorOwner { Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt +34 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,40 @@ class NestedScrollToSceneTest { assertThat(state.transitionState).hasCurrentScene(SceneB) } @Test fun stlNotConsumeUnobservedGesture() { val state = rule.runOnUiThread { MutableSceneTransitionLayoutState(SceneA, transitions = EmptyTestTransitions) } rule.setContent { touchSlop = LocalViewConfiguration.current.touchSlop SceneTransitionLayout( state = state, modifier = Modifier.size(layoutWidth, layoutHeight), ) { scene(SceneA) { Spacer( Modifier.verticalNestedScrollToScene() // This scrollable will not consume the gesture. .scrollable(rememberScrollableState { 0f }, Vertical) .fillMaxSize() ) } } } rule.onRoot().performTouchInput { down(Offset.Zero) // There is no vertical scene. moveBy(Offset(0f, layoutWidth.toPx()), delayMillis = 1_000) } rule.waitForIdle() assertThat(state.transitionState).isIdle() } @Test fun customizeStlNestedScrollBehavior_multipleRequests() { var canScroll = true Loading Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ private class NestedScrollToSceneNode( ) : DelegatingNode() { private var scrollBehaviorOwner: ScrollBehaviorOwner? = null private fun requireScrollBehaviorOwner(): ScrollBehaviorOwner { private fun findScrollBehaviorOwner(): ScrollBehaviorOwner? { var behaviorOwner = scrollBehaviorOwner if (behaviorOwner == null) { behaviorOwner = requireScrollBehaviorOwner(layoutImpl.draggableHandler(orientation)) behaviorOwner = findScrollBehaviorOwner(layoutImpl.draggableHandler(orientation)) scrollBehaviorOwner = behaviorOwner } return behaviorOwner Loading @@ -156,8 +156,8 @@ private class NestedScrollToSceneNode( // transition between scenes. We can assume that the behavior is only needed if // there is some remaining amount. if (available != Offset.Zero) { requireScrollBehaviorOwner() .updateScrollBehaviors( findScrollBehaviorOwner() ?.updateScrollBehaviors( topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, isExternalOverscrollGesture = isExternalOverscrollGesture, Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt +5 −8 Original line number Diff line number Diff line Loading @@ -172,15 +172,12 @@ private class SwipeToSceneNode( } /** Find the [ScrollBehaviorOwner] for the current orientation. */ internal fun DelegatableNode.requireScrollBehaviorOwner( internal fun DelegatableNode.findScrollBehaviorOwner( draggableHandler: DraggableHandlerImpl ): ScrollBehaviorOwner { val ancestorNode = checkNotNull(findNearestAncestor(draggableHandler.nestedScrollKey)) { "This should never happen! Couldn't find a ScrollBehaviorOwner. " + "Are we inside an SceneTransitionLayout?" } return ancestorNode as ScrollBehaviorOwner ): ScrollBehaviorOwner? { // If there are no scenes in a particular orientation, the corresponding ScrollBehaviorOwnerNode // is removed from the composition. return findNearestAncestor(draggableHandler.nestedScrollKey) as? ScrollBehaviorOwner } internal fun interface ScrollBehaviorOwner { Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt +34 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,40 @@ class NestedScrollToSceneTest { assertThat(state.transitionState).hasCurrentScene(SceneB) } @Test fun stlNotConsumeUnobservedGesture() { val state = rule.runOnUiThread { MutableSceneTransitionLayoutState(SceneA, transitions = EmptyTestTransitions) } rule.setContent { touchSlop = LocalViewConfiguration.current.touchSlop SceneTransitionLayout( state = state, modifier = Modifier.size(layoutWidth, layoutHeight), ) { scene(SceneA) { Spacer( Modifier.verticalNestedScrollToScene() // This scrollable will not consume the gesture. .scrollable(rememberScrollableState { 0f }, Vertical) .fillMaxSize() ) } } } rule.onRoot().performTouchInput { down(Offset.Zero) // There is no vertical scene. moveBy(Offset(0f, layoutWidth.toPx()), delayMillis = 1_000) } rule.waitForIdle() assertThat(state.transitionState).isIdle() } @Test fun customizeStlNestedScrollBehavior_multipleRequests() { var canScroll = true Loading