I have a question regarding SubcomposeLayout anima...
# compose
o
I have a question regarding SubcomposeLayout animations - I have a custom subcompsose layout that lays out a player and the content behind just like youtube app for eg. but in my case whenever i want to minize the player, i want to change the width and height of the layout so that it could show up a PIP like window instead like the one from youtube app. Could someone kindly help me with figuring out how to update it? 🧵
Copy code
@Composable
private fun PlayerScaffoldLayout(
    modifier: Modifier,
    state: PlayerState,
    containerColor: Color,
    contentColor: Color,
    content: @Composable () -> Unit,
    player: @Composable (layoutHeight: Int) -> Unit,
) {
    SubcomposeLayout { constraints ->
        val layoutWidth = constraints.maxWidth
        val layoutHeight = constraints.maxHeight
        val looseConstraints = constraints.copy(minWidth = 0, minHeight = 0)
        
        val playerPlaceable = subcompose(Player) {
            player(layoutHeight)
        }[0].measure(looseConstraints.copy())
        val playerOffsetX = Integer.max(0, (layoutWidth - playerPlaceable.width) / 2)
        val playerOffsetY = state.requireOffset().roundToInt()

        val contentConstraints = looseConstraints.copy(maxHeight = layoutHeight)
        val contentPlaceable = subcompose(Content) {
            Surface(
                modifier = modifier,
                color = containerColor,
                contentColor = contentColor,
            ) {
                content()
            }
        }[0].measure(contentConstraints)

        layout(layoutWidth, layoutHeight) {
            // Placement order is important for elevation
            contentPlaceable.placeRelative(0, 0)
            playerPlaceable.placeRelative(playerOffsetX, playerOffsetY)
        }
    }
}
in the above code, it is now animating like the youtube app, but i want the player composable to have a fixed size like for eg 16:9 aspect ratio.