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

Commit 5ca8c956 authored by Omar Miatello's avatar Omar Miatello Committed by Android (Google) Code Review
Browse files

Merge changes Idd46c15d,I89ce6f00 into main

* changes:
  QS avoid clip at the bottom of the shade
  QS skip squishing during lookahead or when squishiness is 1.0
parents b4c8add5 5a1fade5
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredHeight
@@ -234,7 +235,6 @@ fun ContentScope.QuickSettingsLayout(
            modifier.padding(
            modifier.padding(
                start = QuickSettingsShade.Dimensions.Padding,
                start = QuickSettingsShade.Dimensions.Padding,
                end = QuickSettingsShade.Dimensions.Padding,
                end = QuickSettingsShade.Dimensions.Padding,
                bottom = QuickSettingsShade.Dimensions.Padding,
            ),
            ),
    ) {
    ) {
        if (isFullWidthShade()) {
        if (isFullWidthShade()) {
@@ -304,13 +304,9 @@ fun ContentScope.QuickSettingsLayout(
                }
                }
            }
            }


            Box {
            GridAnchor()
            GridAnchor()
                TileGrid(
            TileGrid(viewModel = viewModel.tileGridViewModel, modifier = Modifier.fillMaxWidth())
                    viewModel = viewModel.tileGridViewModel,
            Spacer(Modifier.padding(bottom = QuickSettingsShade.Dimensions.Padding))
                    modifier = Modifier.fillMaxWidth(),
                )
            }
        }
        }
    }
    }
}
}
+22 −10
Original line number Original line Diff line number Diff line
@@ -33,16 +33,28 @@ import kotlin.math.roundToInt
 * also use an approachLayout tracking the squishiness.
 * also use an approachLayout tracking the squishiness.
 */
 */
fun Modifier.verticalSquish(squishiness: () -> Float): Modifier {
fun Modifier.verticalSquish(squishiness: () -> Float): Modifier {
    return approachLayout(isMeasurementApproachInProgress = { squishiness() < 1 }) { measurable, _
    return approachLayout(
        ->
        isMeasurementApproachInProgress = { squishiness() < 1 },
        val squishinessValue = squishiness()
        approachMeasure = { measurable, constraints ->
            val value = squishiness()

            // Skip squishing during lookahead or when squishiness is 1.0.
            // Lookahead: Ensures accurate pre-layout size.
            // Squishiness 1f: Prevents unnecessary calculations when no squishing is needed.
            if (isLookingAhead || value == 1f) {
                return@approachLayout measurable.measure(constraints).run {
                    layout(width, height) { place(0, 0) }
                }
            }

            val expectedHeight = lookaheadSize.height
            val expectedHeight = lookaheadSize.height


            val placeable = measurable.measure(lookaheadConstraints)
            val placeable = measurable.measure(lookaheadConstraints)
        val squishedHeight = (expectedHeight * squishinessValue).roundToInt()
            val squishedHeight = (expectedHeight * value).roundToInt()
            // Center the content by moving it UP (squishedHeight < actualHeight)
            // Center the content by moving it UP (squishedHeight < actualHeight)
            val scroll = (squishedHeight - expectedHeight) / 2
            val scroll = (squishedHeight - expectedHeight) / 2


            layout(placeable.width, squishedHeight) { placeable.place(0, scroll) }
            layout(placeable.width, squishedHeight) { placeable.place(0, scroll) }
    }
        },
    )
}
}