API Reference Item

DialogSceneStrategy.Companion.DialogKey

The key for NavEntry.metadata or Scene.metadata to indicate that an entry should be displayed within a Dialog.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

DialogSample

@Composable
fun DialogSample() {
    val backStack = rememberNavBackStack(OverlaidNavKey)
    NavDisplay(
        backStack,
        onBack = { backStack.removeLastOrNull() },
        sceneStrategies = listOf(DialogSceneStrategy()),
        entryProvider =
            entryProvider {
                entry<OverlaidNavKey> {
                    Box(
                        Modifier.fillMaxSize()
                            .background(Color(0.2f, 0.2f, 1.0f, 1.0f))
                            .border(10.dp, Color.Blue),
                        contentAlignment = Alignment.Center,
                    ) {
                        Column(horizontalAlignment = Alignment.CenterHorizontally) {
                            BasicText(
                                "Overlaid Entry",
                                Modifier.size(50.dp),
                                style = TextStyle(textAlign = TextAlign.Center),
                            )
                            Button(onClick = { backStack.add(DialogNavKey) }) {
                                Text("Open Dialog")
                            }
                        }
                    }
                }
                entry<DialogNavKey>(metadata = metadata { put(DialogKey, DialogProperties()) }) {
                    RedBox("Dialog")
                }
            },
    )
}