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

Commit fbb2e5b6 authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Autoscroll to the top of the edit page when resetting tiles

Test: manually
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 408172392
Change-Id: I11f12cc73a704350f8a8aecc6d33642faed25c50
parent 96c75f81
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -243,10 +243,11 @@ sealed interface EditAction {
fun DefaultEditTileGrid(
    listState: EditTileListState,
    allTiles: List<EditTileViewModel>,
    modifier: Modifier,
    snapshotViewModel: InfiniteGridSnapshotViewModel,
    onStopEditing: () -> Unit,
    onEditAction: (EditAction) -> Unit,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    onStopEditing: () -> Unit = {},
    onEditAction: (EditAction) -> Unit = {},
) {
    val selectionState = rememberSelectionState()

@@ -293,8 +294,6 @@ fun DefaultEditTileGrid(
        CompositionLocalProvider(
            LocalOverscrollFactory provides rememberOffsetOverscrollEffectFactory()
        ) {
            val scrollState = rememberScrollState()

            AutoScrollGrid(listState, scrollState, innerPadding)

            LaunchedEffect(listState.dragType) {
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.qs.panels.ui.compose.infinitegrid

import androidx.compose.foundation.rememberScrollState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
@@ -49,6 +50,7 @@ import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.shared.ui.ElementKeys.toElementKey
import com.android.systemui.res.R
import javax.inject.Inject
import kotlinx.coroutines.launch

@SysUISingleton
class InfiniteGridLayout
@@ -162,11 +164,16 @@ constructor(
            rememberViewModel("InfiniteGridLayout.EditTileGrid") {
                viewModel.snapshotViewModelFactory.create()
            }
        val scrollState = rememberScrollState()
        val coroutineScope = rememberCoroutineScope()
        val dialogDelegate =
            rememberViewModel("InfiniteGridLayout.EditTileGrid") {
                viewModel.resetDialogDelegateFactory.create {
                    // Clear the stack of snapshots on reset
                    snapshotViewModel.clearStack()

                    // Automatically scroll to the top on reset
                    coroutineScope.launch { scrollState.animateScrollTo(0) }
                }
            }
        val columns = columnsViewModel.columns
@@ -189,6 +196,7 @@ constructor(
            listState = listState,
            allTiles = tiles,
            modifier = modifier,
            scrollState = scrollState,
            snapshotViewModel = snapshotViewModel,
            onStopEditing = onStopEditing,
        ) { action ->