Updated on 2026-08-14
This commit is contained in:
parent
d9d3ba2cda
commit
3a6668eee0
10 changed files with 97 additions and 28 deletions
|
|
@ -16,7 +16,4 @@ dependencies {
|
|||
/* Project - Core */
|
||||
implementation(projects.core.decompose)
|
||||
implementation(projects.core.ui)
|
||||
|
||||
/* AndroidX */
|
||||
implementation(deps.androidx.fragment.ktx)
|
||||
}
|
||||
|
|
@ -1,18 +1,14 @@
|
|||
package com.tangem.features.details.component
|
||||
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.factory.ComponentFactory
|
||||
import com.tangem.core.ui.ComposableContentComponent
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
||||
interface DetailsComponent : ComposableContentComponent {
|
||||
|
||||
interface Factory : ComponentFactory<DetailsComponent, Params> {
|
||||
|
||||
override fun create(context: AppComponentContext, params: Params): DetailsComponent
|
||||
}
|
||||
interface Factory : ComponentFactory<Params, DetailsComponent>
|
||||
|
||||
data class Params(
|
||||
val selectedUserWalletId: UserWalletId,
|
||||
val userWalletId: UserWalletId,
|
||||
)
|
||||
}
|
||||
|
|
@ -17,20 +17,16 @@ import dagger.assisted.AssistedInject
|
|||
|
||||
internal class DefaultDetailsComponent @AssistedInject constructor(
|
||||
@Assisted context: AppComponentContext,
|
||||
@Assisted private val params: DetailsComponent.Params,
|
||||
@Assisted params: DetailsComponent.Params,
|
||||
userWalletListComponentFactory: UserWalletListComponent.Factory,
|
||||
) : DetailsComponent, AppComponentContext by context {
|
||||
|
||||
private val model: DetailsModel = getOrCreateModel()
|
||||
private val model: DetailsModel = getOrCreateModel(params)
|
||||
|
||||
private val userWalletListComponent = userWalletListComponentFactory.create(
|
||||
context = child(key = "user_wallet_list"),
|
||||
)
|
||||
|
||||
init {
|
||||
model.provideUserWalletId(params.selectedUserWalletId)
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
val state by model.state.collectAsStateWithLifecycle()
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package com.tangem.features.details.model
|
|||
import arrow.core.getOrElse
|
||||
import com.tangem.core.decompose.di.ComponentScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.domain.walletconnect.CheckIsWalletConnectAvailableUseCase
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.features.details.component.DetailsComponent
|
||||
import com.tangem.features.details.entity.DetailsFooterUM
|
||||
import com.tangem.features.details.entity.DetailsItemUM
|
||||
import com.tangem.features.details.entity.DetailsUM
|
||||
|
|
@ -24,15 +25,19 @@ import timber.log.Timber
|
|||
import javax.inject.Inject
|
||||
|
||||
@ComponentScoped
|
||||
@Suppress("LongParameterList")
|
||||
internal class DetailsModel @Inject constructor(
|
||||
private val socialsBuilder: SocialsBuilder,
|
||||
private val itemsBuilder: ItemsBuilder,
|
||||
private val appVersionProvider: AppVersionProvider,
|
||||
private val checkIsWalletConnectAvailableUseCase: CheckIsWalletConnectAvailableUseCase,
|
||||
private val router: Router,
|
||||
private val paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
) : Model() {
|
||||
|
||||
private val params: DetailsComponent.Params = paramsContainer.require()
|
||||
|
||||
private val items: MutableStateFlow<ImmutableList<DetailsItemUM>> = MutableStateFlow(value = persistentListOf())
|
||||
|
||||
val state: MutableStateFlow<DetailsUM> = MutableStateFlow(
|
||||
|
|
@ -50,10 +55,12 @@ internal class DetailsModel @Inject constructor(
|
|||
items
|
||||
.onEach(::updateState)
|
||||
.launchIn(modelScope)
|
||||
|
||||
checkWalletConnectAvailability()
|
||||
}
|
||||
|
||||
fun provideUserWalletId(userWalletId: UserWalletId) = modelScope.launch {
|
||||
val isWalletConnectAvailable = checkIsWalletConnectAvailableUseCase(userWalletId).getOrElse {
|
||||
private fun checkWalletConnectAvailability() = modelScope.launch {
|
||||
val isWalletConnectAvailable = checkIsWalletConnectAvailableUseCase(params.userWalletId).getOrElse {
|
||||
Timber.w("Unable to check WalletConnect availability: $it")
|
||||
|
||||
false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue