From 8abcb506edc05b1c9de162e93b0288f8dfd937d4 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Wed, 3 Dec 2025 10:29:56 +0000 Subject: [PATCH] Refactor Navigator goUp to clearSubStack Renamed the `goUp` method to `clearSubStack` to more accurately reflect that its function is to clear the sub-stack. --- .../samples/apps/nowinandroid/core/navigation/Navigator.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.kt index 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() }