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

Alias renderings are too hard to deal with #973

Closed
rjrjr opened this issue Mar 20, 2023 · 0 comments · Fixed by #975
Closed

Alias renderings are too hard to deal with #973

rjrjr opened this issue Mar 20, 2023 · 0 comments · Fixed by #975
Assignees

Comments

@rjrjr
Copy link
Contributor

rjrjr commented Mar 20, 2023

The recent introduction of the Wrapper interface (#920) made it easier to create things like NamedScreen, where one rendering is used to modify how a wrapped one is displayed; but made it harder to implement "alias" types: custom renderings that are most easily displayed by transforming them into existing types.

This is a problem because we encourgage apps to use BodyAndOverlaysScreen as a building block to craft their own, stricter rules.

e.g., it should be trivial to register a ScreenViewFactory that handles this:

class MyAppRootUI(
  val body: Screen,
  val maybeExactlyOnePopupScreen: MySpecificOverlayType?
  val maybeAnAlertOnTopOfThat: AlertOverlay?
)

by transforming it into this:

BodyAndOverlaysScreen(
  body = myRoot.body,
  overlays = listOfNotNull(
    myRoot.maybeExactlyOnePopupScreen,
    myRoot.maybeAnAlertOnTopOfThat
)

By coupling the ScreenViewFactory.forWrapper to the new Wrapper type, we have actually made that much harder.

So, at least two outcomes needed here:

  • Convenient API for this use case
  • Introduce a sample demonstrating this pattern, both to document it and to make it painfully obvious when we work against it.
rjrjr added a commit that referenced this issue Mar 21, 2023
Coupling `Wrapper` to `ScreenViewFactory.forWrapper` was a mistake,
made simple transformations that weren't in the strict `Wrapper`
shape more difficult.

Fixes #973
rjrjr added a commit that referenced this issue Mar 21, 2023
Coupling `Wrapper` to `ScreenViewFactory.forWrapper` was a mistake,
made simple transformations that weren't in the strict `Wrapper`
shape more difficult.

Also some compulsive tidying of sample code.

Fixes #973
rjrjr added a commit that referenced this issue Mar 21, 2023
Coupling `Wrapper` to `ScreenViewFactory.forWrapper` was a mistake,
made simple transformations that weren't in the strict `Wrapper`
shape more difficult.

Also some compulsive tidying of sample code.

Fixes #973
rjrjr added a commit that referenced this issue Mar 21, 2023
Coupling `Wrapper` to `ScreenViewFactory.forWrapper` was a mistake,
made simple transformations that weren't in the strict `Wrapper`
shape more difficult.

Also some compulsive tidying of sample code.

Fixes #973
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

Successfully merging a pull request may close this issue.

2 participants