Updated on 2026-08-14

This commit is contained in:
Tangem 2024-06-23 23:36:32 +04:00
parent 3595fdbf9a
commit 36871cc5c9
17 changed files with 152 additions and 10 deletions

View file

@ -5,6 +5,7 @@ import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.router.stack.childStack
import com.arkivanov.decompose.value.Value
import com.arkivanov.essenty.backhandler.BackCallback
import com.arkivanov.essenty.lifecycle.doOnDestroy
import com.tangem.common.routing.AppRoute
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.context.childByContext
@ -34,6 +35,10 @@ internal class DefaultRoutingComponent @AssistedInject constructor(
init {
backHandler.register(backCallback)
lifecycle.doOnDestroy {
childFactory.doOnDestroy()
}
}
private fun getInitialRoute(): AppRoute = AppRoute.Initial

View file

@ -163,6 +163,10 @@ internal class ChildFactory @Inject constructor(
}
}
fun doOnDestroy() {
componentContexts.clear()
}
private fun contextProvider(
appRoute: AppRoute,
contextFactory: (route: AppRoute) -> AppComponentContext,

View file

@ -5,7 +5,7 @@ import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.bundle.RouteBundleParams
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.factory.ComponentFactory
import com.tangem.core.ui.ComposableContentComponent
import com.tangem.core.ui.decompose.ComposableContentComponent
import com.tangem.tap.DecomposeFragment
import com.tangem.tap.routing.RoutingComponent.Child
import com.tangem.utils.Provider
@ -29,6 +29,7 @@ internal fun <C : ComposableContentComponent, P : Any, F : ComponentFactory<P, C
): Child {
val fragmentProvider = Provider {
DecomposeFragment.newInstance(
tag = path,
contextProvider = contextProvider,
params = params,
componentFactory = componentFactory,