File tree Expand file tree Collapse file tree
cmp-navigation/src/commonMain/kotlin/cmp/navigation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ import androidx.compose.ui.graphics.Color
6666import androidx.compose.ui.layout.ContentScale
6767import androidx.compose.ui.unit.dp
6868import androidx.lifecycle.compose.collectAsStateWithLifecycle
69+ import androidx.navigation.NavGraph.Companion.findStartDestination
6970import androidx.navigation.compose.currentBackStackEntryAsState
7071import cmp.navigation.components.MifosNavigationBar
7172import cmp.navigation.components.NavigationConstants
@@ -195,18 +196,8 @@ fun App(
195196 selected = index == selectedItemIndex,
196197 onClick = {
197198 selectedItemIndex = index
198- selectedItemIndex?.let {
199- appState.navController.apply {
200- navigate(navigationDrawerTabs[it].route) {
201- restoreState = true
202- launchSingleTop = true
203- graph.startDestinationRoute?.let {
204- popUpTo(route = HomeDestinationsScreen .SearchScreen .route) {
205- saveState = true
206- }
207- }
208- }
209- }
199+ appState.navController.navigate(navigationDrawerTabs[index].route) {
200+ launchSingleTop = true
210201 }
211202 scope.launch {
212203 drawerState.close()
@@ -275,10 +266,9 @@ fun App(
275266 navigate(target) {
276267 restoreState = true
277268 launchSingleTop = true
278- graph.startDestinationRoute?.let {
279- popUpTo(route = HomeDestinationsScreen .SearchScreen .route) {
280- saveState = true
281- }
269+ popUpTo(route = graph.findStartDestination().route.toString()) {
270+ saveState = true
271+ inclusive = false
282272 }
283273 }
284274 }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import androidx.compose.material3.NavigationBar
1414import androidx.compose.material3.NavigationBarItem
1515import androidx.compose.material3.Text
1616import androidx.compose.runtime.Composable
17+ import androidx.compose.runtime.remember
1718import androidx.compose.runtime.saveable.rememberSaveable
1819import androidx.compose.ui.Modifier
1920import androidx.compose.ui.graphics.Color
@@ -35,11 +36,13 @@ fun MifosNavigationBar(
3536 HomeDestinationsScreen .GroupListScreen ,
3637 )
3738 }
39+ val isAnyTabSelected = remember(route) { tabs.any { route.contains(it.route) } }
3840
3941 NavigationBar (modifier = modifier) {
4042 tabs.forEach { item ->
4143 val targetRoute = item.route
42- val selected = route.contains(targetRoute)
44+ val selected =
45+ if (isAnyTabSelected) route.contains(targetRoute) else targetRoute == HomeDestinationsScreen .SearchScreen .route
4346 NavigationBarItem (
4447 icon = {
4548 item.icon?.let {
You can’t perform that action at this time.
0 commit comments