Skip to content

Instantly share code, notes, and snippets.

@k0siara
Last active March 29, 2023 13:44
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 k0siara/bb527d5a29f530d707a29cd1203b68b0 to your computer and use it in GitHub Desktop.
Save k0siara/bb527d5a29f530d707a29cd1203b68b0 to your computer and use it in GitHub Desktop.
fun DialogFragment.dialogFragmentComposeView(
content: @Composable () -> Unit
): ComposeView {
return ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
// Another interesting flaw. If you use other strategies in DialogFragment you may get crashes 🫠
setViewCompositionStrategy(strategy = ViewCompositionStrategy.DisposeOnDetachedFromWindow)
setContent {
CustomComposeTheme(
darkTheme = false
) {
content()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment