-
Notifications
You must be signed in to change notification settings - Fork 6
Prototype DecorationLayout #28
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| class Decoration( | ||
| internal val modifier: Modifier = Modifier, | ||
| private val onDraw: DrawScope.(container: DecoratedElementContainer) -> Unit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High level design comment - it'd be really nice if decorations could themselves be arbitrary @Composables, rather than just something that can be drawn into a canvas.
This puts some constraints on what Decorations can do and the ordering of placement, and specifically the amount of information available for a decoration without needing to reach for subcomposition (or maybe the performance subcomposition is fine ™️ in the context of creating presentations)
Without subcomposition, the sizing of the overlayed content wouldn't be available in composition for the overlaying decoration, but it should be available in both measurement and layout.
With subcomposition, the sizing the overlayed content could be available for the overlaying decoration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like that too! I experimented a while ago with a Connected layout and my original HorizontalTree which sort of (maybe?) do something like that.
Unfortunately, I ran into a bunch of problems when trying to combine it with SharedTransitionLayout and animate the movement of the items. Maybe it's how I had it set up, but I couldn't get the lines to animate correctly without using onPlaced. It will probably take someone far more familiar with creating custom layouts then I to implement something that works.
If you have ideas, though, I'd happily take a PR. 😃 I'm using the new example storyboard as the proving grounds. Both for API friendliness and animation behavior.
| import androidx.compose.ui.platform.InspectorInfo | ||
|
|
||
| class Decoration( | ||
| internal val modifier: Modifier = Modifier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Modifier part I'm not sure about:
- This is meant to handle shared decorations inside a SharedTransitionLayout.
- Could also be useful to impact visibility within an AnimatedVisibility context or other useful modifiers.
- Maybe exposes too many details for the Canvas, and it would be better to have a single Canvas? Many modifiers would be useless.
- Could also help get layering correct, though, if you want a decoration to be behind some other element.
One thought was to make Decoration a Composable itself within the DecorationScope, but I'm not sure how I would push that up to the same level as the DecorationLayout so it is sized within the box correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, didn't realize I only staged this comment... 😄
|
|
||
| class Decoration( | ||
| internal val modifier: Modifier = Modifier, | ||
| private val onDraw: DrawScope.(container: DecoratedElementContainer) -> Unit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like that too! I experimented a while ago with a Connected layout and my original HorizontalTree which sort of (maybe?) do something like that.
Unfortunately, I ran into a bunch of problems when trying to combine it with SharedTransitionLayout and animate the movement of the items. Maybe it's how I had it set up, but I couldn't get the lines to animate correctly without using onPlaced. It will probably take someone far more familiar with creating custom layouts then I to implement something that works.
If you have ideas, though, I'd happily take a PR. 😃 I'm using the new example storyboard as the proving grounds. Both for API friendliness and animation behavior.
No description provided.