Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-05 13:46:52 +03:00
parent 636c602fcb
commit cde97de92e
3 changed files with 15 additions and 5 deletions

View file

@ -38,6 +38,6 @@ internal interface RoutingComponent : ComposableContentComponent {
}
interface Factory {
fun create(context: AppComponentContext): RoutingComponent
fun create(context: AppComponentContext, initialStack: List<AppRoute>?): RoutingComponent
}
}

View file

@ -34,6 +34,7 @@ import dagger.assisted.AssistedInject
@Suppress("LongParameterList")
internal class DefaultRoutingComponent @AssistedInject constructor(
@Assisted context: AppComponentContext,
@Assisted val initialStack: List<AppRoute>?,
private val childFactory: ChildFactory,
private val appRouterConfig: AppRouterConfig,
private val uiDependencies: UiDependencies,
@ -46,8 +47,8 @@ internal class DefaultRoutingComponent @AssistedInject constructor(
override val stack: Value<ChildStack<AppRoute, Child>> = childStack(
source = navigationProvider.getOrCreateTyped(),
serializer = AppRoute.serializer(),
initialConfiguration = getInitialRoute(),
initialStack = { getInitialStackOrInit() },
serializer = null, // AppRoute.serializer(), // Disabled until Nav refactoring completes
handleBackButton = false,
childFactory = ::child,
)
@ -115,7 +116,11 @@ internal class DefaultRoutingComponent @AssistedInject constructor(
}
// TODO: Find correct initial route here: [REDACTED_JIRA]
private fun getInitialRoute(): AppRoute = AppRoute.Initial
private fun getInitialStackOrInit(): List<AppRoute> = if (initialStack.isNullOrEmpty()) {
listOf(AppRoute.Initial)
} else {
initialStack
}
private fun child(route: AppRoute, context: ComponentContext): Child {
return childFactory.createChild(route) { childByContext(context) }
@ -123,6 +128,6 @@ internal class DefaultRoutingComponent @AssistedInject constructor(
@AssistedFactory
interface Factory : RoutingComponent.Factory {
override fun create(context: AppComponentContext): DefaultRoutingComponent
override fun create(context: AppComponentContext, initialStack: List<AppRoute>?): DefaultRoutingComponent
}
}