appyx
appyx copied to clipboard
Allow dynamically changing the visual representation
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 aboutAlpha
, the other only cares aboutPosition
), but the classes should contain the superset of all the properties of all the representations. - For the actual rearranging, we can use
animateTo
on theMutableUiState
towards the target new values - The
mutableUiStateCache
in theBaseMotionController
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 mapModelState
toTargetUiState
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 initialUiRepresentation
? It might make theInteractionModel
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.