Tlaster / PreCompose

Compose Multiplatform Navigation && State Management

Home Page:https://tlaster.github.io/PreCompose/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple back stacks NavigationBar

mahramane opened this issue · comments

Hi
Please give me an example for NavigationBar with 4 tabs.
I want to create a multiple back stacks Navigation Bar and save current page and tabs page data when switch between those.
also when switch between tabs onResume event called. 👇

@Composable
fun OnResume(onResume: () -> Unit) {
    OnLifecycleEvent { event ->
        if (event == Lifecycle.State.Active) onResume()
    }
}

@Composable
fun OnLifecycleEvent(onEvent: (event: Lifecycle.State) -> Unit) {
    val eventHandler = rememberUpdatedState(onEvent)
    val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current)

    DisposableEffect(lifecycleOwner.value) {
        val lifecycle = lifecycleOwner.value.lifecycle

        val observer = object : LifecycleObserver {

            override fun onStateChanged(state: Lifecycle.State) {
                eventHandler.value(state)
            }
        }
        lifecycle.addObserver(observer)
        onDispose {
            lifecycle.removeObserver(observer)
        }
    }
}

Thank you.

Sorry I'm busying doing my own job and bug fixes for PreCompose and any other things, you can try to do this yourself or asking ChatGPT :)

Ok sorry 😢 good luck.
is PreCompose support Multiple back stacks?

 navController.navigate(screen.route) {
                            // Pop up to the start destination of the graph to
                            // avoid building up a large stack of destinations
                            // on the back stack as users select items
                            popUpTo(navController.graph.findStartDestination().id) {
                                saveState = true
                            }
                            // Avoid multiple copies of the same destination when
                            // reselecting the same item
                            launchSingleTop = true
                            // Restore state when reselecting a previously selected item
                            restoreState = true
                        }

PreCompose does support Nestesd NavHost with different Navigator.

PreCompose does support Nestesd NavHost with different Navigator.

Oh God

When do you anticipate adding it to the library?

PreCompose already support Nestesd NavHost with different Navigator.