Refactor Navigator goUp to clearSubStack

Renamed the `goUp` method to `clearSubStack` to more accurately reflect that its function is to clear the sub-stack.
pull/2003/head
Don Turner 9 months ago
parent 8f269ff57a
commit 8abcb506ed

@ -32,7 +32,7 @@ class Navigator(val state: NavigationState) {
*/ */
fun navigate(key: NavKey) { fun navigate(key: NavKey) {
when (key) { when (key) {
state.currentTopLevelKey -> goUp() state.currentTopLevelKey -> clearSubStack()
in state.topLevelKeys -> goToTopLevel(key) in state.topLevelKeys -> goToTopLevel(key)
else -> goToKey(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 { state.currentSubStack.run {
if (size > 1) subList(1, size).clear() if (size > 1) subList(1, size).clear()
} }

Loading…
Cancel
Save