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

Commit 6daf155d authored by omarmt's avatar omarmt
Browse files

Add OverscrollEffect to OverlayShade when idle

Test: Manually tested by opening and closing the notifications shade
Bug: 384653288
Flag: com.android.systemui.dual_shade
Change-Id: I7e332d18a0e9a7a536a09b67ef350b40cf1fd8cb
parent b353840b
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ package com.android.systemui.shade.ui.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.rememberScrollableState
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.PaddingValues
@@ -41,16 +44,21 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.LowestZIndexContentPicker
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.effect.rememberOffsetOverscrollEffect
import com.android.compose.windowsizeclass.LocalWindowSizeClass
import com.android.systemui.res.R

@@ -61,7 +69,22 @@ fun SceneScope.OverlayShade(
    modifier: Modifier = Modifier,
    content: @Composable () -> Unit,
) {
    Box(modifier) {
    // TODO(b/384653288) This should be removed when b/378470603 is done.
    val idleEffect = rememberOffsetOverscrollEffect(Orientation.Vertical)
    Box(
        modifier
            .overscroll(idleEffect)
            .nestedScroll(
                remember {
                    object : NestedScrollConnection {
                        override suspend fun onPreFling(available: Velocity): Velocity {
                            return available
                        }
                    }
                }
            )
            .scrollable(rememberScrollableState { 0f }, Orientation.Vertical, idleEffect)
    ) {
        Scrim(onClicked = onScrimClicked)

        Box(modifier = Modifier.fillMaxSize().panelPadding(), contentAlignment = Alignment.TopEnd) {