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

Commit e5f0ed5f authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Fix the missing animation when cuebar appears." into main

parents ec39baec 0c7df748
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -18,18 +18,20 @@ package com.android.systemui.ambientcue.ui.compose

import android.graphics.RuntimeShader
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateIntOffsetAsState
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.rememberTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.drawWithCache
@@ -53,7 +55,11 @@ fun BackgroundGlow(
    val turbulenceDisplacementPx = with(density) { Defaults.TURBULENCE_DISPLACEMENT_DP.dp.toPx() }
    val gradientRadiusPx = with(density) { Defaults.GRADIENT_RADIUS.dp.toPx() }

    val alpha by animateFloatAsState(if (visible) 1f else 0f, animationSpec = tween(750))
    val visibleState = remember { MutableTransitionState(false) }
    visibleState.targetState = visible

    val transition = rememberTransition(visibleState)
    val alpha by transition.animateFloat(transitionSpec = { tween(750) }) { if (it) 1f else 0f }
    val verticalOffset by
        animateIntOffsetAsState(if (expanded) IntOffset.Zero else collapsedOffset, tween(350))

+12 −5
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.systemui.ambientcue.ui.compose

import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.rememberTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -43,7 +46,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
@@ -81,12 +83,17 @@ fun NavBarPill(
    val density = LocalDensity.current
    val collapsedWidthPx = with(density) { navBarWidth.toPx() }
    var expandedSize by remember { mutableStateOf(IntSize.Zero) }
    val visibleState = remember { MutableTransitionState(false) }
    visibleState.targetState = visible

    val transition = rememberTransition(visibleState)
    val enterProgress by
        animateFloatAsState(
            if (visible) 1f else 0f,
            animationSpec = tween(250, delayMillis = 200),
        transition.animateFloat(
            transitionSpec = { tween(250, delayMillis = 200) },
            label = "enter",
        )
        ) {
            if (it) 1f else 0f
        }
    val expansionAlpha by
        animateFloatAsState(
            if (expanded) 0f else 1f,
+13 −7
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.systemui.ambientcue.ui.compose

import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.rememberTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -39,6 +42,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -68,14 +72,16 @@ fun ShortPill(
    val backgroundColor = MaterialTheme.colorScheme.background
    val minSize = 48.dp
    val closeButtonSize = 28.dp
    val transitionTween: AnimationSpec<Float> = tween(250, delayMillis = 200)
    val transitionTween: TweenSpec<Float> = tween(250, delayMillis = 200)

    val visibleState = remember { MutableTransitionState(false) }
    visibleState.targetState = visible

    val transition = rememberTransition(visibleState)
    val enterProgress by
        animateFloatAsState(
            if (visible) 1f else 0f,
            animationSpec = transitionTween,
            label = "enter",
        )
        transition.animateFloat(transitionSpec = { transitionTween }, label = "enter") {
            if (it) 1f else 0f
        }
    val expansionAlpha by
        animateFloatAsState(
            if (expanded) 0f else 1f,