workflow-kotlin icon indicating copy to clipboard operation
workflow-kotlin copied to clipboard

BackStackScreen causes ComposeRenderings to disappear when transition animations kick-in

Open lucamtudor opened this issue 3 years ago • 1 comments
trafficstars

I've changed ":samples:compose-samples" & ":samples:tutorial" to play with BackStackScreen, ComposeRendering & LayoutRunners. The code producing this bug isn't really noteworthy. The whole Activity is driven with a WorkflowLayout and the render method looks like:

  override fun render(
    renderProps: Unit,
    renderState: State,
    context: RenderContext
  ): Any {
    val backstack: List<Any> = List(renderState.children) { index ->
      when (index % 3) {
        0 -> {
          LegacyRendering(
            id = "$index Compose-GoForwardRendering",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = GoForwardComposeRendering(
              step = index,
              content = context.renderChild(TextInputWorkflow, key = "text-input-$index"),
              onNextClicked = { context.actionSink.send(goForward()) },
            ),
          )
        }

        1 -> {
          val welcomeScreen = context.renderChild(WelcomeWorkflow, key = "welcome-$index") {
            WorkflowAction.noAction()
          }
          LegacyRendering(
            id = "$index Legacy-Welcome Screen",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = welcomeScreen,
          )
        }

        else -> {
          val hello = context.renderChild(HelloWorkflow)
          LegacyRendering(
            id = "$index Compose-GoBackRendering",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = GoBackComposeRendering(
              step = index,
              content = hello,
              onGoBack = { context.actionSink.send(goBack()) },
            )
          )
        }
      }
    }

    return backstack.toBackStackScreen()
  }

Here's a short video showcasing the problem:

https://user-images.githubusercontent.com/3036785/154375879-ac8b07da-2e1d-4b3e-8150-cef1dafcdf46.mp4

lucamtudor avatar Feb 16 '22 23:02 lucamtudor

I believe this was fixed by the introduction of ScreenComposableFactory and the new compose binding for NamedScreen. Leaving the ticket open as a reminder to verify that.

rjrjr avatar Jun 24 '24 17:06 rjrjr