Updated on 2026-08-14

This commit is contained in:
Tangem 2025-06-23 11:56:00 +03:00
parent 929317d15c
commit 12e53a3aa3
24 changed files with 205 additions and 95 deletions

View file

@ -1,13 +1,19 @@
plugins {
alias(deps.plugins.kotlin.jvm)
alias(deps.plugins.android.library)
alias(deps.plugins.kotlin.android)
alias(deps.plugins.kotlin.kapt)
id("configuration")
}
android {
namespace = "com.tangem.core.decompose"
}
dependencies {
api(projects.core.utils)
api(deps.decompose)
api(deps.androidx.appCompat)
implementation(deps.kotlin.coroutines)
implementation(deps.hilt.core)

View file

@ -4,6 +4,7 @@ import com.arkivanov.decompose.ComponentContext
import com.tangem.core.decompose.di.HiltComponentBuilderOwner
import com.tangem.core.decompose.navigation.NavigationOwner
import com.tangem.core.decompose.ui.UiMessageSenderOwner
import com.tangem.core.decompose.utils.ActivityHolder
import com.tangem.core.decompose.utils.ComponentScopeOwner
import com.tangem.core.decompose.utils.DispatchersOwner
import com.tangem.core.decompose.utils.TagsOwner
@ -20,4 +21,5 @@ interface AppComponentContext :
DispatchersOwner,
UiMessageSenderOwner,
HiltComponentBuilderOwner,
TagsOwner
TagsOwner,
ActivityHolder

View file

@ -10,6 +10,7 @@ import com.tangem.core.decompose.ui.DefaultUiMessageSender
import com.tangem.core.decompose.ui.UiMessageHandler
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.decompose.ui.UiMessageSenderOwner
import com.tangem.core.decompose.utils.ActivityHolder
import com.tangem.core.decompose.utils.ComponentCoroutineScope
import com.tangem.core.decompose.utils.DispatchersOwner
import kotlinx.coroutines.CoroutineScope
@ -58,7 +59,8 @@ fun AppComponentContext.childByContext(
NavigationOwner by this@childByContext,
UiMessageSenderOwner by this@childByContext,
DispatchersOwner by this@childByContext,
HiltComponentBuilderOwner by this@childByContext {
HiltComponentBuilderOwner by this@childByContext,
ActivityHolder by this@childByContext {
override val tags: HashMap<String, Any> = HashMap()

View file

@ -1,5 +1,6 @@
package com.tangem.core.decompose.context
import androidx.appcompat.app.AppCompatActivity
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.essenty.instancekeeper.getOrCreate
import com.tangem.core.decompose.di.ModelComponent
@ -17,6 +18,7 @@ class DefaultAppComponentContext(
override val dispatchers: CoroutineDispatcherProvider,
override val hiltComponentBuilder: ModelComponent.Builder,
override val messageSender: UiMessageSender,
override val activity: AppCompatActivity,
private val replaceRouter: Router? = null,
) : AppComponentContext, ComponentContext by componentContext {

View file

@ -0,0 +1,16 @@
package com.tangem.core.decompose.utils
import androidx.appcompat.app.AppCompatActivity
/**
* Interface for holding an [AppCompatActivity] instance.
*
* This interface is used to provide access to the activity in which the component is running.
*/
interface ActivityHolder {
/**
* The [AppCompatActivity] instance associated with this context.
*/
val activity: AppCompatActivity
}