Skip to content

Commit

Permalink
fix setContent
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-avdeev-jb committed Dec 8, 2023
1 parent 9bfba2f commit 73621ef
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ internal class ComposeSceneMediator(
}

private var onAttachedToWindow: (() -> Unit)? = null
private fun whenViewShown(action: () -> Unit) {
if (view.window == null) {
onAttachedToWindow = {
onAttachedToWindow = null
action()
}
} else {
action()
}
}

init {
view.onAttachedToWindow = {
Expand All @@ -183,8 +193,7 @@ internal class ComposeSceneMediator(
}

fun setContent(content: @Composable () -> Unit) {
onAttachedToWindow = {
onAttachedToWindow = null
whenViewShown {
scene.setContent {
/**
* TODO isReadyToShowContent it is workaround we need to fix.
Expand Down

0 comments on commit 73621ef

Please sign in to comment.