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

Commit 8fa5ce38 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge "Don't read AnimatedState.value during composition" into main

parents d068a51e b5f1daa4
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -91,12 +91,19 @@ fun SceneScope.CollapsedShadeHeader(
    statusBarIconController: StatusBarIconController,
    modifier: Modifier = Modifier,
) {
    val formatProgress = animateSceneFloatAsState(0.0f, ShadeHeader.Keys.transitionProgress)
    val formatProgress =
        animateSceneFloatAsState(0f, ShadeHeader.Keys.transitionProgress)
            .unsafeCompositionState(initialValue = 0f)

    val cutoutWidth = LocalDisplayCutout.current.width()
    val cutoutLocation = LocalDisplayCutout.current.location

    val useExpandedFormat = formatProgress.value > 0.5f || cutoutLocation != CutoutLocation.CENTER
    val useExpandedFormat by
        remember(formatProgress) {
            derivedStateOf {
                cutoutLocation != CutoutLocation.CENTER || formatProgress.value > 0.5f
            }
        }

    // This layout assumes it is globally positioned at (0, 0) and is the
    // same size as the screen.
@@ -209,7 +216,9 @@ fun SceneScope.ExpandedShadeHeader(
    statusBarIconController: StatusBarIconController,
    modifier: Modifier = Modifier,
) {
    val formatProgress = animateSceneFloatAsState(1.0f, ShadeHeader.Keys.transitionProgress)
    val formatProgress =
        animateSceneFloatAsState(1f, ShadeHeader.Keys.transitionProgress)
            .unsafeCompositionState(initialValue = 1f)
    val useExpandedFormat by
        remember(formatProgress) { derivedStateOf { formatProgress.value > 0.5f } }