Updated on 2026-08-14
This commit is contained in:
parent
a46867e2e9
commit
ce86d3f87c
3 changed files with 52 additions and 11 deletions
|
|
@ -21,8 +21,10 @@ internal class PreviewDetailsComponent : DetailsComponent {
|
||||||
router = DummyRouter(),
|
router = DummyRouter(),
|
||||||
).buildAll(
|
).buildAll(
|
||||||
isWalletConnectAvailable = true,
|
isWalletConnectAvailable = true,
|
||||||
|
isSupportChatAvailable = true,
|
||||||
userWalletId = UserWalletId(""),
|
userWalletId = UserWalletId(""),
|
||||||
onSupportClick = {},
|
onSupportEmailClick = {},
|
||||||
|
onSupportChatClick = {},
|
||||||
onBuyClick = {},
|
onBuyClick = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.features.details.model
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import arrow.core.getOrElse
|
import arrow.core.getOrElse
|
||||||
|
import com.tangem.common.routing.AppRoute
|
||||||
import com.tangem.core.analytics.AppInstanceIdProvider
|
import com.tangem.core.analytics.AppInstanceIdProvider
|
||||||
import com.tangem.core.decompose.di.ModelScoped
|
import com.tangem.core.decompose.di.ModelScoped
|
||||||
import com.tangem.core.decompose.model.Model
|
import com.tangem.core.decompose.model.Model
|
||||||
|
|
@ -14,6 +15,7 @@ import com.tangem.domain.feedback.GetCardInfoUseCase
|
||||||
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
||||||
import com.tangem.domain.feedback.models.CardInfo
|
import com.tangem.domain.feedback.models.CardInfo
|
||||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||||
|
import com.tangem.domain.feedback.repository.FeedbackFeatureToggles
|
||||||
import com.tangem.domain.redux.LegacyAction
|
import com.tangem.domain.redux.LegacyAction
|
||||||
import com.tangem.domain.redux.ReduxStateHolder
|
import com.tangem.domain.redux.ReduxStateHolder
|
||||||
import com.tangem.domain.walletconnect.CheckIsWalletConnectAvailableUseCase
|
import com.tangem.domain.walletconnect.CheckIsWalletConnectAvailableUseCase
|
||||||
|
|
@ -57,6 +59,7 @@ internal class DetailsModel @Inject constructor(
|
||||||
private val getCardInfoUseCase: GetCardInfoUseCase,
|
private val getCardInfoUseCase: GetCardInfoUseCase,
|
||||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||||
private val getWalletsUseCase: GetWalletsUseCase,
|
private val getWalletsUseCase: GetWalletsUseCase,
|
||||||
|
private val feedbackFeatureToggles: FeedbackFeatureToggles,
|
||||||
override val dispatchers: CoroutineDispatcherProvider,
|
override val dispatchers: CoroutineDispatcherProvider,
|
||||||
) : Model() {
|
) : Model() {
|
||||||
|
|
||||||
|
|
@ -82,8 +85,10 @@ internal class DetailsModel @Inject constructor(
|
||||||
items = MutableStateFlow(
|
items = MutableStateFlow(
|
||||||
itemsBuilder.buildAll(
|
itemsBuilder.buildAll(
|
||||||
isWalletConnectAvailable = isWalletConnectAvailable,
|
isWalletConnectAvailable = isWalletConnectAvailable,
|
||||||
|
isSupportChatAvailable = feedbackFeatureToggles.isUsedeskEnabled,
|
||||||
userWalletId = params.userWalletId,
|
userWalletId = params.userWalletId,
|
||||||
onSupportClick = ::sendFeedback,
|
onSupportEmailClick = ::sendFeedback,
|
||||||
|
onSupportChatClick = ::openUseDesk,
|
||||||
onBuyClick = ::onBuyClick,
|
onBuyClick = ::onBuyClick,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -134,6 +139,16 @@ internal class DetailsModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openUseDesk() {
|
||||||
|
val scanResponse =
|
||||||
|
getSelectedWalletSyncUseCase().getOrNull()?.requireColdWallet()?.scanResponse // TODO [REDACTED_TASK_KEY]
|
||||||
|
?: error("Selected wallet is null")
|
||||||
|
|
||||||
|
val cardInfo = getCardInfoUseCase(scanResponse).getOrNull() ?: return
|
||||||
|
|
||||||
|
router.push(AppRoute.Usedesk(cardInfo))
|
||||||
|
}
|
||||||
|
|
||||||
private fun showFeedbackEmailTypeOptionBS(selectedCardInfo: CardInfo) {
|
private fun showFeedbackEmailTypeOptionBS(selectedCardInfo: CardInfo) {
|
||||||
state.update {
|
state.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
|
|
|
||||||
|
|
@ -13,22 +13,30 @@ import com.tangem.features.details.impl.R
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ModelScoped
|
@ModelScoped
|
||||||
internal class ItemsBuilder @Inject constructor(private val router: Router) {
|
internal class ItemsBuilder @Inject constructor(private val router: Router) {
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
fun buildAll(
|
fun buildAll(
|
||||||
isWalletConnectAvailable: Boolean,
|
isWalletConnectAvailable: Boolean,
|
||||||
|
isSupportChatAvailable: Boolean,
|
||||||
userWalletId: UserWalletId,
|
userWalletId: UserWalletId,
|
||||||
onSupportClick: () -> Unit,
|
onSupportEmailClick: () -> Unit,
|
||||||
|
onSupportChatClick: () -> Unit,
|
||||||
onBuyClick: () -> Unit,
|
onBuyClick: () -> Unit,
|
||||||
): ImmutableList<DetailsItemUM> = buildList {
|
): ImmutableList<DetailsItemUM> = buildList {
|
||||||
buildWalletConnectBlock(isWalletConnectAvailable, userWalletId)?.let(::add)
|
buildWalletConnectBlock(isWalletConnectAvailable, userWalletId)?.let(::add)
|
||||||
buildUserWalletListBlock().let(::add)
|
buildUserWalletListBlock().let(::add)
|
||||||
buildShopBlock(onBuyClick).let(::add)
|
buildShopBlock(onBuyClick).let(::add)
|
||||||
buildSettingsBlock().let(::add)
|
buildSettingsBlock().let(::add)
|
||||||
buildSupportBlock(onSupportClick).let(::add)
|
buildSupportBlock(
|
||||||
|
onSupportEmailClick = onSupportEmailClick,
|
||||||
|
onSupportChatClick = onSupportChatClick,
|
||||||
|
isSupportChatAvailable = isSupportChatAvailable,
|
||||||
|
).let(::add)
|
||||||
}.toImmutableList()
|
}.toImmutableList()
|
||||||
|
|
||||||
private fun buildWalletConnectBlock(isWalletConnectAvailable: Boolean, userWalletId: UserWalletId): DetailsItemUM? {
|
private fun buildWalletConnectBlock(isWalletConnectAvailable: Boolean, userWalletId: UserWalletId): DetailsItemUM? {
|
||||||
|
|
@ -82,17 +90,33 @@ internal class ItemsBuilder @Inject constructor(private val router: Router) {
|
||||||
}.toImmutableList(),
|
}.toImmutableList(),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun buildSupportBlock(onClick: () -> Unit): DetailsItemUM = DetailsItemUM.Basic(
|
private fun buildSupportBlock(
|
||||||
|
onSupportEmailClick: () -> Unit,
|
||||||
|
onSupportChatClick: () -> Unit,
|
||||||
|
isSupportChatAvailable: Boolean,
|
||||||
|
): DetailsItemUM = DetailsItemUM.Basic(
|
||||||
id = "support",
|
id = "support",
|
||||||
items = persistentListOf(
|
items = buildList {
|
||||||
DetailsItemUM.Basic.Item(
|
DetailsItemUM.Basic.Item(
|
||||||
id = "send_feedback",
|
id = "support_email",
|
||||||
block = BlockUM(
|
block = BlockUM(
|
||||||
text = resourceReference(R.string.details_row_title_contact_to_support),
|
text = resourceReference(R.string.details_row_title_contact_to_support),
|
||||||
iconRes = R.drawable.ic_comment_24,
|
iconRes = R.drawable.ic_comment_24,
|
||||||
onClick = onClick,
|
onClick = onSupportEmailClick,
|
||||||
),
|
),
|
||||||
),
|
).let(::add)
|
||||||
|
|
||||||
|
if (isSupportChatAvailable) {
|
||||||
|
DetailsItemUM.Basic.Item(
|
||||||
|
id = "support_chat",
|
||||||
|
block = BlockUM(
|
||||||
|
text = resourceReference(R.string.details_row_title_contact_to_support_chat),
|
||||||
|
iconRes = R.drawable.ic_chat_24,
|
||||||
|
onClick = onSupportChatClick,
|
||||||
|
),
|
||||||
|
).let(::add)
|
||||||
|
}
|
||||||
|
|
||||||
DetailsItemUM.Basic.Item(
|
DetailsItemUM.Basic.Item(
|
||||||
id = "disclaimer",
|
id = "disclaimer",
|
||||||
block = BlockUM(
|
block = BlockUM(
|
||||||
|
|
@ -100,7 +124,7 @@ internal class ItemsBuilder @Inject constructor(private val router: Router) {
|
||||||
iconRes = R.drawable.ic_text_24,
|
iconRes = R.drawable.ic_text_24,
|
||||||
onClick = { router.push(AppRoute.Disclaimer(isTosAccepted = true)) },
|
onClick = { router.push(AppRoute.Disclaimer(isTosAccepted = true)) },
|
||||||
),
|
),
|
||||||
),
|
).let(::add)
|
||||||
),
|
}.toPersistentList(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue