Created
December 21, 2019 23:02
-
-
Save zsoltk/466b35a90e325b84f2bbcaa3e87b194c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Content(backPress: Backpress, cantPopBackStack: () -> Unit) { | |
// remainder omitted | |
var unhandledCount = +memo { State(0) } | |
val nbChildren = 2 | |
val cantPopBackStackDelegate = { | |
// if we tried all of them and failed... | |
if (++unhandledCount.value == nbChildren) { | |
// ...then comes our local handling | |
if (!backStack.pop()) { | |
cantPopBackStack() | |
} | |
// don't forget to reset | |
unhandledCount.value = 0 | |
} | |
} | |
SomeChild1.Content( | |
backPress = backPress, | |
cantPopBackStack = cantPopBackStackDelegate | |
) | |
SomeChild2.Content( | |
backPress = backPress, | |
cantPopBackStack = cantPopBackStackDelegate | |
) | |
// and so on ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment