fix: apply elevation color thresholds on radar page

LocalElevationThresholds was provided inside MainScreen, but RadarDestination
is a root-level sibling entry in NavRoot's NavDisplay, so the radar page's
top bar fell outside the CompositionLocal scope and always used the default
15/45 thresholds instead of the user-configured ones.

Hoist the CompositionLocalProvider to NavRoot so both the tab content and
the root-level RadarDestination read the user's low/high elevation
thresholds, and drop the now-redundant provider from MainScreen.
This commit is contained in:
atsunatsu committed 2026-09-16 04:17:52 +08:00
1 parent d471f02370
commit c1277763de
1 file changed
+14 -8
@@ -99,6 +99,19 @@ fun NavRoot(deeplink: String? = null) {
// Reverse: outgoing slides out to the right, incoming drifts in from the left
val popTransition = slideInHorizontally(tween(300)) { -it / 3 } togetherWith
slideOutHorizontally(tween(300)) { it }
// Elevation color thresholds must be provided at the root level so that BOTH
// the tab content (MainScreen) and the root-level RadarDestination see the
// user's custom thresholds. RadarDestination is a sibling entry of MainScreen
// in this NavDisplay, so a provider inside MainScreen never reaches it.
val context = LocalContext.current
val container = (context.applicationContext as IContainerProvider).getMainContainer()
val otherSettings by container.settingsRepo.otherSettings.collectAsStateWithLifecycle()
CompositionLocalProvider(
LocalElevationThresholds provides ElevationThresholds(
low = otherSettings.lowElevation,
high = otherSettings.highElevation
)
) {
NavDisplay(
modifier = Modifier.fillMaxSize(),
backStack = rootBackStack,
@@ -122,6 +135,7 @@ fun NavRoot(deeplink: String? = null) {
}
}
)
}
}
@Composable
@@ -129,7 +143,6 @@ private fun MainScreen(navigateToRadar: () -> Unit = {}) {
val context = LocalContext.current
val container = (context.applicationContext as IContainerProvider).getMainContainer()
val trackingState by container.radioTrackingService.state.collectAsStateWithLifecycle()
val otherSettings by container.settingsRepo.otherSettings.collectAsStateWithLifecycle()
val backStack = rememberNavBackStack(Screen.Passes)
val currentKey = backStack.lastOrNull()
@@ -139,12 +152,6 @@ private fun MainScreen(navigateToRadar: () -> Unit = {}) {
val navItems =
listOf(Screen.Satellites, Screen.Passes, Screen.Status, Screen.Map, Screen.Settings)
CompositionLocalProvider(
LocalElevationThresholds provides ElevationThresholds(
low = otherSettings.lowElevation,
high = otherSettings.highElevation
)
) {
NavigationSuiteScaffold(
navigationSuiteItems = {
navItems.forEach { screen ->
@@ -223,7 +230,6 @@ private fun MainScreen(navigateToRadar: () -> Unit = {}) {
}
}
}
}
}
@Composable