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

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

Merge "Run ktfmt 0.52 on SceneTransitionLayout sources" into main

parents 4e8dfd78 916f65fa
Loading
Loading
Loading
Loading
+9 −25
Original line number Diff line number Diff line
@@ -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(
@@ -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.
@@ -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)
}

@@ -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)
}

@@ -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(
@@ -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))
@@ -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>()

+5 −8
Original line number Diff line number Diff line
@@ -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),
                ))
    }

@@ -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)
@@ -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 =
@@ -266,7 +263,7 @@ private class DragControllerImpl(
            layoutState.startTransitionImmediately(
                animationScope = draggableHandler.layoutImpl.animationScope,
                newTransition.contentTransition,
                true
                true,
            )
        }

+11 −21
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ internal class ElementNode(
    @ExperimentalComposeUiApi
    override fun MeasureScope.measure(
        measurable: Measurable,
        constraints: Constraints
        constraints: Constraints,
    ): MeasureResult {
        check(isLookingAhead)

@@ -344,7 +344,7 @@ internal class ElementNode(

    private fun ApproachMeasureScope.doNotPlace(
        measurable: Measurable,
        constraints: Constraints
        constraints: Constraints,
    ): MeasureResult {
        recursivelyClearPlacementValues()
        stateInContent.lastSize = Element.SizeUnspecified
@@ -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()
@@ -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)) {
@@ -1139,7 +1136,7 @@ private fun ContentDrawScope.getDrawScale(
                            Offset.Unspecified
                        } else {
                            a.pivot.specifiedOrCenter() - b.pivot.specifiedOrCenter()
                        }
                        },
                )
            },
            add = { a, b, bProgress ->
@@ -1151,9 +1148,9 @@ private fun ContentDrawScope.getDrawScale(
                            Offset.Unspecified
                        } else {
                            a.pivot.specifiedOrCenter() + b.pivot.specifiedOrCenter() * bProgress
                        }
                        },
                )
            }
            },
        )

    stateInContent.lastScale = interruptedScale
@@ -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) {
@@ -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,
                )
            }
        }
@@ -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.
@@ -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)
+1 −4
Original line number Diff line number Diff line
@@ -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)
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -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. */
@@ -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