mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app: never pop the root navigation entry
A screen's back button stays clickable while the screen slides out, so tapping it twice quickly called Navigator.pop() twice. The second call removed Route.Main, and NavDisplay crashed the app because its back stack must not be empty. Make pop() a no-op on the root entry. Leaving the app from the root is handled by the system, not by popping the last entry. Assisted-by: Claude Opus 5.5
This commit is contained in:
@@ -16,7 +16,11 @@ class Navigator(val backStack: NavBackStack<NavKey>) {
|
||||
}
|
||||
|
||||
fun pop(): Boolean {
|
||||
return backStack.removeLastOrNull() != null
|
||||
// Never remove the root: NavDisplay requires a non-empty back stack, and a screen's
|
||||
// back button stays clickable during its exit animation, so it can be tapped again
|
||||
if (backStack.size <= 1) return false
|
||||
backStack.removeAt(backStack.lastIndex)
|
||||
return true
|
||||
}
|
||||
|
||||
fun current(): NavKey? = backStack.lastOrNull()
|
||||
|
||||
Reference in New Issue
Block a user