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

Code before:
        maxVerticalPartitions,
        horizontalSpacerSize,
        defaultPanePreferredWidth,
        getExcludedVerticalBounds(windowAdaptiveInfo.windowPosture, verticalHingePolicy)
    )
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
private fun getExcludedVerticalBounds(posture: Posture, hingePolicy: HingePolicy): List<Rect> {
    return when (hingePolicy) {
        HingePolicy.AvoidSeparating -> posture.separatingVerticalHingeBounds
        HingePolicy.AvoidOccluding -> posture.occludingVerticalHingeBounds
        HingePolicy.AlwaysAvoid -> posture.allVerticalHingeBounds
        else -> emptyList()
    }
}

private fun androidx.window.core.layout.WindowSizeClass.isCompact(): Boolean =
    windowWidthSizeClass == WindowWidthSizeClass.COMPACT ||
        windowHeightSizeClass == WindowHeightSizeClass.COMPACT

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun MainScreen(
    windowSizeClass: WindowSizeClass,
    navigateToPlayer: (EpisodeInfo) -> Unit,
    viewModel: HomeViewModel = hiltViewModel()
) {
    val viewState by viewModel.state.collectAsStateWithLifecycle()
    val navigator = rememberSupportingPaneScaffoldNavigator<String>(
        scaffoldDirective = calculateScaffoldDirective(currentWindowAdaptiveInfo())
    )
    BackHandler(enabled = navigator.canNavigateBack()) {
        navigator.navigateBack()
    }

    val homeState = HomeState(
        windowSizeClass = windowSizeClass,
        featuredPodcasts = viewState.featuredPodcasts,
        isRefreshing = viewState.refreshing,
        homeCategories = viewState.homeCategories,
        selectedHomeCategory = viewState.selectedHomeCategory,
        filterableCategoriesModel = viewState.filterableCategoriesModel,
        podcastCategoryFilterResult = viewState.podcastCategoryFilterResult,
        library = viewState.library,
        onHomeCategorySelected = viewModel::onHomeCategorySelected,
        onCategorySelected = viewModel::onCategorySelected,
        onPodcastUnfollowed = viewModel::onPodcastUnfollowed,
        navigateToPodcastDetails = {
            navigator.navigateTo(SupportingPaneScaffoldRole.Supporting, it.uri)
        },

Review comment (suggestion):
There are currently two different `WindowSizeClass` symbols, one in `androidx-window` (used by the `adaptive` deps), and one in `material3-window-size-class`. I think things are moving towards the `androidx-window` one, and I have a mind to migrate all usages of the other, but not sure if this PR is the right place for that. 

Code after:
    val defaultPanePreferredWidth = 360.dp

    return PaneScaffoldDirective(
        maxHorizontalPartitions,
        verticalSpacerSize,
        maxVerticalPartitions,
        horizontalSpacerSize,
        defaultPanePreferredWidth,
        getExcludedVerticalBounds(windowAdaptiveInfo.windowPosture, verticalHingePolicy)
    )
}

/**
 * Copied from `getExcludedVerticalBounds()` in [PaneScaffoldDirective] since it is private.
 */
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
private fun getExcludedVerticalBounds(posture: Posture, hingePolicy: HingePolicy): List<Rect> {
    return when (hingePolicy) {
        HingePolicy.AvoidSeparating -> posture.separatingVerticalHingeBounds
        HingePolicy.AvoidOccluding -> posture.occludingVerticalHingeBounds
        HingePolicy.AlwaysAvoid -> posture.allVerticalHingeBounds
        else -> emptyList()
    }
}

private fun androidx.window.core.layout.WindowSizeClass.isCompact(): Boolean =
    windowWidthSizeClass == WindowWidthSizeClass.COMPACT ||
        windowHeightSizeClass == WindowHeightSizeClass.COMPACT

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun MainScreen(
    windowSizeClass: WindowSizeClass,
    navigateToPlayer: (EpisodeInfo) -> Unit,
    viewModel: HomeViewModel = hiltViewModel()
) {
    val viewState by viewModel.state.collectAsStateWithLifecycle()
    val navigator = rememberSupportingPaneScaffoldNavigator<String>(
        scaffoldDirective = calculateScaffoldDirective(currentWindowAdaptiveInfo())
    )
    BackHandler(enabled = navigator.canNavigateBack()) {
        navigator.navigateBack()
    }

    val homeState = HomeState(
        windowSizeClass = windowSizeClass,
        featuredPodcasts = viewState.featuredPodcasts,
        isRefreshing = viewState.refreshing,
        homeCategories = viewState.homeCategories,
        selectedHomeCategory = viewState.selectedHomeCategory,
        filterableCategoriesModel = viewState.filterableCategoriesModel,