Loading packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/ActionList.kt +70 −16 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ import android.view.Surface.ROTATION_270 import android.view.Surface.ROTATION_90 import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.Spring import androidx.compose.animation.core.animate import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.keyframes import androidx.compose.animation.core.snap import androidx.compose.animation.core.spring import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.scaleIn Loading Loading @@ -55,6 +59,7 @@ import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue Loading Loading @@ -101,13 +106,15 @@ fun ActionList( val maxOverscrollDelta = 0.dp val columnSpacing = 8.dp val minGradientHeight = 70.dp val scrimVerticalPadding = 32.dp val scrimHorizontalPadding = 42.dp val edgeAligned = horizontalAlignment == Alignment.Start || horizontalAlignment == Alignment.End val smartScrimAlpha by animateFloatAsState( if (expanded) { 0.25f 0.5f } else if (visible && !edgeAligned) { 0.1f 0.3f } else { 0f } Loading @@ -118,9 +125,17 @@ fun ActionList( val translateStiffnessMultiplier = 50 val overscrollStiffness = 2063f var containerHeightPx by remember { mutableIntStateOf(0) } var radius by remember { mutableFloatStateOf(0f) } var wasEverExpanded by remember { mutableStateOf(false) } val leftGradientColor = MaterialTheme.colorScheme.tertiary val rightGradientColor = MaterialTheme.colorScheme.primaryFixedDim LaunchedEffect(expanded) { if (expanded) { wasEverExpanded = true } } val leftGradientColor = MaterialTheme.colorScheme.tertiaryContainer val rightGradientColor = MaterialTheme.colorScheme.primary // User should be able to drag down vertically to dismiss the action list. // The list will shrink as the user drags. Loading @@ -131,6 +146,7 @@ fun ActionList( val maxOverscrollDeltaPx = with(density) { maxOverscrollDelta.toPx() } val columnSpacingPx = with(density) { columnSpacing.toPx() } val minGradientHeightPx = with(density) { minGradientHeight.toPx() } val scrimVerticalPaddingPx = with(density) { scrimVerticalPadding.toPx() } val scope = rememberCoroutineScope() val overscrollEffect = remember { Loading Loading @@ -167,6 +183,45 @@ fun ActionList( ), ) var smartScrimAlphaBoost by remember { mutableFloatStateOf(0f) } LaunchedEffect(visible) { if (visible) { animate( initialValue = 0f, targetValue = 0f, animationSpec = keyframes { durationMillis = 2000 0f at 0 0.2f at 500 0.2f at 1500 0f at 2000 }, ) { value, _ -> smartScrimAlphaBoost = value } } else { smartScrimAlphaBoost = 0f } } val scrimOffsetY by animateFloatAsState( targetValue = if (!expanded) containerHeightPx - scrimVerticalPaddingPx else containerHeightPx - radius, animationSpec = if (expanded || wasEverExpanded) { // Enable animation only when user expands/collapses the action list. tween(250, delayMillis = 200) } else { // Disable animation during Compose initialization. snap() }, label = "scrimOffsetY", ) LaunchedEffect(visible, expanded) { anchoredDraggableState.animateTo(if (visible && expanded) End else Start) } Loading Loading @@ -246,9 +301,7 @@ fun ActionList( ) } .drawBehind { val sidePaddingPx = with(density) { padding.calculateLeftPadding(layoutDirection).toPx() } val radius = size.width - sidePaddingPx * 2f val sidePaddingPx = with(density) { scrimHorizontalPadding.toPx() } if (!(radius > 0)) return@drawBehind val minScaleY = minGradientHeightPx / (radius * 2f) Loading @@ -256,32 +309,32 @@ fun ActionList( scale(scaleX = 1f, scaleY = scaleY, pivot = Offset(0f, size.height)) { val leftGradientCenter = Offset(size.width / 2 + sidePaddingPx, size.height - radius) Offset(size.width / 2 - sidePaddingPx, scrimOffsetY) val rightGradientCenter = Offset(size.width / 2 - sidePaddingPx, size.height - radius) Offset(size.width / 2 + sidePaddingPx, scrimOffsetY) val leftBrush = Brush.radialGradient( colors = listOf(leftGradientColor, leftGradientColor.copy(alpha = 0f)), center = rightGradientCenter, center = leftGradientCenter, radius = radius, ) val rightBrush = Brush.radialGradient( colors = listOf(rightGradientColor, rightGradientColor.copy(alpha = 0f)), center = leftGradientCenter, radius = radius, center = rightGradientCenter, radius = radius * 0.85f, ) drawCircle( brush = rightBrush, alpha = smartScrimAlpha, brush = leftBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, center = leftGradientCenter, ) drawCircle( brush = leftBrush, alpha = smartScrimAlpha, brush = rightBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, center = rightGradientCenter, ) Loading Loading @@ -342,6 +395,7 @@ fun ActionList( } chipWidthPx = it.width } .onGloballyPositioned { radius = max(radius, it.size.width / 2f) } .graphicsLayer { val chipsTotalHeightPx = childHeights.sum().toFloat() + Loading packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/NavBarPill.kt +23 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,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.animateIntAsState import androidx.compose.animation.core.keyframes import androidx.compose.animation.core.rememberTransition import androidx.compose.animation.core.tween Loading Loading @@ -97,7 +98,7 @@ fun NavBarPill( ) { val maxPillWidth = 248.dp val backgroundColor = if (isSystemInDarkTheme()) Color.Black else Color.White val scrimColor = MaterialTheme.colorScheme.primary val smartScrimColor = MaterialTheme.colorScheme.primaryFixedDim val density = LocalDensity.current val collapsedWidthPx = with(density) { navBarWidth.toPx() } Loading Loading @@ -133,7 +134,7 @@ fun NavBarPill( 0f at 0 0.2f at 500 0.2f at 1500 0f at 2000 0.4f at 2000 } } else { tween(500) Loading @@ -141,7 +142,7 @@ fun NavBarPill( }, label = "smartScrimAlphaBoost", ) { if (it) 0f else 0f if (it) 0.4f else 0f } val expansionAlpha by animateFloatAsState( Loading @@ -149,6 +150,13 @@ fun NavBarPill( animationSpec = tween(250, delayMillis = 200), label = "expansion", ) val smartScrimOffset by animateIntAsState( if (expanded) -18 else 10, animationSpec = tween(250, delayMillis = 200), label = "smartScrimOffset", ) val config = LocalConfiguration.current val isBoldTextEnabled = config.fontWeightAdjustment > 0 val fontScale = config.fontScale Loading @@ -167,20 +175,23 @@ fun NavBarPill( modifier = modifier.defaultMinSize(minWidth = 412.dp, minHeight = 50.dp).drawBehind { // SmartScrim val radius = size.width / 2f if (!(radius > 0)) return@drawBehind val scrimBrush = val smartScrimRadius = 50.dp.toPx() val smartScrimBrush = Brush.radialGradient( colors = listOf(scrimColor, scrimColor.copy(alpha = 0f)), colors = listOf(smartScrimColor, smartScrimColor.copy(alpha = 0f)), center = Offset.Zero, radius = radius, radius = smartScrimRadius * 0.9f, ) translate(radius, size.height) { scale(scaleX = 1f, scaleY = size.height / size.width * 2, pivot = Offset.Zero) { translate(size.width / 2f, size.height + smartScrimOffset.dp.toPx()) { scale( scaleX = size.width / (smartScrimRadius * 2), scaleY = 1f, pivot = Offset.Zero, ) { drawCircle( brush = scrimBrush, brush = smartScrimBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, radius = smartScrimRadius, center = Offset.Zero, ) } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/ActionList.kt +70 −16 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ import android.view.Surface.ROTATION_270 import android.view.Surface.ROTATION_90 import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.Spring import androidx.compose.animation.core.animate import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.keyframes import androidx.compose.animation.core.snap import androidx.compose.animation.core.spring import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.scaleIn Loading Loading @@ -55,6 +59,7 @@ import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue Loading Loading @@ -101,13 +106,15 @@ fun ActionList( val maxOverscrollDelta = 0.dp val columnSpacing = 8.dp val minGradientHeight = 70.dp val scrimVerticalPadding = 32.dp val scrimHorizontalPadding = 42.dp val edgeAligned = horizontalAlignment == Alignment.Start || horizontalAlignment == Alignment.End val smartScrimAlpha by animateFloatAsState( if (expanded) { 0.25f 0.5f } else if (visible && !edgeAligned) { 0.1f 0.3f } else { 0f } Loading @@ -118,9 +125,17 @@ fun ActionList( val translateStiffnessMultiplier = 50 val overscrollStiffness = 2063f var containerHeightPx by remember { mutableIntStateOf(0) } var radius by remember { mutableFloatStateOf(0f) } var wasEverExpanded by remember { mutableStateOf(false) } val leftGradientColor = MaterialTheme.colorScheme.tertiary val rightGradientColor = MaterialTheme.colorScheme.primaryFixedDim LaunchedEffect(expanded) { if (expanded) { wasEverExpanded = true } } val leftGradientColor = MaterialTheme.colorScheme.tertiaryContainer val rightGradientColor = MaterialTheme.colorScheme.primary // User should be able to drag down vertically to dismiss the action list. // The list will shrink as the user drags. Loading @@ -131,6 +146,7 @@ fun ActionList( val maxOverscrollDeltaPx = with(density) { maxOverscrollDelta.toPx() } val columnSpacingPx = with(density) { columnSpacing.toPx() } val minGradientHeightPx = with(density) { minGradientHeight.toPx() } val scrimVerticalPaddingPx = with(density) { scrimVerticalPadding.toPx() } val scope = rememberCoroutineScope() val overscrollEffect = remember { Loading Loading @@ -167,6 +183,45 @@ fun ActionList( ), ) var smartScrimAlphaBoost by remember { mutableFloatStateOf(0f) } LaunchedEffect(visible) { if (visible) { animate( initialValue = 0f, targetValue = 0f, animationSpec = keyframes { durationMillis = 2000 0f at 0 0.2f at 500 0.2f at 1500 0f at 2000 }, ) { value, _ -> smartScrimAlphaBoost = value } } else { smartScrimAlphaBoost = 0f } } val scrimOffsetY by animateFloatAsState( targetValue = if (!expanded) containerHeightPx - scrimVerticalPaddingPx else containerHeightPx - radius, animationSpec = if (expanded || wasEverExpanded) { // Enable animation only when user expands/collapses the action list. tween(250, delayMillis = 200) } else { // Disable animation during Compose initialization. snap() }, label = "scrimOffsetY", ) LaunchedEffect(visible, expanded) { anchoredDraggableState.animateTo(if (visible && expanded) End else Start) } Loading Loading @@ -246,9 +301,7 @@ fun ActionList( ) } .drawBehind { val sidePaddingPx = with(density) { padding.calculateLeftPadding(layoutDirection).toPx() } val radius = size.width - sidePaddingPx * 2f val sidePaddingPx = with(density) { scrimHorizontalPadding.toPx() } if (!(radius > 0)) return@drawBehind val minScaleY = minGradientHeightPx / (radius * 2f) Loading @@ -256,32 +309,32 @@ fun ActionList( scale(scaleX = 1f, scaleY = scaleY, pivot = Offset(0f, size.height)) { val leftGradientCenter = Offset(size.width / 2 + sidePaddingPx, size.height - radius) Offset(size.width / 2 - sidePaddingPx, scrimOffsetY) val rightGradientCenter = Offset(size.width / 2 - sidePaddingPx, size.height - radius) Offset(size.width / 2 + sidePaddingPx, scrimOffsetY) val leftBrush = Brush.radialGradient( colors = listOf(leftGradientColor, leftGradientColor.copy(alpha = 0f)), center = rightGradientCenter, center = leftGradientCenter, radius = radius, ) val rightBrush = Brush.radialGradient( colors = listOf(rightGradientColor, rightGradientColor.copy(alpha = 0f)), center = leftGradientCenter, radius = radius, center = rightGradientCenter, radius = radius * 0.85f, ) drawCircle( brush = rightBrush, alpha = smartScrimAlpha, brush = leftBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, center = leftGradientCenter, ) drawCircle( brush = leftBrush, alpha = smartScrimAlpha, brush = rightBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, center = rightGradientCenter, ) Loading Loading @@ -342,6 +395,7 @@ fun ActionList( } chipWidthPx = it.width } .onGloballyPositioned { radius = max(radius, it.size.width / 2f) } .graphicsLayer { val chipsTotalHeightPx = childHeights.sum().toFloat() + Loading
packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/NavBarPill.kt +23 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,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.animateIntAsState import androidx.compose.animation.core.keyframes import androidx.compose.animation.core.rememberTransition import androidx.compose.animation.core.tween Loading Loading @@ -97,7 +98,7 @@ fun NavBarPill( ) { val maxPillWidth = 248.dp val backgroundColor = if (isSystemInDarkTheme()) Color.Black else Color.White val scrimColor = MaterialTheme.colorScheme.primary val smartScrimColor = MaterialTheme.colorScheme.primaryFixedDim val density = LocalDensity.current val collapsedWidthPx = with(density) { navBarWidth.toPx() } Loading Loading @@ -133,7 +134,7 @@ fun NavBarPill( 0f at 0 0.2f at 500 0.2f at 1500 0f at 2000 0.4f at 2000 } } else { tween(500) Loading @@ -141,7 +142,7 @@ fun NavBarPill( }, label = "smartScrimAlphaBoost", ) { if (it) 0f else 0f if (it) 0.4f else 0f } val expansionAlpha by animateFloatAsState( Loading @@ -149,6 +150,13 @@ fun NavBarPill( animationSpec = tween(250, delayMillis = 200), label = "expansion", ) val smartScrimOffset by animateIntAsState( if (expanded) -18 else 10, animationSpec = tween(250, delayMillis = 200), label = "smartScrimOffset", ) val config = LocalConfiguration.current val isBoldTextEnabled = config.fontWeightAdjustment > 0 val fontScale = config.fontScale Loading @@ -167,20 +175,23 @@ fun NavBarPill( modifier = modifier.defaultMinSize(minWidth = 412.dp, minHeight = 50.dp).drawBehind { // SmartScrim val radius = size.width / 2f if (!(radius > 0)) return@drawBehind val scrimBrush = val smartScrimRadius = 50.dp.toPx() val smartScrimBrush = Brush.radialGradient( colors = listOf(scrimColor, scrimColor.copy(alpha = 0f)), colors = listOf(smartScrimColor, smartScrimColor.copy(alpha = 0f)), center = Offset.Zero, radius = radius, radius = smartScrimRadius * 0.9f, ) translate(radius, size.height) { scale(scaleX = 1f, scaleY = size.height / size.width * 2, pivot = Offset.Zero) { translate(size.width / 2f, size.height + smartScrimOffset.dp.toPx()) { scale( scaleX = size.width / (smartScrimRadius * 2), scaleY = 1f, pivot = Offset.Zero, ) { drawCircle( brush = scrimBrush, brush = smartScrimBrush, alpha = smartScrimAlpha + smartScrimAlphaBoost, radius = radius, radius = smartScrimRadius, center = Offset.Zero, ) } Loading