summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ale Nijamkin <nijamkin@google.com> 2023-03-28 17:13:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-03-28 17:13:59 +0000
commitd710ab4aadc682dea1ce280e1f6974ff76d0c7c0 (patch)
treecfdcef808af89ff7ecf71296ded927d8b2b6d258
parenta374e17c03fc46c94106fa9f2af072808b8800b7 (diff)
parentc270be975cf1a2d5bfd34db1c279715533330ab4 (diff)
Merge "[multi-shade] Remove shade content padding when the shade is collapsed." into udc-dev
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt23
1 files changed, 21 insertions, 2 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt b/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt
index 98ef57f94783..cfcc2fb251fd 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt
@@ -22,7 +22,6 @@ import androidx.compose.foundation.interaction.DragInteraction
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
@@ -41,6 +40,7 @@ import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.compose.modifiers.height
+import com.android.compose.modifiers.padding
import com.android.compose.swipeable.FixedThreshold
import com.android.compose.swipeable.SwipeableState
import com.android.compose.swipeable.ThresholdConfig
@@ -48,6 +48,7 @@ import com.android.compose.swipeable.rememberSwipeableState
import com.android.compose.swipeable.swipeable
import com.android.systemui.multishade.shared.model.ProxiedInputModel
import com.android.systemui.multishade.ui.viewmodel.ShadeViewModel
+import kotlin.math.min
import kotlin.math.roundToInt
import kotlinx.coroutines.launch
@@ -145,13 +146,31 @@ private fun ShadeContent(
modifier: Modifier = Modifier,
content: @Composable () -> Unit = {},
) {
+ /**
+ * Returns a function that takes in [Density] and returns the current padding around the shade
+ * content.
+ */
+ fun padding(
+ shadeHeightPx: () -> Float,
+ ): Density.() -> Int {
+ return {
+ min(
+ 12.dp.toPx().roundToInt(),
+ shadeHeightPx().roundToInt(),
+ )
+ }
+ }
+
Surface(
shape = RoundedCornerShape(32.dp),
modifier =
modifier
- .padding(12.dp)
.fillMaxWidth()
.height { shadeHeightPx().roundToInt() }
+ .padding(
+ horizontal = padding(shadeHeightPx),
+ vertical = padding(shadeHeightPx),
+ )
.graphicsLayer {
// Applies the vertical over-stretching of the shade content that may happen if
// the user keep dragging down when the shade is already fully-expanded.