Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions cmp-navigation/src/commonMain/kotlin/cmp/navigation/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.currentBackStackEntryAsState
import cmp.navigation.components.MifosNavigationBar
import cmp.navigation.components.NavigationConstants
Expand Down Expand Up @@ -195,18 +196,8 @@ fun App(
selected = index == selectedItemIndex,
onClick = {
selectedItemIndex = index
selectedItemIndex?.let {
appState.navController.apply {
navigate(navigationDrawerTabs[it].route) {
restoreState = true
launchSingleTop = true
graph.startDestinationRoute?.let {
popUpTo(route = HomeDestinationsScreen.SearchScreen.route) {
saveState = true
}
}
}
}
appState.navController.navigate(navigationDrawerTabs[index].route) {
launchSingleTop = true
}
scope.launch {
drawerState.close()
Expand Down Expand Up @@ -275,10 +266,9 @@ fun App(
navigate(target) {
restoreState = true
launchSingleTop = true
graph.startDestinationRoute?.let {
popUpTo(route = HomeDestinationsScreen.SearchScreen.route) {
saveState = true
}
popUpTo(route = graph.findStartDestination().route.toString()) {
saveState = true
inclusive = false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -35,11 +36,13 @@ fun MifosNavigationBar(
HomeDestinationsScreen.GroupListScreen,
)
}
val isAnyTabSelected = remember(route) { tabs.any { route.contains(it.route) } }

NavigationBar(modifier = modifier) {
tabs.forEach { item ->
val targetRoute = item.route
val selected = route.contains(targetRoute)
val selected =
if (isAnyTabSelected) route.contains(targetRoute) else targetRoute == HomeDestinationsScreen.SearchScreen.route
NavigationBarItem(
icon = {
item.icon?.let {
Expand Down