-
-
Save KatieBarnett/d5130861d1cf63f21fc6fc46e566e5b4 to your computer and use it in GitHub Desktop.
Dialog edge to edge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showDialog?.let { | |
Dialog( | |
onDismissRequest = { showDialog = null }, | |
properties = DialogProperties( | |
usePlatformDefaultWidth = true, | |
decorFitsSystemWindows = false | |
) | |
) { | |
// Step 1: Find the windows | |
val activityWindow = window | |
val dialogWindow = (LocalView.current.parent as? DialogWindowProvider)?.window | |
val parentView = LocalView.current.parent as View | |
SideEffect { | |
if (activityWindow != null && dialogWindow != null) { | |
// Step 2: Get and apply the activity attributes to the dialog parent view | |
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 | |
) | |
} | |
} | |
FactDetail(items[it], Modifier.fillMaxSize()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment