Skip to content

[Adaptive JetStream] TopBar layout is not used even when the window width is Large #33

@dturner

Description

@dturner

The logic to decide on the navigation component type looks like it should use a top bar layout if the window width is large or above:

@Composable
fun rememberNavigationComponentType(): NavigationComponentType {
    val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
    val isLeanbackEnabled = isLeanbackEnabled()
    val isAutomotiveEnabled = isAutomotiveEnabled()
    
    val isPreview = LocalInspectionMode.current
    val isSpatialUiEnabled = if (isPreview) {
        false
    } else {
        hasXrSpatialFeature() && isSpatialUiEnabled()
    }

    return remember(isLeanbackEnabled, isAutomotiveEnabled, windowSizeClass, isSpatialUiEnabled) {
        selectNavigationComponentType(
            isLeanbackEnabled = isLeanbackEnabled,
            isAutomotiveEnabled = isAutomotiveEnabled,
            isLargeWindow = windowSizeClass.isWidthAtLeastLarge(),
            isSpatialUiEnabled = isSpatialUiEnabled
        )
    }
}

// Select the navigation component type based on the available input devices.
private fun selectNavigationComponentType(
    isLeanbackEnabled: Boolean,
    isAutomotiveEnabled: Boolean,
    isLargeWindow: Boolean,
    isSpatialUiEnabled: Boolean,
): NavigationComponentType {
    return when {
        isSpatialUiEnabled -> NavigationComponentType.Spatial
        isLeanbackEnabled -> NavigationComponentType.TopBar
        isAutomotiveEnabled -> NavigationComponentType.TopBar
        isLargeWindow -> NavigationComponentType.TopBar
        else -> NavigationComponentType.NavigationSuiteScaffold
    }
}

However, when currentWindowAdaptiveInfo() has a parameter supportLargeAndXLargeWidth which defaults to false meaning that even on large screens, isLargeWindow will still be false.

Suggest updating to set this parameter to true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions