mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
fix: prevent popping the last item from backStack if it's the only item
This commit is contained in:
@@ -155,7 +155,7 @@ class PurefinActivity : ComponentActivity() {
|
|||||||
LaunchedEffect(navigationManager, backStack) {
|
LaunchedEffect(navigationManager, backStack) {
|
||||||
navigationManager.commands.collect { command ->
|
navigationManager.commands.collect { command ->
|
||||||
when (command) {
|
when (command) {
|
||||||
NavigationCommand.Pop -> backStack.removeLastOrNull()
|
NavigationCommand.Pop -> if (backStack.size > 1) backStack.removeLastOrNull()
|
||||||
is NavigationCommand.Navigate -> backStack.add(command.route)
|
is NavigationCommand.Navigate -> backStack.add(command.route)
|
||||||
is NavigationCommand.ReplaceAll -> {
|
is NavigationCommand.ReplaceAll -> {
|
||||||
backStack.clear()
|
backStack.clear()
|
||||||
@@ -168,6 +168,7 @@ class PurefinActivity : ComponentActivity() {
|
|||||||
CompositionLocalProvider(LocalNavigationManager provides navigationManager) {
|
CompositionLocalProvider(LocalNavigationManager provides navigationManager) {
|
||||||
NavDisplay(
|
NavDisplay(
|
||||||
backStack = backStack,
|
backStack = backStack,
|
||||||
|
onBack = { navigationManager.pop() },
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
entryDecorators =
|
entryDecorators =
|
||||||
listOf(
|
listOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user