From 493208c2afb29927696d54af3a3c4b267d39f498 Mon Sep 17 00:00:00 2001 From: christianrowlands Date: Sat, 2 Nov 2024 11:54:33 -0400 Subject: [PATCH] WIP: Handle updating the bottom nav selected item when hitting back while on a different bottom tab --- .../com/craxiom/networksurvey/ui/main/HomeScreen.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/ui/main/HomeScreen.kt b/networksurvey/src/main/java/com/craxiom/networksurvey/ui/main/HomeScreen.kt index b09baa07..37cbe3d7 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/ui/main/HomeScreen.kt +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/ui/main/HomeScreen.kt @@ -59,6 +59,16 @@ fun HomeScreen( var showGnssFilterDialog by remember { mutableStateOf(false) } var showGnssSortDialog by remember { mutableStateOf(false) } + bottomNavController.addOnDestinationChangedListener { _, destination, _ -> + BottomNavItem().bottomNavigationItems().forEachIndexed { index, item -> + // Only needed to update the selected item when hitting back from a bottom tab (which + // takes you to the dashboard tab) + if (destination.route == item.route) { + bottomNavSelectedItem = index + } + } + } + Scaffold( topBar = { AppBar(