appyx icon indicating copy to clipboard operation
appyx copied to clipboard

Allow dynamically changing the visual representation

Open zsoltk opened this issue 1 year ago • 0 comments

It would be great if we could replace the visual representation of the model runtime, and the ui elements would rearrange.

Idea:

  • The different visual representations need to work with the same exact TargetUiState / MutableUiState types. They might only leverage a subset of the properties in these classes (e.g. one only cares about Alpha, the other only cares about Position), but the classes should contain the superset of all the properties of all the representations.
  • For the actual rearranging, we can use animateTo on the MutableUiState towards the target new values
  • The mutableUiStateCache in the BaseMotionController should be shared across the different representations, otherwise the screen would blink to the new representation instead of rearranging
  • Because of this, probably you need to keep the MotionController instance (so that it keeps its cache), but extract the part where we map ModelState to TargetUiState into a class (UiRepresentation?), and allow replacing that mapper instead.
  • After extracting that part, maybe nothing else remains in the actual MotionController, so we can create it as a base class instance automatically using the initial UiRepresentation? It might make the InteractionModel constructor easier to understand with that naming.

For a proof of concept, you could take Spotlight + its Slider and Fader as different representations to switch between.

zsoltk avatar Apr 12 '23 16:04 zsoltk