android: preserve Runs home navigation stack
This commit is contained in:
@@ -92,6 +92,10 @@ internal val destinations = listOf(
|
|||||||
/** The home route remains beneath top-level navigation, so Back returns to Runs. */
|
/** The home route remains beneath top-level navigation, so Back returns to Runs. */
|
||||||
internal const val HOME_ROUTE = "runs"
|
internal const val HOME_ROUTE = "runs"
|
||||||
|
|
||||||
|
/** Returning to home clears the accumulated top-level stack; other destinations keep it. */
|
||||||
|
internal fun topLevelPopUpToHomeInclusive(destination: String): Boolean =
|
||||||
|
destination == HOME_ROUTE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether [route] is the current destination. Detail panes are no longer
|
* Whether [route] is the current destination. Detail panes are no longer
|
||||||
* separate routes (they are saved state inside a destination), so this is a
|
* separate routes (they are saved state inside a destination), so this is a
|
||||||
@@ -220,7 +224,7 @@ fun PipelinesApp(
|
|||||||
is SearchTarget.Run -> {
|
is SearchTarget.Run -> {
|
||||||
runSelection = PaneSelection(MasterPane.Detail, target.runId)
|
runSelection = PaneSelection(MasterPane.Detail, target.runId)
|
||||||
runSearchNav = target.takeIf { it.sequence > 0 }
|
runSearchNav = target.takeIf { it.sequence > 0 }
|
||||||
navController.navigate("runs") { launchSingleTop = true }
|
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
|
||||||
}
|
}
|
||||||
null -> Unit
|
null -> Unit
|
||||||
}
|
}
|
||||||
@@ -234,7 +238,7 @@ fun PipelinesApp(
|
|||||||
val openRunFromAttention: (Long) -> Unit = { runId ->
|
val openRunFromAttention: (Long) -> Unit = { runId ->
|
||||||
vm.arrivedAtRun(runId)
|
vm.arrivedAtRun(runId)
|
||||||
runSelection = PaneSelection(pane = MasterPane.Detail, itemId = runId)
|
runSelection = PaneSelection(pane = MasterPane.Detail, itemId = runId)
|
||||||
navController.navigate("runs") { launchSingleTop = true }
|
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
// A deep link (or the notification's click action) opens its run once. The
|
// A deep link (or the notification's click action) opens its run once. The
|
||||||
@@ -277,7 +281,9 @@ fun PipelinesApp(
|
|||||||
val onNavigate: (TopDestination) -> Unit = { destination ->
|
val onNavigate: (TopDestination) -> Unit = { destination ->
|
||||||
if (currentRoute != destination.route) {
|
if (currentRoute != destination.route) {
|
||||||
navController.navigate(destination.route) {
|
navController.navigate(destination.route) {
|
||||||
popUpTo(HOME_ROUTE) { inclusive = destination.route == HOME_ROUTE }
|
popUpTo(HOME_ROUTE) {
|
||||||
|
inclusive = topLevelPopUpToHomeInclusive(destination.route)
|
||||||
|
}
|
||||||
launchSingleTop = true
|
launchSingleTop = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,11 +353,11 @@ fun PipelinesApp(
|
|||||||
pane = MasterPane.Detail,
|
pane = MasterPane.Detail,
|
||||||
itemId = runId,
|
itemId = runId,
|
||||||
)
|
)
|
||||||
navController.navigate("runs") { launchSingleTop = true }
|
navController.navigate(HOME_ROUTE) { launchSingleTop = true }
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
composable("runs") {
|
composable(HOME_ROUTE) {
|
||||||
RunsDestination(
|
RunsDestination(
|
||||||
vm = vm,
|
vm = vm,
|
||||||
wide = wide,
|
wide = wide,
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ class PipelinesNavTest {
|
|||||||
assertEquals("runs", HOME_ROUTE)
|
assertEquals("runs", HOME_ROUTE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun returningToHomeIsTheOnlyTopLevelNavigationThatClearsHome() {
|
||||||
|
assertTrue(topLevelPopUpToHomeInclusive(HOME_ROUTE))
|
||||||
|
assertFalse(topLevelPopUpToHomeInclusive("pipelines"))
|
||||||
|
assertFalse(topLevelPopUpToHomeInclusive("chat"))
|
||||||
|
assertFalse(topLevelPopUpToHomeInclusive("settings"))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun thePillDoesNotHoldTemplates() {
|
fun thePillDoesNotHoldTemplates() {
|
||||||
// Templates is configuration and moved to the Settings page; the pill keeps
|
// Templates is configuration and moved to the Settings page; the pill keeps
|
||||||
|
|||||||
Reference in New Issue
Block a user