A fully functional Android app built entirely with Kotlin and Jetpack Compose
Refactor Navigator goUp to clearSubStack
Don Turner8abcb506edc0
diff --git a/core/navigation/src/main/kotlin/com/google/samples/apps/nowinandroid/core/navigation/Navigator.kt b/core/navigation/src/main/kotlin/com/google/samples/apps/nowinandroid/core/navigation/Navigator.ktindex e98e2c12b..c1c456476 100644--- a/core/navigation/src/main/kotlin/com/google/samples/apps/nowinandroid/core/navigation/Navigator.kt+++ b/core/navigation/src/main/kotlin/com/google/samples/apps/nowinandroid/core/navigation/Navigator.kt@@ -32,7 +32,7 @@ class Navigator(val state: NavigationState) {*/fun navigate(key: NavKey) {when (key) {- state.currentTopLevelKey -> goUp()+ state.currentTopLevelKey -> clearSubStack()in state.topLevelKeys -> goToTopLevel(key)else -> goToKey(key)}@@ -81,9 +81,9 @@ class Navigator(val state: NavigationState) {}/**- * Go up in the current sub stack by clearing all but the root key.+ * Clearing all but the root key in the current sub stack.*/- private fun goUp() {+ private fun clearSubStack() {state.currentSubStack.run {if (size > 1) subList(1, size).clear()}