Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
I realize that this code would need to change slightly to take the SaveableStateHolder
as input, but the idea remains the same.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit a8c1f68f0bdbfce87cda1331a07af6ac0fb1594e
Author: Jossi Wolf <10628007+jossiwolf@users.noreply.github.com>
Date: Thu May 06 23:13:31 2021
[GH] [Navigation] Introduce NavBackStackEntry#provideToCompositionLocals
…that provides the NavBackStackEntry to the composition locals needed for all Compose-related navigators.
Relnote: Introduced a new NavBackStackEntry#provideToCompositionLocals that provides the NavBackStackEntry to the relevant composition locals.
## Testing
Test: NavBackStackEntryProviderTest
`NavBackStackEntryProviderTest#testSaveableValueInContentIsSaved` is pretty much just copied from [RememberSaveableTest](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/runtime/runtime-saveable/src/androidAndroidTest/kotlin/androidx/compose/runtime/saveable/RememberSaveableTest.kt ) and as always, I'll be very happy about suggestions on improving the tests and additional tests!
## Issues Fixed
Fixes: b/187229439
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/175 .
Resolves #175
Github-Pr-Head-Sha: a8100a09daa0e688fd278e43f1dd27dd22d718ac
GitOrigin-RevId: 7441a30ed46421dfd25c29fec168f766d674f88e
Change-Id: I25a46dfefc52adc1411536359a285bfbc4fb2e38
M navigation/navigation-compose/api/current.txt
M navigation/navigation-compose/api/public_plus_experimental_current.txt
M navigation/navigation-compose/api/restricted_current.txt
A navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavBackStackEntryProviderTest.kt
A navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavBackStackEntryProvider.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
https://android-review.googlesource.com/1698805
Branch: androidx-main
commit a8c1f68f0bdbfce87cda1331a07af6ac0fb1594e
Author: Jossi Wolf <10628007+jossiwolf@users.noreply.github.com>
Date: Thu May 06 23:13:31 2021
[GH] [Navigation] Introduce NavBackStackEntry#provideToCompositionLocals
…that provides the NavBackStackEntry to the composition locals needed for all Compose-related navigators.
Relnote: Introduced a new NavBackStackEntry#provideToCompositionLocals that provides the NavBackStackEntry to the relevant composition locals.
## Testing
Test: NavBackStackEntryProviderTest
`NavBackStackEntryProviderTest#testSaveableValueInContentIsSaved` is pretty much just copied from [RememberSaveableTest](
## Issues Fixed
Fixes:
This is an imported pull request from
Resolves #175
Github-Pr-Head-Sha: a8100a09daa0e688fd278e43f1dd27dd22d718ac
GitOrigin-RevId: 7441a30ed46421dfd25c29fec168f766d674f88e
Change-Id: I25a46dfefc52adc1411536359a285bfbc4fb2e38
M navigation/navigation-compose/api/current.txt
M navigation/navigation-compose/api/public_plus_experimental_current.txt
M navigation/navigation-compose/api/restricted_current.txt
A navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavBackStackEntryProviderTest.kt
A navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavBackStackEntryProvider.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
Description
Component used: Navigation Compose
Navigation Compose's
NavHost
(and any other Compose related Navigator), must all use the same pattern of:It would be nice if we could extract that out into a reusable container, so that any Navigator could write:
Where a
fun NavBackStackEntry.compositionLocalProvider(content: @Composable () -> Unit)
would encapsulate all of the details for you.I'm not particularly tied to the name / use of an extension, but I like the reuse of
CompositionLocalProvider
in a way that doesn't add an overload in a different package to the global namespace.