Repository: android/compose-samples
File: Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt (Kotlin)

Code before:
                podcastImageUrl = uiState.podcastImageUrl,
                modifier = Modifier.weight(10f)
            )
            Spacer(modifier = Modifier.height(32.dp))
            PodcastDescription(uiState.title, uiState.podcastName)
            Spacer(modifier = Modifier.height(32.dp))
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.weight(10f)
            ) {
                PlayerSlider(uiState.duration)
                PlayerButtons(Modifier.padding(vertical = 8.dp))
            }
            Spacer(modifier = Modifier.weight(1f))
        }
    }
}

@Composable
private fun PlayerContentTableTop(
    uiState: PlayerUiState,
    windowInfo: WindowInfo,
    onBackPress: () -> Unit
) {
    val hingeRect: Rect = windowInfo.hingePosition
        ?: throw IllegalStateException("Bounds should never be null in tabletop mode")

    val hingePosition = with(LocalDensity.current) { hingeRect.top.toDp() }
    val hingeHeight = with(LocalDensity.current) { (hingeRect.bottom - hingeRect.top).toDp() }

    Column(modifier = Modifier.fillMaxSize()) {
        // Content for the top part of the screen
        Column(
            modifier = Modifier
                .height(hingePosition)
                .fillMaxWidth()
                .verticalGradientScrim(
                    color = MaterialTheme.colors.primary.copy(alpha = 0.50f),
                    startYPercentage = 1f,
                    endYPercentage = 0f
                )
                .systemBarsPadding(bottom = false)
                .padding(32.dp),
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            PlayerImage(uiState.podcastImageUrl)
        }
        // Space for the hinge
        Spacer(modifier = Modifier.height(hingeHeight))
        // Content for the table part of the screen
        Column(

Review comment (suggestion):
Small request:

Can we expand `FoldableInfo` so that it is more typesafe? That would avoid the need for this `throw`.

Something along the lines of

```kotlin
sealed interface FoldableInfo {
    object NormalPosture : FoldableInfo
    
    data class TableTopPosture(
        hingePosition: Rect
    ) : FoldableInfo
    
    object BookPosture : FoldableInfo
}
```

Then `PlayerContentTableTop` could only accept a `FoldableInfo.TableTopPosture`, which would be guaranteed to have a `hingePosition`.

Code after:
                modifier = Modifier.weight(10f)
            )
            Spacer(modifier = Modifier.height(32.dp))
            PodcastDescription(uiState.title, uiState.podcastName)
            Spacer(modifier = Modifier.height(32.dp))
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.weight(10f)
            ) {
                PlayerSlider(uiState.duration)
                PlayerButtons(Modifier.padding(vertical = 8.dp))
            }
            Spacer(modifier = Modifier.weight(1f))
        }
    }
}

@Composable
private fun PlayerContentTableTop(
    uiState: PlayerUiState,
    tableTopPosture: DevicePosture.TableTopPosture,
    onBackPress: () -> Unit
) {
    val hingePosition = with(LocalDensity.current) { tableTopPosture.hingePosition.top.toDp() }
    val hingeHeight = with(LocalDensity.current) { tableTopPosture.hingePosition.height().toDp() }

    Column(modifier = Modifier.fillMaxSize()) {
        // Content for the top part of the screen
        Column(
            modifier = Modifier
                .height(hingePosition)
                .fillMaxWidth()
                .verticalGradientScrim(
                    color = MaterialTheme.colors.primary.copy(alpha = 0.50f),
                    startYPercentage = 1f,
                    endYPercentage = 0f
                )
                .systemBarsPadding(bottom = false)
                .padding(32.dp),
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            PlayerImage(uiState.podcastImageUrl)
        }
        // Space for the hinge
        Spacer(modifier = Modifier.height(hingeHeight))
        // Content for the table part of the screen
        Column(
            modifier = Modifier
                .systemBarsPadding(top = false)
                .padding(horizontal = 32.dp, vertical = 8.dp),
            horizontalAlignment = Alignment.CenterHorizontally