Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Created December 20, 2023 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KatieBarnett/f0e17dfa9cbc7ec4edd11760fad6cd6c to your computer and use it in GitHub Desktop.
Save KatieBarnett/f0e17dfa9cbc7ec4edd11760fad6cd6c to your computer and use it in GitHub Desktop.
Navigation dialog destination edge to edge
dialog(
"detail/{index}",
dialogProperties = DialogProperties(
usePlatformDefaultWidth = true,
decorFitsSystemWindows = false
)
) { backStackEntry ->
val activityWindow = window
val dialogWindow = (LocalView.current.parent as? DialogWindowProvider)?.window
val parentView = LocalView.current.parent as View
SideEffect {
if (activityWindow != null && dialogWindow != null) {
val attributes = WindowManager.LayoutParams()
attributes.copyFrom(activityWindow.attributes)
attributes.type = dialogWindow.attributes.type
dialogWindow.attributes = attributes
parentView.layoutParams = LayoutParams(
activityWindow.decorView.width,
activityWindow.decorView.height
)
}
}
backStackEntry.arguments?.getInt("index")?.let {
FactDetail(items[it], Modifier.fillMaxSize())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment