Skip to content

Commit

Permalink
Merge pull request bumble-tech#275 from KovalevAndrey/fix-backstack-s…
Browse files Browse the repository at this point in the history
…ample-crash

Fix backstack crash
  • Loading branch information
KovalevAndrey authored Nov 16, 2022
2 parents 6e62636 + 83b0737 commit 7e1c70a
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class BackStackExampleNode(
}

@Composable
@Suppress("ComplexMethod")
private fun MissingParamsColumn(
selectedOperation: MutableState<Operation?>,
selectedChildRadioButton: MutableState<String>,
Expand Down Expand Up @@ -345,20 +346,23 @@ class BackStackExampleNode(
Button(
enabled = selectedOperation.value != null && !areThereMissingParams.value,
onClick = {
val element =

fun getElement() =
selectedChildRadioButton.value.toChild(random = defaultOrRandomRadioButton.value.random)

when (selectedOperation.value) {
PUSH -> backStack.push(element)
PUSH -> backStack.push(getElement())
POP -> backStack.pop()
REPLACE -> backStack.replace(element)
NEW_ROOT -> backStack.newRoot(element)
SINGLE_TOP -> backStack.singleTop(element)
REPLACE -> backStack.replace(getElement())
NEW_ROOT -> backStack.newRoot(getElement())
SINGLE_TOP -> backStack.singleTop(getElement())
REMOVE -> {
backStack.remove(backStackState.value.first { it.key.id == selectedId.value }.key)
selectedId.value = ""
}
null -> Unit
else -> Unit
}

}
) {
Text(text = "Perform")
Expand Down

0 comments on commit 7e1c70a

Please sign in to comment.