Guia Navigation
Github
  • Overview
  • Setup
  • Using Guia
    • 📔Express Lore
      • Quick Start
    • 📖The Lore
      • Navigation Key
      • Navigation Node
        • Screen
        • Bottom Sheet
        • Dialog
      • Navigator
        • Navigation Operations
        • Navigator Instance
        • Back Handling
      • Navigator Config
        • Dynamic Navigation Node
        • Transitions
      • Containers
      • NavHost
        • Back Handling
      • Multi module navigation
        • NavHost Multi module
      • Deep Linking / Global Navigation
      • Results
      • Lifecycle, ViewModel, Saved State
      • UI Tests
  • 🤖Advanced
    • Custom LifecycleManager
Powered by GitBook
On this page
  1. Using Guia
  2. The Lore
  3. Navigation Node

Dialog

PreviousBottom SheetNextNavigator

Last updated 2 years ago

A Dialog will be rendered inside a Dialog Composable.

class Dialog(
    override val content: @Composable () -> Unit
) : NavigationNode {
    ..
    var dialogOptions by mutableStateOf(DialogOptions())
    ..
}

Similar to , a Dialog has stateful DialogOptions that can be updated at any time.

data class DialogOptions(
    val dismissOnClickOutside: Boolean = true,
    val dismissOnBackPress: Boolean = true,
    val securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
)

Navigating between 2 Dialogs will also animate the changes within the dialog container that hosts them.

Updating Dialog state

Note that DialogOptions currently are not saved/restored so make sure you have a backing saveable state if needed in your Composable.

@Composable
fun MyDialog() {
    val dialog = requireLocalDialog() // Get the local dialog node
    var dismissOnBackPress by rememberSaveable { mutableStateOf(false)) }
    
    LaunchedEffect(dismissOnBackPress) {
        dialog.dialogOptions = dialog.dialogOptions.copy(
            dismissOnBackPress = dismissOnBackPress,
            dismissOnClickOutside = dismissOnBackPress
        )
    }
    
    Button(onClick = { 
        dismissOnBackPress = !dismissOnBackPress
    }) {
        Text(text = "Toggle Back Press!")
    }
}

📖
BottomSheet