Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-30 11:59:23 +04:00
parent 418fbf710d
commit 8c47e9483c
20 changed files with 53 additions and 36 deletions

View file

@ -2,9 +2,8 @@ package com.tangem.features.tangempay.components
import com.tangem.core.decompose.factory.ComponentFactory
import com.tangem.core.ui.decompose.ComposableContentComponent
import com.tangem.domain.models.wallet.UserWalletId
interface TangemPayDetailsComponent : ComposableContentComponent {
data class Params(val userWalletId: UserWalletId)
data class Params(val customerWalletAddress: String)
interface Factory : ComponentFactory<Params, TangemPayDetailsComponent>
}

View file

@ -23,7 +23,7 @@ internal class DefaultTangemPayDetailsComponent @AssistedInject constructor(
private val model: TangemPayDetailsModel = getOrCreateModel(params = params)
private val txHistoryComponent = DefaultTangemPayTxHistoryComponent(
appComponentContext = child("txHistoryComponent"),
params = DefaultTangemPayTxHistoryComponent.Params(userWalletId = params.userWalletId),
params = DefaultTangemPayTxHistoryComponent.Params(customerWalletAddress = params.customerWalletAddress),
)
@Composable

View file

@ -4,7 +4,6 @@ import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.model.getOrCreateModel
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.features.tangempay.model.TangemPayTxHistoryModel
import com.tangem.features.txhistory.entity.TxHistoryUM
import com.tangem.features.txhistory.ui.txHistoryItems
@ -22,5 +21,5 @@ internal class DefaultTangemPayTxHistoryComponent(
txHistoryItems(listState, state)
}
data class Params(val userWalletId: UserWalletId)
data class Params(val customerWalletAddress: String)
}

View file

@ -31,7 +31,7 @@ internal class TangemPayTxHistoryModel @Inject constructor(
private val listManager = TangemPayTxHistoryListManager(
repository = tangemPayTxHistoryRepository,
dispatchers = dispatchers,
userWalletId = params.userWalletId,
customerWalletAddress = params.customerWalletAddress,
txHistoryUiActions = this,
)
@ -86,7 +86,7 @@ internal class TangemPayTxHistoryModel @Inject constructor(
}
private fun loadMoreItems(): Boolean {
modelScope.launch { listManager.loadMore(params.userWalletId) }
modelScope.launch { listManager.loadMore(params.customerWalletAddress) }
return true
}

View file

@ -1,6 +1,5 @@
package com.tangem.features.tangempay.utils
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.tangempay.model.TangemPayTxHistoryListBatchingContext
import com.tangem.domain.tangempay.model.TangemPayTxHistoryListConfig
import com.tangem.domain.tangempay.repository.TangemPayTxHistoryRepository
@ -23,7 +22,7 @@ private typealias TangemPayTxHistoryBatchAction = BatchAction<Int, TangemPayTxHi
internal class TangemPayTxHistoryListManager(
private val repository: TangemPayTxHistoryRepository,
private val dispatchers: CoroutineDispatcherProvider,
private val userWalletId: UserWalletId,
private val customerWalletAddress: String,
private val txHistoryUiActions: TxHistoryUiActions,
) {
private val jobHolder = JobHolder()
@ -56,15 +55,18 @@ internal class TangemPayTxHistoryListManager(
suspend fun reload() {
actionsFlow.emit(
BatchAction.Reload(
requestParams = TangemPayTxHistoryListConfig(userWalletId = userWalletId, refresh = true),
requestParams = TangemPayTxHistoryListConfig(
customerWalletAddress = customerWalletAddress,
refresh = true,
),
),
)
}
suspend fun loadMore(userWalletId: UserWalletId) {
suspend fun loadMore(customerWalletAddress: String) {
actionsFlow.emit(
BatchAction.LoadMore(
requestParams = TangemPayTxHistoryListConfig(userWalletId, refresh = false),
requestParams = TangemPayTxHistoryListConfig(customerWalletAddress, refresh = false),
),
)
}

View file

@ -349,6 +349,7 @@ internal class WalletModel @Inject constructor(
value = info,
onIssueOrderClick = ::issueOrder,
onContinueKycClick = innerWalletRouter::openTangemPayOnboarding,
cardOnClick = ::tangemPayCardOnClick,
).transform(stateHolder.uiState.value.tangemPayState)
}
} ?: return
@ -374,6 +375,10 @@ internal class WalletModel @Inject constructor(
}
}
private fun tangemPayCardOnClick(customerWalletAddress: String) {
innerWalletRouter.openTangemPayDetails(customerWalletAddress)
}
private fun needToRefreshTimer() {
modelScope.launch {
delay(REFRESH_WALLET_BACKGROUND_TIMER_MILLIS)

View file

@ -111,4 +111,8 @@ internal class DefaultWalletRouter @Inject constructor(
override fun openTangemPayOnboarding() {
router.push(AppRoute.TangemPayOnboarding(AppRoute.TangemPayOnboarding.Mode.ContinueOnboarding))
}
override fun openTangemPayDetails(custoemrWalletAddress: String) {
router.push(AppRoute.TangemPayDetails(custoemrWalletAddress))
}
}

View file

@ -60,4 +60,6 @@ internal interface InnerWalletRouter {
fun openTokenReceiveBottomSheet(tokenReceiveConfig: TokenReceiveConfig)
fun openTangemPayOnboarding()
fun openTangemPayDetails(custoemrWalletAddress: String)
}

View file

@ -20,5 +20,6 @@ internal sealed class TangemPayState {
data class Card(
val lastFourDigits: TextReference,
val balanceText: TextReference,
val onClick: () -> Unit,
) : TangemPayState()
}

View file

@ -17,6 +17,7 @@ internal class TangemPayStateTransformer(
private val value: MainScreenCustomerInfo? = null,
private val onIssueOrderClick: () -> Unit = {},
private val onContinueKycClick: () -> Unit = {},
private val cardOnClick: (String) -> Unit = {},
private val issueProgressState: Boolean = false,
private val issueState: Boolean = false,
) : Transformer<TangemPayState> {
@ -63,6 +64,7 @@ internal class TangemPayStateTransformer(
private fun getCardInfoState(cardInfo: CardInfo): TangemPayState = TangemPayState.Card(
lastFourDigits = TextReference.Str("*${cardInfo.lastFourDigits}"),
balanceText = TextReference.Str(getBalanceText(cardInfo)),
onClick = { cardOnClick(cardInfo.customerWalletAddress) },
)
private fun getBalanceText(cardInfo: CardInfo): String {

View file

@ -1,6 +1,7 @@
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Surface
@ -21,7 +22,9 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
@Composable
internal fun TangemPayCardMainBlock(state: TangemPayState.Card, modifier: Modifier = Modifier) {
Surface(
modifier = modifier.fillMaxWidth(),
modifier = modifier
.fillMaxWidth()
.clickable { state.onClick() },
shape = TangemTheme.shapes.roundedCornersXMedium,
color = TangemTheme.colors.background.primary,
) {

View file

@ -81,6 +81,7 @@ private fun ResetCardScreenPreview() {
TangemPayState.Card(
lastFourDigits = TextReference.Str("*1234"),
balanceText = TextReference.Str("$ 0.00"),
onClick = {},
),
)
}