fix(navigation): dynamically update bottom navigation items
This commit is contained in:
1 parent
67c633396e
commit
91ad09b5f2
2 files changed
+14
-6
No files matched your search
@@ -179,12 +179,11 @@ fun MainNavigation() {
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// Read dynamic bottom-nav config.
|
||||
// NB: deliberately NOT wrapped in remember { … } — AuthManager values change
|
||||
// when the user customises items in Settings (saved to SharedPreferences).
|
||||
// Without a key that tracks prefs changes, remember would cache the stale
|
||||
// defaults and the NavigationBar would never reflect the user's picks.
|
||||
// Reading fresh on every recomposition is negligible (pure map over 18 items).
|
||||
val bottomNavItems = resolveBottomNavItems(AuthManager.getBottomNavItems())
|
||||
// AuthManager.bottomNavItemsFlow is a StateFlow that emits updates when the user
|
||||
// customises items in Settings. Using collectAsState() ensures the NavigationBar
|
||||
// recomposes and reflects choices instantly.
|
||||
val bottomNavItemsState by AuthManager.bottomNavItemsFlow.collectAsState()
|
||||
val bottomNavItems = resolveBottomNavItems(bottomNavItemsState)
|
||||
val bottomNavKeys = remember(bottomNavItems) { bottomNavItems.map { it.key }.toSet() }
|
||||
|
||||
// Sync primary screens to NavigationController
|
||||
|
||||
Reference in new issue
Block a user