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

Commit b847f1a0 authored by Tianfan Zhang's avatar Tianfan Zhang Committed by Android (Google) Code Review
Browse files

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

parents d6627bbd 18b3480b
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -18,20 +18,18 @@ 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
@@ -55,11 +53,7 @@ fun BackgroundGlow(
    val turbulenceDisplacementPx = with(density) { Defaults.TURBULENCE_DISPLACEMENT_DP.dp.toPx() }
    val gradientRadiusPx = with(density) { Defaults.GRADIENT_RADIUS.dp.toPx() }

    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 alpha by animateFloatAsState(if (visible) 1f else 0f, animationSpec = tween(750))
    val verticalOffset by
        animateIntOffsetAsState(if (expanded) IntOffset.Zero else collapsedOffset, tween(350))

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

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
@@ -46,6 +43,7 @@ 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
@@ -83,17 +81,12 @@ 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
        transition.animateFloat(
            transitionSpec = { tween(250, delayMillis = 200) },
        animateFloatAsState(
            if (visible) 1f else 0f,
            animationSpec = tween(250, delayMillis = 200),
            label = "enter",
        ) {
            if (it) 1f else 0f
        }
        )
    val expansionAlpha by
        animateFloatAsState(
            if (expanded) 0f else 1f,
+7 −13
Original line number Diff line number Diff line
@@ -16,11 +16,8 @@

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

import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.AnimationSpec
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
@@ -42,7 +39,6 @@ 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
@@ -72,16 +68,14 @@ fun ShortPill(
    val backgroundColor = MaterialTheme.colorScheme.background
    val minSize = 48.dp
    val closeButtonSize = 28.dp
    val transitionTween: TweenSpec<Float> = tween(250, delayMillis = 200)
    val transitionTween: AnimationSpec<Float> = tween(250, delayMillis = 200)

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

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