Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt +9 −25 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ fun ContentScope.animateContentFloatAsState( @Deprecated( "Use animateContentFloatAsState() instead", replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)") replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)"), ) @Composable fun ContentScope.animateSceneFloatAsState( Loading Loading @@ -172,14 +172,11 @@ fun ContentScope.animateContentDpAsState( @Deprecated( "Use animateContentDpAsState() instead", replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)") replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)"), ) @Composable fun ContentScope.animateSceneDpAsState( value: Dp, key: ValueKey, canOverflow: Boolean = true, ) = animateContentDpAsState(value, key, canOverflow) fun ContentScope.animateSceneDpAsState(value: Dp, key: ValueKey, canOverflow: Boolean = true) = animateContentDpAsState(value, key, canOverflow) /** * Animate a shared element Dp value. Loading Loading @@ -214,10 +211,7 @@ private object SharedDpType : SharedValueType<Dp, Dp> { * @see ContentScope.animateContentValueAsState */ @Composable fun ContentScope.animateContentColorAsState( value: Color, key: ValueKey, ): AnimatedState<Color> { fun ContentScope.animateContentColorAsState(value: Color, key: ValueKey): AnimatedState<Color> { return animateContentValueAsState(value, key, SharedColorType, canOverflow = false) } Loading @@ -227,10 +221,7 @@ fun ContentScope.animateContentColorAsState( * @see ElementScope.animateElementValueAsState */ @Composable fun ElementScope<*>.animateElementColorAsState( value: Color, key: ValueKey, ): AnimatedState<Color> { fun ElementScope<*>.animateElementColorAsState(value: Color, key: ValueKey): AnimatedState<Color> { return animateElementValueAsState(value, key, SharedColorType, canOverflow = false) } Loading Loading @@ -274,12 +265,7 @@ private object SharedColorType : SharedValueType<Color, ColorDelta> { * Note: This class is necessary because Color() checks the bounds of its values and UncheckedColor * is internal. */ private class ColorDelta( val red: Float, val green: Float, val blue: Float, val alpha: Float, ) private class ColorDelta(val red: Float, val green: Float, val blue: Float, val alpha: Float) @Composable internal fun <T> animateSharedValueAsState( Loading Loading @@ -331,7 +317,7 @@ internal fun <T> animateSharedValueAsState( private fun <T, Delta> sharedValue( layoutImpl: SceneTransitionLayoutImpl, key: ValueKey, element: ElementKey? element: ElementKey?, ): SharedValue<T, Delta> { return layoutImpl.sharedValues[key]?.get(element)?.let { it as SharedValue<T, Delta> } ?: error(valueReadTooEarlyMessage(key)) Loading @@ -342,9 +328,7 @@ private fun valueReadTooEarlyMessage(key: ValueKey) = "means that you are reading it during composition, which you should not do. See the " + "documentation of AnimatedState for more information." internal class SharedValue<T, Delta>( val type: SharedValueType<T, Delta>, ) { internal class SharedValue<T, Delta>(val type: SharedValueType<T, Delta>) { /** The target value of this shared value for each content. */ val targetValues = SnapshotStateMap<ContentKey, T>() Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +5 −8 Original line number Diff line number Diff line Loading @@ -109,12 +109,12 @@ internal class DraggableHandlerImpl( return (upOrLeft != null && contentTransition.isTransitioningBetween( fromContent.key, upOrLeft.toContent(currentScene) upOrLeft.toContent(currentScene), )) || (downOrRight != null && contentTransition.isTransitioningBetween( fromContent.key, downOrRight.toContent(currentScene) downOrRight.toContent(currentScene), )) } Loading Loading @@ -163,7 +163,7 @@ internal class DraggableHandlerImpl( private fun updateDragController( swipes: Swipes, swipeAnimation: SwipeAnimation<*> swipeAnimation: SwipeAnimation<*>, ): DragControllerImpl { val newDragController = DragControllerImpl(this, swipes, swipeAnimation) newDragController.updateTransition(swipeAnimation, force = true) Loading @@ -171,10 +171,7 @@ internal class DraggableHandlerImpl( return newDragController } internal fun createSwipeAnimation( swipes: Swipes, result: UserActionResult, ): SwipeAnimation<*> { internal fun createSwipeAnimation(swipes: Swipes, result: UserActionResult): SwipeAnimation<*> { val upOrLeftResult = swipes.upOrLeftResult val downOrRightResult = swipes.downOrRightResult val isUpOrLeft = Loading Loading @@ -266,7 +263,7 @@ private class DragControllerImpl( layoutState.startTransitionImmediately( animationScope = draggableHandler.layoutImpl.animationScope, newTransition.contentTransition, true true, ) } Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt +11 −21 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ internal class ElementNode( @ExperimentalComposeUiApi override fun MeasureScope.measure( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { check(isLookingAhead) Loading Loading @@ -344,7 +344,7 @@ internal class ElementNode( private fun ApproachMeasureScope.doNotPlace( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { recursivelyClearPlacementValues() stateInContent.lastSize = Element.SizeUnspecified Loading @@ -355,7 +355,7 @@ internal class ElementNode( private fun ApproachMeasureScope.placeNormally( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { val placeable = measurable.measure(constraints) stateInContent.lastSize = placeable.size() Loading Loading @@ -670,10 +670,7 @@ private fun prepareInterruption( * Reconcile the state of [element] in the formContent and toContent of [transition] so that the * values before interruption have their expected values, taking shared transitions into account. */ private fun reconcileStates( element: Element, transition: TransitionState.Transition, ) { private fun reconcileStates(element: Element, transition: TransitionState.Transition) { val fromContentState = element.stateByContent[transition.fromContent] ?: return val toContentState = element.stateByContent[transition.toContent] ?: return if (!isSharedElementEnabled(element.key, transition)) { Loading Loading @@ -1139,7 +1136,7 @@ private fun ContentDrawScope.getDrawScale( Offset.Unspecified } else { a.pivot.specifiedOrCenter() - b.pivot.specifiedOrCenter() } }, ) }, add = { a, b, bProgress -> Loading @@ -1151,9 +1148,9 @@ private fun ContentDrawScope.getDrawScale( Offset.Unspecified } else { a.pivot.specifiedOrCenter() + b.pivot.specifiedOrCenter() * bProgress } }, ) } }, ) stateInContent.lastScale = interruptedScale Loading Loading @@ -1371,7 +1368,7 @@ private inline fun <T> computeValue( lerp( lerp(previewTargetValue, targetValueOrNull ?: idleValue, previewRangeProgress), idleValue, transformation?.range?.progress(transition.progress) ?: transition.progress transformation?.range?.progress(transition.progress) ?: transition.progress, ) } else { if (targetValueOrNull == null) { Loading @@ -1384,7 +1381,7 @@ private inline fun <T> computeValue( lerp( lerp(idleValue, previewTargetValue, previewRangeProgress), targetValueOrNull, transformation.range?.progress(transition.progress) ?: transition.progress transformation.range?.progress(transition.progress) ?: transition.progress, ) } } Loading @@ -1399,14 +1396,7 @@ private inline fun <T> computeValue( val idleValue = contentValue(contentState) val targetValue = transformation.transform( layoutImpl, content, element, contentState, transition, idleValue, ) transformation.transform(layoutImpl, content, element, contentState, transition, idleValue) // Make sure we don't read progress if values are the same and we don't need to interpolate, so // we don't invalidate the phase where this is read. Loading @@ -1433,7 +1423,7 @@ private inline fun <T> interpolateSharedElement( fromState: Element.State, toState: Element.State, isSpecified: (T) -> Boolean, lerp: (T, T, Float) -> T lerp: (T, T, Float) -> T, ): T { val start = contentValue(fromState) val end = contentValue(toState) Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt +1 −4 Original line number Diff line number Diff line Loading @@ -79,9 +79,6 @@ object DefaultInterruptionHandler : InterruptionHandler { interrupted: TransitionState.Transition.ChangeScene, newTargetScene: SceneKey, ): InterruptionResult { return InterruptionResult( animateFrom = interrupted.currentScene, chain = true, ) return InterruptionResult(animateFrom = interrupted.currentScene, chain = true) } } packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt +2 −8 Original line number Diff line number Diff line Loading @@ -49,10 +49,7 @@ sealed class ContentKey(debugName: String, identity: Any) : Key(debugName, ident } /** Key for a scene. */ class SceneKey( debugName: String, identity: Any = Object(), ) : ContentKey(debugName, identity) { class SceneKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) { override val testTag: String = "scene:$debugName" /** The unique [ElementKey] identifying this scene's root element. */ Loading @@ -64,10 +61,7 @@ class SceneKey( } /** Key for an overlay. */ class OverlayKey( debugName: String, identity: Any = Object(), ) : ContentKey(debugName, identity) { class OverlayKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) { override val testTag: String = "overlay:$debugName" override fun toString(): String { Loading Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt +9 −25 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ fun ContentScope.animateContentFloatAsState( @Deprecated( "Use animateContentFloatAsState() instead", replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)") replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)"), ) @Composable fun ContentScope.animateSceneFloatAsState( Loading Loading @@ -172,14 +172,11 @@ fun ContentScope.animateContentDpAsState( @Deprecated( "Use animateContentDpAsState() instead", replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)") replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)"), ) @Composable fun ContentScope.animateSceneDpAsState( value: Dp, key: ValueKey, canOverflow: Boolean = true, ) = animateContentDpAsState(value, key, canOverflow) fun ContentScope.animateSceneDpAsState(value: Dp, key: ValueKey, canOverflow: Boolean = true) = animateContentDpAsState(value, key, canOverflow) /** * Animate a shared element Dp value. Loading Loading @@ -214,10 +211,7 @@ private object SharedDpType : SharedValueType<Dp, Dp> { * @see ContentScope.animateContentValueAsState */ @Composable fun ContentScope.animateContentColorAsState( value: Color, key: ValueKey, ): AnimatedState<Color> { fun ContentScope.animateContentColorAsState(value: Color, key: ValueKey): AnimatedState<Color> { return animateContentValueAsState(value, key, SharedColorType, canOverflow = false) } Loading @@ -227,10 +221,7 @@ fun ContentScope.animateContentColorAsState( * @see ElementScope.animateElementValueAsState */ @Composable fun ElementScope<*>.animateElementColorAsState( value: Color, key: ValueKey, ): AnimatedState<Color> { fun ElementScope<*>.animateElementColorAsState(value: Color, key: ValueKey): AnimatedState<Color> { return animateElementValueAsState(value, key, SharedColorType, canOverflow = false) } Loading Loading @@ -274,12 +265,7 @@ private object SharedColorType : SharedValueType<Color, ColorDelta> { * Note: This class is necessary because Color() checks the bounds of its values and UncheckedColor * is internal. */ private class ColorDelta( val red: Float, val green: Float, val blue: Float, val alpha: Float, ) private class ColorDelta(val red: Float, val green: Float, val blue: Float, val alpha: Float) @Composable internal fun <T> animateSharedValueAsState( Loading Loading @@ -331,7 +317,7 @@ internal fun <T> animateSharedValueAsState( private fun <T, Delta> sharedValue( layoutImpl: SceneTransitionLayoutImpl, key: ValueKey, element: ElementKey? element: ElementKey?, ): SharedValue<T, Delta> { return layoutImpl.sharedValues[key]?.get(element)?.let { it as SharedValue<T, Delta> } ?: error(valueReadTooEarlyMessage(key)) Loading @@ -342,9 +328,7 @@ private fun valueReadTooEarlyMessage(key: ValueKey) = "means that you are reading it during composition, which you should not do. See the " + "documentation of AnimatedState for more information." internal class SharedValue<T, Delta>( val type: SharedValueType<T, Delta>, ) { internal class SharedValue<T, Delta>(val type: SharedValueType<T, Delta>) { /** The target value of this shared value for each content. */ val targetValues = SnapshotStateMap<ContentKey, T>() Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +5 −8 Original line number Diff line number Diff line Loading @@ -109,12 +109,12 @@ internal class DraggableHandlerImpl( return (upOrLeft != null && contentTransition.isTransitioningBetween( fromContent.key, upOrLeft.toContent(currentScene) upOrLeft.toContent(currentScene), )) || (downOrRight != null && contentTransition.isTransitioningBetween( fromContent.key, downOrRight.toContent(currentScene) downOrRight.toContent(currentScene), )) } Loading Loading @@ -163,7 +163,7 @@ internal class DraggableHandlerImpl( private fun updateDragController( swipes: Swipes, swipeAnimation: SwipeAnimation<*> swipeAnimation: SwipeAnimation<*>, ): DragControllerImpl { val newDragController = DragControllerImpl(this, swipes, swipeAnimation) newDragController.updateTransition(swipeAnimation, force = true) Loading @@ -171,10 +171,7 @@ internal class DraggableHandlerImpl( return newDragController } internal fun createSwipeAnimation( swipes: Swipes, result: UserActionResult, ): SwipeAnimation<*> { internal fun createSwipeAnimation(swipes: Swipes, result: UserActionResult): SwipeAnimation<*> { val upOrLeftResult = swipes.upOrLeftResult val downOrRightResult = swipes.downOrRightResult val isUpOrLeft = Loading Loading @@ -266,7 +263,7 @@ private class DragControllerImpl( layoutState.startTransitionImmediately( animationScope = draggableHandler.layoutImpl.animationScope, newTransition.contentTransition, true true, ) } Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt +11 −21 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ internal class ElementNode( @ExperimentalComposeUiApi override fun MeasureScope.measure( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { check(isLookingAhead) Loading Loading @@ -344,7 +344,7 @@ internal class ElementNode( private fun ApproachMeasureScope.doNotPlace( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { recursivelyClearPlacementValues() stateInContent.lastSize = Element.SizeUnspecified Loading @@ -355,7 +355,7 @@ internal class ElementNode( private fun ApproachMeasureScope.placeNormally( measurable: Measurable, constraints: Constraints constraints: Constraints, ): MeasureResult { val placeable = measurable.measure(constraints) stateInContent.lastSize = placeable.size() Loading Loading @@ -670,10 +670,7 @@ private fun prepareInterruption( * Reconcile the state of [element] in the formContent and toContent of [transition] so that the * values before interruption have their expected values, taking shared transitions into account. */ private fun reconcileStates( element: Element, transition: TransitionState.Transition, ) { private fun reconcileStates(element: Element, transition: TransitionState.Transition) { val fromContentState = element.stateByContent[transition.fromContent] ?: return val toContentState = element.stateByContent[transition.toContent] ?: return if (!isSharedElementEnabled(element.key, transition)) { Loading Loading @@ -1139,7 +1136,7 @@ private fun ContentDrawScope.getDrawScale( Offset.Unspecified } else { a.pivot.specifiedOrCenter() - b.pivot.specifiedOrCenter() } }, ) }, add = { a, b, bProgress -> Loading @@ -1151,9 +1148,9 @@ private fun ContentDrawScope.getDrawScale( Offset.Unspecified } else { a.pivot.specifiedOrCenter() + b.pivot.specifiedOrCenter() * bProgress } }, ) } }, ) stateInContent.lastScale = interruptedScale Loading Loading @@ -1371,7 +1368,7 @@ private inline fun <T> computeValue( lerp( lerp(previewTargetValue, targetValueOrNull ?: idleValue, previewRangeProgress), idleValue, transformation?.range?.progress(transition.progress) ?: transition.progress transformation?.range?.progress(transition.progress) ?: transition.progress, ) } else { if (targetValueOrNull == null) { Loading @@ -1384,7 +1381,7 @@ private inline fun <T> computeValue( lerp( lerp(idleValue, previewTargetValue, previewRangeProgress), targetValueOrNull, transformation.range?.progress(transition.progress) ?: transition.progress transformation.range?.progress(transition.progress) ?: transition.progress, ) } } Loading @@ -1399,14 +1396,7 @@ private inline fun <T> computeValue( val idleValue = contentValue(contentState) val targetValue = transformation.transform( layoutImpl, content, element, contentState, transition, idleValue, ) transformation.transform(layoutImpl, content, element, contentState, transition, idleValue) // Make sure we don't read progress if values are the same and we don't need to interpolate, so // we don't invalidate the phase where this is read. Loading @@ -1433,7 +1423,7 @@ private inline fun <T> interpolateSharedElement( fromState: Element.State, toState: Element.State, isSpecified: (T) -> Boolean, lerp: (T, T, Float) -> T lerp: (T, T, Float) -> T, ): T { val start = contentValue(fromState) val end = contentValue(toState) Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt +1 −4 Original line number Diff line number Diff line Loading @@ -79,9 +79,6 @@ object DefaultInterruptionHandler : InterruptionHandler { interrupted: TransitionState.Transition.ChangeScene, newTargetScene: SceneKey, ): InterruptionResult { return InterruptionResult( animateFrom = interrupted.currentScene, chain = true, ) return InterruptionResult(animateFrom = interrupted.currentScene, chain = true) } }
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt +2 −8 Original line number Diff line number Diff line Loading @@ -49,10 +49,7 @@ sealed class ContentKey(debugName: String, identity: Any) : Key(debugName, ident } /** Key for a scene. */ class SceneKey( debugName: String, identity: Any = Object(), ) : ContentKey(debugName, identity) { class SceneKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) { override val testTag: String = "scene:$debugName" /** The unique [ElementKey] identifying this scene's root element. */ Loading @@ -64,10 +61,7 @@ class SceneKey( } /** Key for an overlay. */ class OverlayKey( debugName: String, identity: Any = Object(), ) : ContentKey(debugName, identity) { class OverlayKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) { override val testTag: String = "overlay:$debugName" override fun toString(): String { Loading