diff --git a/demo/src/main/kotlin/com/kiwi/navigationcompose/typed/demo/screens/NameEditDialog.kt b/demo/src/main/kotlin/com/kiwi/navigationcompose/typed/demo/screens/NameEditDialog.kt index c6c64ab..2196608 100644 --- a/demo/src/main/kotlin/com/kiwi/navigationcompose/typed/demo/screens/NameEditDialog.kt +++ b/demo/src/main/kotlin/com/kiwi/navigationcompose/typed/demo/screens/NameEditDialog.kt @@ -20,9 +20,9 @@ internal fun NameEditDialog(navController: NavController) { NameEdit( onNameSave = { name -> navController.setResult(ProfileDestinations.NameEditDialog.Result(name)) - navController.navigateUp() + navController.popBackStack() }, - onDismiss = navController::navigateUp, + onDismiss = navController::popBackStack, ) } diff --git a/readme.md b/readme.md index deee25e..866fe66 100644 --- a/readme.md +++ b/readme.md @@ -150,7 +150,9 @@ Another set of functionality is provided to support the result sharing. First, d ```kotlin import com.kiwi.navigationcompose.typed.Destination +import com.kiwi.navigationcompose.typed.DialogResultEffect import com.kiwi.navigationcompose.typed.ResultDestination +import com.kiwi.navigationcompose.typed.setResult sealed interface Destinations : Destination { @Serializable @@ -164,7 +166,7 @@ sealed interface Destinations : Destination { @Composable fun Host(navController: NavController) { - ComposableResultEffect(navController) { result: Destinations.Dialog.Result -> + DialogResultEffect(navController) { result: Destinations.Dialog.Result -> println(result) // process the result } @@ -175,4 +177,16 @@ fun Host(navController: NavController) { Text("Open") } } + +@Composable +fun Dialog(navController: NavController) { + Button( + onClick = { + navController.setResult(Destinations.Dialog.Result(something = 42)) + navController.popBackStack() + } + ) { + Text("Set and close") + } +} ```