Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping still is a pain, and losing type info from Screen.withEnvironment is too. #683

Closed
rjrjr opened this issue Feb 23, 2022 · 2 comments

Comments

@rjrjr
Copy link
Contributor

rjrjr commented Feb 23, 2022

From a long discussion w/ @RBusarow

How about this:

sealed interface Screen

@WorkflowUiExperimentalApi
interface Screen_2 : Screen

@WorkflowUiExperimentalApi
class EnvironmentScreen<V : Screen_2> @PublishedApi internal constructor(
  public val screen: V,
  public val viewEnvironment: ViewEnvironment = ViewEnvironment.EMPTY
) : Compatible, Screen {
  /* ... */
}

or this:

sealed interface Screen {
  val environment : ViewEnvironment get() = EMPTY

  interface LeafScreen : Screen

  abstract class <S> ContainerScreen<S, C: ContainerScreen<S, C>>(
    val children: List<S>,
  ): Screen {
    abstract val environment: ViewEnvironment
    abstract fun withEnvironment(e: Environment): C
  }
}

class EnvironmentScreen<S: Screen>(
  val wrapped: S,
  override  val environment: ViewEnvironment
) : ContainerScreen<S, EnvironmentScreen<S>>(listOf(wrapped), environment) {
  override fun withEnvironment(e: Environment): EnvironmentScreen<S> {
    return ...
  }
}

fun <S: Screen> S.withEnvironment(e: ViewEnvironment): EnvironmentScreen<S>
@rjrjr
Copy link
Contributor Author

rjrjr commented Sep 15, 2022

VisualFactory to be introduced with #874 should address this.

@rjrjr
Copy link
Contributor Author

rjrjr commented Dec 19, 2023

@rjrjr rjrjr closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant