mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Fix console crash with competing animations / layout.
This commit is contained in:
@@ -129,6 +129,13 @@ fun CallElementsLayout(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum class BlurrableContentSlot {
|
||||||
|
BARS,
|
||||||
|
GRID,
|
||||||
|
REACTIONS,
|
||||||
|
OVERFLOW
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun BlurrableContentLayer(
|
private fun BlurrableContentLayer(
|
||||||
isFocused: Boolean,
|
isFocused: Boolean,
|
||||||
@@ -144,17 +151,17 @@ private fun BlurrableContentLayer(
|
|||||||
isBlurred = isFocused,
|
isBlurred = isFocused,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
Layout(
|
SubcomposeLayout(modifier = Modifier.fillMaxSize()) { constraints ->
|
||||||
contents = listOf(barsSlot, callGridSlot, reactionsSlot, callOverflowSlot),
|
|
||||||
modifier = Modifier.fillMaxSize()
|
|
||||||
) { measurables, constraints ->
|
|
||||||
val looseConstraints = constraints.copy(minWidth = 0, minHeight = 0)
|
val looseConstraints = constraints.copy(minWidth = 0, minHeight = 0)
|
||||||
val overflowPlaceables = measurables[3].map { it.measure(looseConstraints) }
|
|
||||||
|
val overflowPlaceables = subcompose(BlurrableContentSlot.OVERFLOW, callOverflowSlot)
|
||||||
|
.map { it.measure(looseConstraints) }
|
||||||
val constrainedHeightOffset = if (isPortrait) overflowPlaceables.maxOfOrNull { it.height } ?: 0 else 0
|
val constrainedHeightOffset = if (isPortrait) overflowPlaceables.maxOfOrNull { it.height } ?: 0 else 0
|
||||||
val constrainedWidthOffset = if (isPortrait) { 0 } else overflowPlaceables.maxOfOrNull { it.width } ?: 0
|
val constrainedWidthOffset = if (isPortrait) 0 else overflowPlaceables.maxOfOrNull { it.width } ?: 0
|
||||||
|
|
||||||
val nonOverflowConstraints = looseConstraints.offset(horizontal = -constrainedWidthOffset, vertical = -constrainedHeightOffset)
|
val nonOverflowConstraints = looseConstraints.offset(horizontal = -constrainedWidthOffset, vertical = -constrainedHeightOffset)
|
||||||
val gridPlaceables = measurables[1].map { it.measure(nonOverflowConstraints) }
|
val gridPlaceables = subcompose(BlurrableContentSlot.GRID, callGridSlot)
|
||||||
|
.map { it.measure(nonOverflowConstraints) }
|
||||||
|
|
||||||
val barConstraints = if (bottomInsetPx > constrainedHeightOffset) {
|
val barConstraints = if (bottomInsetPx > constrainedHeightOffset) {
|
||||||
looseConstraints.offset(-constrainedWidthOffset, -bottomInsetPx)
|
looseConstraints.offset(-constrainedWidthOffset, -bottomInsetPx)
|
||||||
@@ -166,11 +173,13 @@ private fun BlurrableContentLayer(
|
|||||||
val barsMaxWidth = minOf(barConstraints.maxWidth, bottomSheetWidthPx)
|
val barsMaxWidth = minOf(barConstraints.maxWidth, bottomSheetWidthPx)
|
||||||
val barsConstrainedToSheet = barConstraints.copy(maxWidth = barsMaxWidth)
|
val barsConstrainedToSheet = barConstraints.copy(maxWidth = barsMaxWidth)
|
||||||
|
|
||||||
val barsPlaceables = measurables[0].map { it.measure(barsConstrainedToSheet) }
|
val barsPlaceables = subcompose(BlurrableContentSlot.BARS, barsSlot)
|
||||||
|
.map { it.measure(barsConstrainedToSheet) }
|
||||||
|
|
||||||
val barsHeightOffset = barsPlaceables.sumOf { it.height }
|
val barsHeightOffset = barsPlaceables.sumOf { it.height }
|
||||||
val reactionsConstraints = barConstraints.offset(vertical = -barsHeightOffset)
|
val reactionsConstraints = barConstraints.offset(vertical = -barsHeightOffset)
|
||||||
val reactionsPlaceables = measurables[2].map { it.measure(reactionsConstraints) }
|
val reactionsPlaceables = subcompose(BlurrableContentSlot.REACTIONS, reactionsSlot)
|
||||||
|
.map { it.measure(reactionsConstraints) }
|
||||||
|
|
||||||
layout(looseConstraints.maxWidth, looseConstraints.maxHeight) {
|
layout(looseConstraints.maxWidth, looseConstraints.maxHeight) {
|
||||||
overflowPlaceables.forEach {
|
overflowPlaceables.forEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user