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

Commit b6d8f7d9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "TileGrid now includes an optional revealEffectContainer parameter (v2)" into main

parents 054b8378 81ceb451
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.qs.panels.ui.compose
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel
import com.android.systemui.qs.panels.ui.viewmodel.PaginatableViewModel
import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel
@@ -28,14 +29,20 @@ import com.android.systemui.qs.pipeline.shared.TileSpec
interface GridLayout {

    /**
     * [listening] can be used to compose the grid but limit when tiles should be listening. It
     * Displays a grid of tiles with an optional reveal animation.
     *
     * @param listening can be used to compose the grid but limit when tiles should be listening. It
     *   should be a function tracking a snapshot state.
     * @param revealEffectContainer The [ElementKey] of the container driving the reveal animation.
     *   During expansion, tiles use this container's height to compute their own, creating a
     *   synchronized reveal effect. When `null`, the effect is disabled.
     */
    @Composable
    fun ContentScope.TileGrid(
        tiles: List<TileViewModel>,
        modifier: Modifier,
        listening: () -> Boolean,
        revealEffectContainer: ElementKey? = null,
    )

    @Composable
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import androidx.compose.ui.res.integerResource
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.modifiers.padding
import com.android.systemui.common.ui.compose.PagerDots
@@ -70,6 +71,7 @@ constructor(
        tiles: List<TileViewModel>,
        modifier: Modifier,
        listening: () -> Boolean,
        revealEffectContainer: ElementKey?,
    ) {
        val viewModel =
            rememberViewModel(traceName = "PaginatedGridLayout-TileGrid") {
+17 −2
Original line number Diff line number Diff line
@@ -19,16 +19,31 @@ package com.android.systemui.qs.panels.ui.compose
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.systemui.qs.panels.ui.viewmodel.TileGridViewModel

/**
 * Displays a grid of tiles with an optional reveal animation.
 *
 * @param revealEffectContainer The [ElementKey] of the container driving the reveal animation.
 *   During expansion, tiles use this container's height to compute their own, creating a
 *   synchronized reveal effect. When `null`, the effect is disabled.
 */
@Composable
fun ContentScope.TileGrid(
    viewModel: TileGridViewModel,
    modifier: Modifier = Modifier,
    listening: () -> Boolean = { true },
    revealEffectContainer: ElementKey? = null,
) {
    val gridLayout = viewModel.gridLayout
    val tiles = viewModel.tileViewModels

    with(gridLayout) { TileGrid(tiles, modifier, listening) }
    with(gridLayout) {
        TileGrid(
            tiles = tiles,
            modifier = modifier,
            listening = listening,
            revealEffectContainer = revealEffectContainer,
        )
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.util.fastMap
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.mechanics.compose.modifier.verticalTactileSurfaceReveal
import com.android.mechanics.spec.builder.rememberMotionBuilderContext
import com.android.systemui.dagger.SysUISingleton
@@ -72,6 +73,7 @@ constructor(
        tiles: List<TileViewModel>,
        modifier: Modifier,
        listening: () -> Boolean,
        revealEffectContainer: ElementKey?,
    ) {
        val viewModel =
            rememberViewModel(traceName = "InfiniteGridLayout.TileGrid") {
@@ -100,7 +102,6 @@ constructor(
        val scope = rememberCoroutineScope()
        val spans by remember(sizedTiles) { derivedStateOf { sizedTiles.fastMap { it.width } } }

        val isDualShade = viewModel.isDualShade
        val motionBuilderContext = rememberMotionBuilderContext()
        val marginBottom =
            with(LocalDensity.current) { QuickSettingsShade.Dimensions.Padding.toPx() }
@@ -135,17 +136,17 @@ constructor(
                    isVisible = listening,
                    requestToggleTextFeedback = textFeedbackViewModel::requestShowFeedback,
                    modifier =
                        if (isDualShade) {
                        if (revealEffectContainer != null) {
                            Modifier.verticalTactileSurfaceReveal(
                                contentScope = this@TileGrid,
                                motionBuilderContext = motionBuilderContext,
                                container = QuickSettingsShade.Elements.Panel,
                                container = revealEffectContainer,
                                deltaY = -marginBottom,
                            )
                        } else {
                            Modifier
                        },
                    verticalFadeContentReveal = isDualShade,
                    revealEffectContainer = revealEffectContainer,
                )
            }
        }
+4 −4
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import com.android.compose.animation.Expandable
import com.android.compose.animation.bounceable
import com.android.compose.animation.rememberExpandableController
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.compose.modifiers.thenIf
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.mechanics.compose.modifier.verticalFadeContentReveal
@@ -102,7 +103,6 @@ import com.android.systemui.qs.panels.ui.viewmodel.toIconProvider
import com.android.systemui.qs.panels.ui.viewmodel.toUiState
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.ui.composable.QuickSettingsShade
import com.android.systemui.qs.ui.compose.borderOnFocus
import com.android.systemui.res.R
import kotlinx.coroutines.CoroutineScope
@@ -144,7 +144,7 @@ fun ContentScope.Tile(
    isVisible: () -> Boolean = { true },
    requestToggleTextFeedback: (TileSpec) -> Unit = {},
    detailsViewModel: DetailsViewModel?,
    verticalFadeContentReveal: Boolean = false,
    revealEffectContainer: ElementKey? = null,
) {
    trace(tile.traceName) {
        val currentBounceableInfo by rememberUpdatedState(bounceableInfo)
@@ -253,11 +253,11 @@ fun ContentScope.Tile(
                iconOnly = iconOnly,
                isDualTarget = isDualTarget,
                modifier =
                    if (verticalFadeContentReveal) {
                    if (revealEffectContainer != null) {
                        Modifier.verticalFadeContentReveal(
                            contentScope = this,
                            motionBuilderContext = rememberMotionBuilderContext(),
                            container = QuickSettingsShade.Elements.Panel,
                            container = revealEffectContainer,
                        )
                    } else {
                        Modifier
Loading