Skip to content

Conversation

@bnorm
Copy link
Owner

@bnorm bnorm commented Jun 29, 2025

No description provided.


class Decoration(
internal val modifier: Modifier = Modifier,
private val onDraw: DrawScope.(container: DecoratedElementContainer) -> Unit,

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.

Copy link
Owner Author

@bnorm bnorm Jul 1, 2025

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,
Copy link
Owner Author

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.

Copy link
Owner Author

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,
Copy link
Owner Author

@bnorm bnorm Jul 1, 2025

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.

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 this pull request may close these issues.

3 participants