Skip to content

Alias renderings are too hard to deal with  #973

@rjrjr

Description

@rjrjr

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions