<@UHAJKUSTU> has covered a pure compose navigation...
# compose
l
@Arkadii Ivanov has covered a pure compose navigation example by using
Decompose
in one of his recent blog posts. I was interested in decompose and had a look into this example but I can't figure out how it's restoring the scroll position of the
LazyColumn
when moving from the details screen back to the list screen. I'm looking for hours but I can't find the responsible piece of code. Can some please have a look and give me a hint? https://github.com/arkivanov/ComposeNavigatorExample
l
Yes but if I break it down, it's only
configuration
which gets stored and restored but
configuration
is just the representation of the screen state. I do the same in my code but this doesn't restore the scroll position. Can you elaborate this please
a
The Children function listen for the navigation state changes and renders the currently active screen. It also saves UI state when screens go to back stack and restores when they active again. You may need to deep dive into implementation details: https://github.com/arkivanov/Decompose/blob/4737f7bf333301c0198b58bcf8b715e0fa5533f7/extensions-compose-jetpack/src/main/java/com/arkivanov/decompose/extensions/compose/jetpack/RouterStateComposable.kt#L19
l
I went through all these methods but I don't get it. Even with debugging...
a
SaveabaleStateHolder
stores saved UI state per key (per configuration).
SaveableStateProvider
sets the corresponding Ambient (now Local) for currently active screen. So sub-components can use
UiSavedStateRegistry
, which actually
LazyColumn
does.
👍 1
l
Yeah this is the magic I was looking for. I wasn't aware of this API and now it works ❤️ Thanks guys! 🙏
👍 1