android / android/adaptive-apps-samples

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

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
75
Forks
25
PR merge metrics
No merged PRs in 30d

Description

The [logic to decide on the navigation component type](https://github.com/android/adaptive-apps-samples/blob/main/AdaptiveJetStream/jetstream/src/main/java/com/google/jetstream/presentation/app/NavigationComponentType.kt#L36) 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`.

Contributor guide

Open the contributing guide

Research direction

Start in AdaptiveJetStream/jetstream/src/main/java/com/google/jetstream/presentation/app/NavigationComponentType.kt, especially rememberNavigationComponentType and its call to currentWindowAdaptiveInfo(). Check how supportLargeAndXLargeWidth affects isLargeWindow. Done means large or extra-large window widths select NavigationComponentType.TopBar; the issue does not name a specific test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.