adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.27k stars 109 forks source link

Layout Inspector and Live Edit are not working #393

Open nvkleban opened 1 month ago

nvkleban commented 1 month ago

Layout Inspector and Live Edit are not working properly. After I enable any of them l see an initial screen that I put into navigator constructor ( BlankScreen in my case) not the restored screen stack. But somehow it goes back to normal after I enable "Don't keep activities"

It's easier to test with Layout Inspector.

MainActivity looks like this:

class MainActivity : ComponentActivity() {

    private val viewModel: MainActivityViewModel by viewModels()

    @Inject
    lateinit var compositionLocalsProviders: Set<@JvmSuppressWildcards ProvidedValue<*>>

    override fun onCreate(savedInstanceState: Bundle?) {
        installSplashScreen().setKeepOnScreenCondition { viewModel.uiState.showSplashScreen }
        super.onCreate(savedInstanceState)

        setContent {
            CompositionLocalProvider(*compositionLocalsProviders.toTypedArray()) {
                Navigator(
                    BlankScreen(),
                    disposeBehavior = NavigatorDisposeBehavior(disposeNestedNavigators = false),
                ) { navigator ->
                    MainContentContainer(navigator) {
                        CurrentScreen()
                    }
                }
            }
        }
    }
}
nvkleban commented 1 month ago

And I've checked - by default enabling Layout Inspector does not recreate the activity. So probably it somehow related to the fact that screens stack is also not restored properly.