fix: try fixing backstack introspection

This commit is contained in:
Harsh Shandilya 2025-05-25 16:53:09 +05:30
parent 699afafcf9
commit ec70c9ab56

View file

@ -136,7 +136,7 @@ fun Nav3Screen(
TopAppBar( TopAppBar(
modifier = Modifier.shadow(8.dp), modifier = Modifier.shadow(8.dp),
navigationIcon = { navigationIcon = {
if (backStack.none { it in navDestinations }) { if (backStack.firstOrNull() !in navDestinations) {
IconButton(onClick = { if (backStack.removeLastOrNull() == null) activity?.finish() }) { IconButton(onClick = { if (backStack.removeLastOrNull() == null) activity?.finish() }) {
Icon( Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack, imageVector = Icons.AutoMirrored.Filled.ArrowBack,
@ -152,12 +152,12 @@ fun Nav3Screen(
} }
}, },
title = { title = {
if (backStack.any { it in navDestinations }) { if (backStack.firstOrNull() in navDestinations) {
Text(text = stringResource(R.string.app_name), fontWeight = FontWeight.Bold) Text(text = stringResource(R.string.app_name), fontWeight = FontWeight.Bold)
} }
}, },
actions = { actions = {
if (backStack.any { it in navDestinations }) { if (backStack.firstOrNull() in navDestinations) {
IconButton(onClick = { backStack.add(Search) }) { IconButton(onClick = { backStack.add(Search) }) {
Icon(imageVector = Icons.Filled.Search, contentDescription = "Search posts") Icon(imageVector = Icons.Filled.Search, contentDescription = "Search posts")
} }
@ -173,7 +173,7 @@ fun Nav3Screen(
ClawNavigationBar( ClawNavigationBar(
backStack, backStack,
items = navItems, items = navItems,
isVisible = backStack.any { it in navDestinations }, isVisible = backStack.firstOrNull() in navDestinations,
hazeState = hazeState, hazeState = hazeState,
) )
} }