Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt +24 −24 Original line number Diff line number Diff line Loading @@ -73,37 +73,37 @@ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) { internal fun Modifier.nestedScrollToScene( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) = this then NestedScrollToSceneElement( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) private data class NestedScrollToSceneElement( private val layoutImpl: SceneTransitionLayoutImpl, private val orientation: Orientation, private val startBehavior: NestedScrollBehavior, private val endBehavior: NestedScrollBehavior, private val topOrLeftBehavior: NestedScrollBehavior, private val bottomOrRightBehavior: NestedScrollBehavior, ) : ModifierNodeElement<NestedScrollToSceneNode>() { override fun create() = NestedScrollToSceneNode( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) override fun update(node: NestedScrollToSceneNode) { node.update( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) } Loading @@ -111,23 +111,23 @@ private data class NestedScrollToSceneElement( name = "nestedScrollToScene" properties["layoutImpl"] = layoutImpl properties["orientation"] = orientation properties["startBehavior"] = startBehavior properties["endBehavior"] = endBehavior properties["topOrLeftBehavior"] = topOrLeftBehavior properties["bottomOrRightBehavior"] = bottomOrRightBehavior } } private class NestedScrollToSceneNode( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) : DelegatingNode() { private var priorityNestedScrollConnection: PriorityNestedScrollConnection = scenePriorityNestedScrollConnection( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) private var nestedScrollNode: DelegatableNode = Loading @@ -148,8 +148,8 @@ private class NestedScrollToSceneNode( fun update( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) { // Clean up the old nested scroll connection priorityNestedScrollConnection.reset() Loading @@ -160,8 +160,8 @@ private class NestedScrollToSceneNode( scenePriorityNestedScrollConnection( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) nestedScrollNode = nestedScrollModifierNode( Loading @@ -175,12 +175,12 @@ private class NestedScrollToSceneNode( private fun scenePriorityNestedScrollConnection( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) = SceneNestedScrollHandler( gestureHandler = layoutImpl.gestureHandler(orientation = orientation), startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) .connection packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt +17 −7 Original line number Diff line number Diff line Loading @@ -86,16 +86,26 @@ private class SceneScopeImpl( return element(layoutImpl, scene, key) } override fun Modifier.nestedScrollToScene( orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, override fun Modifier.horizontalNestedScrollToScene( leftBehavior: NestedScrollBehavior, rightBehavior: NestedScrollBehavior, ): Modifier = nestedScrollToScene( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, orientation = Orientation.Horizontal, topOrLeftBehavior = leftBehavior, bottomOrRightBehavior = rightBehavior, ) override fun Modifier.verticalNestedScrollToScene( topBehavior: NestedScrollBehavior, bottomBehavior: NestedScrollBehavior ): Modifier = nestedScrollToScene( layoutImpl = layoutImpl, orientation = Orientation.Vertical, topOrLeftBehavior = topBehavior, bottomOrRightBehavior = bottomBehavior, ) @Composable Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt +7 −7 Original line number Diff line number Diff line Loading @@ -495,8 +495,8 @@ private class SceneDraggableHandler( internal class SceneNestedScrollHandler( private val gestureHandler: SceneGestureHandler, private val startBehavior: NestedScrollBehavior, private val endBehavior: NestedScrollBehavior, private val topOrLeftBehavior: NestedScrollBehavior, private val bottomOrRightBehavior: NestedScrollBehavior, ) : NestedScrollHandler { override val connection: PriorityNestedScrollConnection = nestedScrollConnection() Loading Loading @@ -565,8 +565,8 @@ internal class SceneNestedScrollHandler( canStartPostScroll = { offsetAvailable, offsetBeforeStart -> val behavior: NestedScrollBehavior = when { offsetAvailable > 0f -> startBehavior offsetAvailable < 0f -> endBehavior offsetAvailable > 0f -> topOrLeftBehavior offsetAvailable < 0f -> bottomOrRightBehavior else -> return@PriorityNestedScrollConnection false } Loading Loading @@ -594,8 +594,8 @@ internal class SceneNestedScrollHandler( canStartPostFling = { velocityAvailable -> val behavior: NestedScrollBehavior = when { velocityAvailable > 0f -> startBehavior velocityAvailable < 0f -> endBehavior velocityAvailable > 0f -> topOrLeftBehavior velocityAvailable < 0f -> bottomOrRightBehavior else -> return@PriorityNestedScrollConnection false } Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt +17 −7 Original line number Diff line number Diff line Loading @@ -126,14 +126,24 @@ interface SceneScope { * Adds a [NestedScrollConnection] to intercept scroll events not handled by the scrollable * component. * * @param orientation is used to determine if we handle top/bottom or left/right events. * @param startBehavior when we should perform the overscroll animation at the top/left. * @param endBehavior when we should perform the overscroll animation at the bottom/right. * @param leftBehavior when we should perform the overscroll animation at the left. * @param rightBehavior when we should perform the overscroll animation at the right. */ fun Modifier.nestedScrollToScene( orientation: Orientation, startBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, endBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, fun Modifier.horizontalNestedScrollToScene( leftBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, rightBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, ): Modifier /** * Adds a [NestedScrollConnection] to intercept scroll events not handled by the scrollable * component. * * @param topBehavior when we should perform the overscroll animation at the top. * @param bottomBehavior when we should perform the overscroll animation at the bottom. */ fun Modifier.verticalNestedScrollToScene( topBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, bottomBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, ): Modifier /** Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -117,8 +117,8 @@ class SceneGestureHandlerTest { fun nestedScrollConnection(nestedScrollBehavior: NestedScrollBehavior) = SceneNestedScrollHandler( gestureHandler = sceneGestureHandler, startBehavior = nestedScrollBehavior, endBehavior = nestedScrollBehavior, topOrLeftBehavior = nestedScrollBehavior, bottomOrRightBehavior = nestedScrollBehavior, ) .connection Loading Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt +24 −24 Original line number Diff line number Diff line Loading @@ -73,37 +73,37 @@ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) { internal fun Modifier.nestedScrollToScene( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) = this then NestedScrollToSceneElement( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) private data class NestedScrollToSceneElement( private val layoutImpl: SceneTransitionLayoutImpl, private val orientation: Orientation, private val startBehavior: NestedScrollBehavior, private val endBehavior: NestedScrollBehavior, private val topOrLeftBehavior: NestedScrollBehavior, private val bottomOrRightBehavior: NestedScrollBehavior, ) : ModifierNodeElement<NestedScrollToSceneNode>() { override fun create() = NestedScrollToSceneNode( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) override fun update(node: NestedScrollToSceneNode) { node.update( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) } Loading @@ -111,23 +111,23 @@ private data class NestedScrollToSceneElement( name = "nestedScrollToScene" properties["layoutImpl"] = layoutImpl properties["orientation"] = orientation properties["startBehavior"] = startBehavior properties["endBehavior"] = endBehavior properties["topOrLeftBehavior"] = topOrLeftBehavior properties["bottomOrRightBehavior"] = bottomOrRightBehavior } } private class NestedScrollToSceneNode( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) : DelegatingNode() { private var priorityNestedScrollConnection: PriorityNestedScrollConnection = scenePriorityNestedScrollConnection( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) private var nestedScrollNode: DelegatableNode = Loading @@ -148,8 +148,8 @@ private class NestedScrollToSceneNode( fun update( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) { // Clean up the old nested scroll connection priorityNestedScrollConnection.reset() Loading @@ -160,8 +160,8 @@ private class NestedScrollToSceneNode( scenePriorityNestedScrollConnection( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) nestedScrollNode = nestedScrollModifierNode( Loading @@ -175,12 +175,12 @@ private class NestedScrollToSceneNode( private fun scenePriorityNestedScrollConnection( layoutImpl: SceneTransitionLayoutImpl, orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, topOrLeftBehavior: NestedScrollBehavior, bottomOrRightBehavior: NestedScrollBehavior, ) = SceneNestedScrollHandler( gestureHandler = layoutImpl.gestureHandler(orientation = orientation), startBehavior = startBehavior, endBehavior = endBehavior, topOrLeftBehavior = topOrLeftBehavior, bottomOrRightBehavior = bottomOrRightBehavior, ) .connection
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt +17 −7 Original line number Diff line number Diff line Loading @@ -86,16 +86,26 @@ private class SceneScopeImpl( return element(layoutImpl, scene, key) } override fun Modifier.nestedScrollToScene( orientation: Orientation, startBehavior: NestedScrollBehavior, endBehavior: NestedScrollBehavior, override fun Modifier.horizontalNestedScrollToScene( leftBehavior: NestedScrollBehavior, rightBehavior: NestedScrollBehavior, ): Modifier = nestedScrollToScene( layoutImpl = layoutImpl, orientation = orientation, startBehavior = startBehavior, endBehavior = endBehavior, orientation = Orientation.Horizontal, topOrLeftBehavior = leftBehavior, bottomOrRightBehavior = rightBehavior, ) override fun Modifier.verticalNestedScrollToScene( topBehavior: NestedScrollBehavior, bottomBehavior: NestedScrollBehavior ): Modifier = nestedScrollToScene( layoutImpl = layoutImpl, orientation = Orientation.Vertical, topOrLeftBehavior = topBehavior, bottomOrRightBehavior = bottomBehavior, ) @Composable Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt +7 −7 Original line number Diff line number Diff line Loading @@ -495,8 +495,8 @@ private class SceneDraggableHandler( internal class SceneNestedScrollHandler( private val gestureHandler: SceneGestureHandler, private val startBehavior: NestedScrollBehavior, private val endBehavior: NestedScrollBehavior, private val topOrLeftBehavior: NestedScrollBehavior, private val bottomOrRightBehavior: NestedScrollBehavior, ) : NestedScrollHandler { override val connection: PriorityNestedScrollConnection = nestedScrollConnection() Loading Loading @@ -565,8 +565,8 @@ internal class SceneNestedScrollHandler( canStartPostScroll = { offsetAvailable, offsetBeforeStart -> val behavior: NestedScrollBehavior = when { offsetAvailable > 0f -> startBehavior offsetAvailable < 0f -> endBehavior offsetAvailable > 0f -> topOrLeftBehavior offsetAvailable < 0f -> bottomOrRightBehavior else -> return@PriorityNestedScrollConnection false } Loading Loading @@ -594,8 +594,8 @@ internal class SceneNestedScrollHandler( canStartPostFling = { velocityAvailable -> val behavior: NestedScrollBehavior = when { velocityAvailable > 0f -> startBehavior velocityAvailable < 0f -> endBehavior velocityAvailable > 0f -> topOrLeftBehavior velocityAvailable < 0f -> bottomOrRightBehavior else -> return@PriorityNestedScrollConnection false } Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt +17 −7 Original line number Diff line number Diff line Loading @@ -126,14 +126,24 @@ interface SceneScope { * Adds a [NestedScrollConnection] to intercept scroll events not handled by the scrollable * component. * * @param orientation is used to determine if we handle top/bottom or left/right events. * @param startBehavior when we should perform the overscroll animation at the top/left. * @param endBehavior when we should perform the overscroll animation at the bottom/right. * @param leftBehavior when we should perform the overscroll animation at the left. * @param rightBehavior when we should perform the overscroll animation at the right. */ fun Modifier.nestedScrollToScene( orientation: Orientation, startBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, endBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, fun Modifier.horizontalNestedScrollToScene( leftBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, rightBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, ): Modifier /** * Adds a [NestedScrollConnection] to intercept scroll events not handled by the scrollable * component. * * @param topBehavior when we should perform the overscroll animation at the top. * @param bottomBehavior when we should perform the overscroll animation at the bottom. */ fun Modifier.verticalNestedScrollToScene( topBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, bottomBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview, ): Modifier /** Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -117,8 +117,8 @@ class SceneGestureHandlerTest { fun nestedScrollConnection(nestedScrollBehavior: NestedScrollBehavior) = SceneNestedScrollHandler( gestureHandler = sceneGestureHandler, startBehavior = nestedScrollBehavior, endBehavior = nestedScrollBehavior, topOrLeftBehavior = nestedScrollBehavior, bottomOrRightBehavior = nestedScrollBehavior, ) .connection Loading