From 462c3de15573cd165fe914d4e19e0d21c2d830f1 Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Wed, 16 Sep 2026 02:41:53 +0800 Subject: [PATCH] fix(radar): elevation color thresholds not applied on radar page Root cause: LocalElevationThresholds was provided inside MainScreen, but RadarDestination is a root-level sibling entry in NavRoot's NavDisplay, so it fell outside the CompositionLocal scope and always used the default 15/45 thresholds. Fix: hoist the CompositionLocalProvider to NavRoot so both the tab content and the root-level RadarDestination read the user's low/high elevation thresholds. Also affects upstream (same navigation structure). --- .../java/com/rtbishop/look4sat/MainScreen.kt | 64 +++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt b/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt index c5a246bc..e0a6a5ab 100644 --- a/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt +++ b/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt @@ -104,33 +104,47 @@ 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 } - NavDisplay( - modifier = Modifier.fillMaxSize(), - backStack = rootBackStack, - onBack = navigateBack, - transitionSpec = { pushTransition }, - popTransitionSpec = { popTransition }, - predictivePopTransitionSpec = { popTransition }, - entryDecorators = listOf( - rememberSaveableStateHolderNavEntryDecorator(), - rememberViewModelStoreNavEntryDecorator() - ), - entryProvider = entryProvider { - entry { - MainScreen( - navigateToRadar = navigateToRadar - ) - } - entry { - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background - ) { - RadarDestination(navigateUp = navigateBack) + // 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, + onBack = navigateBack, + transitionSpec = { pushTransition }, + popTransitionSpec = { popTransition }, + predictivePopTransitionSpec = { popTransition }, + entryDecorators = listOf( + rememberSaveableStateHolderNavEntryDecorator(), + rememberViewModelStoreNavEntryDecorator() + ), + entryProvider = entryProvider { + entry { + MainScreen( + navigateToRadar = navigateToRadar + ) + } + entry { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + RadarDestination(navigateUp = navigateBack) + } } } - } - ) + ) + } } @Composable