Skip to content
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

Fix sharing composition locals with new platform layers #1086

Merged
merged 5 commits into from Feb 12, 2024

Conversation

MatkovIvan
Copy link
Member

@MatkovIvan MatkovIvan commented Feb 8, 2024

Proposed Changes

  • Pass CompositionLocalContext to all layers
  • Adds a new property to a class that is marked as internal (via annotation).

Testing

Test: unit tests currently runs without platform layers, so existing tests didn't find this issue (TODO). Added a separate page to mpp demo for manual testing for now.

Issues Fixed

Fixes JetBrains/compose-multiplatform#4281

@@ -159,6 +171,7 @@ internal fun rememberComposeSceneLayer(
val density = LocalDensity.current
val layoutDirection = LocalLayoutDirection.current
val parentComposition = rememberCompositionContext()
val compositionLocalContext by rememberUpdatedState(currentCompositionLocalContext)
Copy link
Member Author

@MatkovIvan MatkovIvan Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already contained inside parentComposition that we already passing, but it's internal to runtime, so we cannot receive it from there.
At the same time, we must create a new composition for layers since it has different scope/invalidations/etc

So for now we have to pass it separately 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants