Updated on 2026-08-14
This commit is contained in:
parent
7443421bb1
commit
b83b9d4ef6
19 changed files with 226 additions and 74 deletions
|
|
@ -19,16 +19,19 @@ import com.tangem.features.tangempay.navigation.TangemPayAccountDetailsInnerRout
|
|||
import com.tangem.features.tangempay.utils.userWalletId
|
||||
import com.tangem.features.tokendetails.ExpressTransactionsComponent
|
||||
import com.tangem.features.tokenreceive.TokenReceiveComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class DefaultTangemPayDetailsContainerComponent @AssistedInject constructor(
|
||||
@Assisted private val appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: TangemPayDetailsContainerComponent.Params,
|
||||
private val tangemPayCardPageFactory: TangemPayCardPageComponent.Factory,
|
||||
private val tokenReceiveComponentFactory: TokenReceiveComponent.Factory,
|
||||
private val expressTransactionsComponentFactory: ExpressTransactionsComponent.Factory,
|
||||
private val virtualAccountAddFundsComponentFactory: VirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
) : AppComponentContext by appComponentContext, TangemPayDetailsContainerComponent {
|
||||
|
||||
private val stackNavigation = StackNavigation<TangemPayAccountDetailsInnerRoute>()
|
||||
|
|
@ -65,6 +68,7 @@ internal class DefaultTangemPayDetailsContainerComponent @AssistedInject constru
|
|||
params = params,
|
||||
tokenReceiveComponentFactory = tokenReceiveComponentFactory,
|
||||
expressTransactionsComponentFactory = expressTransactionsComponentFactory,
|
||||
virtualAccountAddFundsComponentFactory = virtualAccountAddFundsComponentFactory,
|
||||
)
|
||||
is TangemPayAccountDetailsInnerRoute.CardDetails -> tangemPayCardPageFactory.create(
|
||||
context = childByContext(componentContext = componentContext, router = innerRouter),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.tangem.features.tangempay.limit.setup.TangemPayCardLimitSetupSuccessC
|
|||
import com.tangem.features.tangempay.navigation.TangemPayCardDetailsInnerRoute
|
||||
import com.tangem.features.tangempay.utils.userWalletId
|
||||
import com.tangem.features.tokenreceive.TokenReceiveComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
|
@ -31,6 +32,7 @@ internal class TangemPayCardPageComponent @AssistedInject constructor(
|
|||
@Assisted private val appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: Params,
|
||||
private val tokenReceiveComponentFactory: TokenReceiveComponent.Factory,
|
||||
private val virtualAccountAddFundsComponentFactory: VirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
private val tangemPayFeatureToggles: TangemPayFeatureToggles,
|
||||
) : ComposableContentComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
|
|
@ -69,6 +71,7 @@ internal class TangemPayCardPageComponent @AssistedInject constructor(
|
|||
appComponentContext = childByContext(componentContext = componentContext, router = innerRouter),
|
||||
params = params,
|
||||
tokenReceiveComponentFactory = tokenReceiveComponentFactory,
|
||||
virtualAccountAddFundsComponentFactory = virtualAccountAddFundsComponentFactory,
|
||||
)
|
||||
is TangemPayCardDetailsInnerRoute.ChangePIN -> TangemPayChangePinComponent(
|
||||
appComponentContext = childByContext(componentContext = componentContext, router = innerRouter),
|
||||
|
|
|
|||
|
|
@ -20,13 +20,18 @@ import com.tangem.features.tangempay.closure.TangemPayCloseCardComponent
|
|||
import com.tangem.features.tangempay.entity.TangemPayCardNavigation
|
||||
import com.tangem.features.tangempay.model.TangemPayCardPageModel
|
||||
import com.tangem.features.tangempay.ui.TangemPayCardPageScreen
|
||||
import com.tangem.features.tangempay.utils.VA_DAILY_DEPOSIT_LIMIT_PLACEHOLDER
|
||||
import com.tangem.features.tangempay.utils.toRequisitesRows
|
||||
import com.tangem.features.tangempay.utils.userWalletId
|
||||
import com.tangem.features.tokenreceive.TokenReceiveComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsListener
|
||||
|
||||
internal class TangemPayCardPageScreenComponent(
|
||||
private val appComponentContext: AppComponentContext,
|
||||
private val params: TangemPayCardPageComponent.Params,
|
||||
private val tokenReceiveComponentFactory: TokenReceiveComponent.Factory,
|
||||
private val virtualAccountAddFundsComponentFactory: VirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
) : AppComponentContext by appComponentContext, ComposableContentComponent {
|
||||
|
||||
private val model: TangemPayCardPageModel = getOrCreateModel(params = params)
|
||||
|
|
@ -105,6 +110,17 @@ internal class TangemPayCardPageScreenComponent(
|
|||
params = TangemPayVirtualAccountDepositComponent.Params(
|
||||
virtualAccountOnramp = navigation.virtualAccountOnramp,
|
||||
onDismiss = model.bottomSheetNavigation::dismiss,
|
||||
onShowDetails = model::onShowVirtualAccountRequisites,
|
||||
),
|
||||
)
|
||||
is TangemPayCardNavigation.VirtualAccountRequisites -> virtualAccountAddFundsComponentFactory.create(
|
||||
context = context,
|
||||
params = VirtualAccountAddFundsBottomSheetComponent.Params(
|
||||
userWalletId = navigation.userWalletId,
|
||||
requisites = navigation.bankCredentials.toRequisitesRows(),
|
||||
dailyDepositLimit = VA_DAILY_DEPOSIT_LIMIT_PLACEHOLDER,
|
||||
shouldSkipIntro = true,
|
||||
listener = VirtualAccountAddFundsListener { model.bottomSheetNavigation.dismiss() },
|
||||
),
|
||||
)
|
||||
is TangemPayCardNavigation.Receive -> tokenReceiveComponentFactory.create(
|
||||
|
|
|
|||
|
|
@ -24,16 +24,21 @@ import com.tangem.features.tangempay.entity.TangemPayDetailsNavigation
|
|||
import com.tangem.features.tangempay.model.TangemPayDetailsModel
|
||||
import com.tangem.features.tangempay.ui.TangemPayDetailsScreen
|
||||
import com.tangem.features.tangempay.ui.TangemPayDetailsScreenV2
|
||||
import com.tangem.features.tangempay.utils.VA_DAILY_DEPOSIT_LIMIT_PLACEHOLDER
|
||||
import com.tangem.features.tangempay.utils.requireLoaded
|
||||
import com.tangem.features.tangempay.utils.toRequisitesRows
|
||||
import com.tangem.features.tangempay.utils.userWalletId
|
||||
import com.tangem.features.tokendetails.ExpressTransactionsComponent
|
||||
import com.tangem.features.tokenreceive.TokenReceiveComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsListener
|
||||
|
||||
internal class TangemPayDetailsComponent(
|
||||
private val appComponentContext: AppComponentContext,
|
||||
private val params: TangemPayDetailsContainerComponent.Params,
|
||||
private val tokenReceiveComponentFactory: TokenReceiveComponent.Factory,
|
||||
private val expressTransactionsComponentFactory: ExpressTransactionsComponent.Factory,
|
||||
private val virtualAccountAddFundsComponentFactory: VirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
) : AppComponentContext by appComponentContext, ComposableContentComponent {
|
||||
|
||||
private val model: TangemPayDetailsModel = getOrCreateModel(params = params)
|
||||
|
|
@ -134,6 +139,17 @@ internal class TangemPayDetailsComponent(
|
|||
params = TangemPayVirtualAccountDepositComponent.Params(
|
||||
virtualAccountOnramp = navigation.virtualAccountOnramp,
|
||||
onDismiss = model.bottomSheetNavigation::dismiss,
|
||||
onShowDetails = model::onShowVirtualAccountRequisites,
|
||||
),
|
||||
)
|
||||
is TangemPayDetailsNavigation.VirtualAccountRequisites -> virtualAccountAddFundsComponentFactory.create(
|
||||
context = context,
|
||||
params = VirtualAccountAddFundsBottomSheetComponent.Params(
|
||||
userWalletId = navigation.userWalletId,
|
||||
requisites = navigation.bankCredentials.toRequisitesRows(),
|
||||
dailyDepositLimit = VA_DAILY_DEPOSIT_LIMIT_PLACEHOLDER,
|
||||
shouldSkipIntro = true,
|
||||
listener = VirtualAccountAddFundsListener { model.bottomSheetNavigation.dismiss() },
|
||||
),
|
||||
)
|
||||
is TangemPayDetailsNavigation.IssueAdditionalCard -> TangemPayIssueAdditionalCardComponent(
|
||||
|
|
|
|||
|
|
@ -31,5 +31,6 @@ internal class TangemPayVirtualAccountDepositComponent(
|
|||
data class Params(
|
||||
val virtualAccountOnramp: VirtualAccountOnramp,
|
||||
val onDismiss: () -> Unit,
|
||||
val onShowDetails: (VirtualAccountOnramp.Available) -> Unit,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.tangempay.entity
|
||||
|
||||
import com.tangem.domain.models.TokenReceiveConfig
|
||||
import com.tangem.domain.models.account.BankCredentials
|
||||
import com.tangem.domain.models.account.VirtualAccountOnramp
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.serialization.SerializedBigDecimal
|
||||
|
|
@ -39,6 +40,12 @@ internal sealed class TangemPayCardNavigation {
|
|||
val virtualAccountOnramp: VirtualAccountOnramp,
|
||||
) : TangemPayCardNavigation()
|
||||
|
||||
@Serializable
|
||||
data class VirtualAccountRequisites(
|
||||
val userWalletId: UserWalletId,
|
||||
val bankCredentials: BankCredentials,
|
||||
) : TangemPayCardNavigation()
|
||||
|
||||
@Serializable
|
||||
data class Receive(val config: TokenReceiveConfig) : TangemPayCardNavigation()
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.tangempay.entity
|
||||
|
||||
import com.tangem.domain.models.TokenReceiveConfig
|
||||
import com.tangem.domain.models.account.BankCredentials
|
||||
import com.tangem.domain.models.account.VirtualAccountOnramp
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.serialization.SerializedBigDecimal
|
||||
|
|
@ -30,6 +31,12 @@ internal sealed class TangemPayDetailsNavigation {
|
|||
val virtualAccountOnramp: VirtualAccountOnramp,
|
||||
) : TangemPayDetailsNavigation()
|
||||
|
||||
@Serializable
|
||||
data class VirtualAccountRequisites(
|
||||
val userWalletId: UserWalletId,
|
||||
val bankCredentials: BankCredentials,
|
||||
) : TangemPayDetailsNavigation()
|
||||
|
||||
@Serializable
|
||||
data class TransactionDetails(
|
||||
val transaction: TangemPayTxHistoryItem,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.tangem.domain.models.StatusSource
|
|||
import com.tangem.domain.models.TokenReceiveConfig
|
||||
import com.tangem.domain.models.account.AccountStatus
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.VirtualAccountOnramp
|
||||
import com.tangem.domain.models.account.findCardWithId
|
||||
import com.tangem.domain.models.pay.TangemPayCard
|
||||
import com.tangem.domain.models.pay.TangemPayCardLimitPeriod
|
||||
|
|
@ -491,6 +492,16 @@ internal class TangemPayCardPageModel @Inject constructor(
|
|||
bottomSheetNavigation.activate(TangemPayCardNavigation.VirtualAccountDeposit(onramp))
|
||||
}
|
||||
|
||||
fun onShowVirtualAccountRequisites(onramp: VirtualAccountOnramp.Available) {
|
||||
bottomSheetNavigation.dismiss()
|
||||
bottomSheetNavigation.activate(
|
||||
TangemPayCardNavigation.VirtualAccountRequisites(
|
||||
userWalletId = userWalletId,
|
||||
bankCredentials = onramp.bankCredentials,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDismissAddFunds() {
|
||||
bottomSheetNavigation.dismiss()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.tangem.domain.feedback.models.FeedbackEmailType
|
|||
import com.tangem.domain.feedback.models.WalletMetaInfo
|
||||
import com.tangem.domain.models.TokenReceiveConfig
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.VirtualAccountOnramp
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher
|
||||
import com.tangem.domain.pay.flow.PaymentAccountStatusSupplier
|
||||
|
|
@ -316,6 +317,16 @@ internal class TangemPayDetailsModel @Inject constructor(
|
|||
bottomSheetNavigation.activate(TangemPayDetailsNavigation.VirtualAccountDeposit(onramp))
|
||||
}
|
||||
|
||||
fun onShowVirtualAccountRequisites(onramp: VirtualAccountOnramp.Available) {
|
||||
bottomSheetNavigation.dismiss()
|
||||
bottomSheetNavigation.activate(
|
||||
TangemPayDetailsNavigation.VirtualAccountRequisites(
|
||||
userWalletId = userWalletId,
|
||||
bankCredentials = onramp.bankCredentials,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onClickReceive(data: TangemPayTopUpData) {
|
||||
analytics.send(TangemPayAnalyticsEvents.ReceiveFundsClicked())
|
||||
bottomSheetNavigation.dismiss()
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ internal class TangemPayVirtualAccountDepositModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun onShowDetailsClick() {
|
||||
// TODO([REDACTED_TASK_KEY]): VA MVP0 — open the bank-transfer requisites screen (separate PR).
|
||||
when (params.virtualAccountOnramp) {
|
||||
is VirtualAccountOnramp.Available -> params.onShowDetails(params.virtualAccountOnramp)
|
||||
VirtualAccountOnramp.Eligible -> TODO()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.tangem.features.tangempay.utils
|
||||
|
||||
import com.tangem.domain.models.account.BankCredentials
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent.RequisitesRow
|
||||
|
||||
/**
|
||||
* MVP0 placeholder for the daily deposit limit shown by the reused VA requisites bottom sheet.
|
||||
*
|
||||
* [REDACTED_TODO_COMMENT]
|
||||
*/
|
||||
internal const val VA_DAILY_DEPOSIT_LIMIT_PLACEHOLDER = "$10,000"
|
||||
|
||||
/**
|
||||
* Maps VA on-ramp [BankCredentials] to the requisites rows consumed by the reused
|
||||
* `VirtualAccountAddFundsBottomSheetComponent` (mirrors `VirtualAccountMainModel.buildRequisites`).
|
||||
*/
|
||||
internal fun BankCredentials.toRequisitesRows(): List<RequisitesRow> = listOf(
|
||||
RequisitesRow(
|
||||
title = "Beneficiary name and address",
|
||||
titleForShare = "Beneficiary name and address",
|
||||
value = "$beneficiaryName\n$beneficiaryAddress",
|
||||
),
|
||||
RequisitesRow(
|
||||
title = "Bank name and address",
|
||||
titleForShare = "Bank name and address",
|
||||
value = "$beneficiaryBankName\n$beneficiaryBankAddress",
|
||||
),
|
||||
RequisitesRow(
|
||||
title = "Account number",
|
||||
titleForShare = "Account number",
|
||||
value = accountNumber,
|
||||
),
|
||||
RequisitesRow(
|
||||
title = "Routing number",
|
||||
titleForShare = "Routing number",
|
||||
value = routingNumber,
|
||||
),
|
||||
)
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.tangem.features.virtualaccount.details.component
|
||||
|
||||
import com.tangem.core.decompose.factory.ComponentFactory
|
||||
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
||||
/**
|
||||
* Bottom sheet showing Virtual Account bank-transfer requisites (beneficiary, bank, account & routing numbers).
|
||||
*
|
||||
* Two stages: an educational intro and the requisites. Set [Params.shouldSkipIntro] to open straight at the
|
||||
* requisites — used by callers (e.g. TangemPay) that already show their own intro.
|
||||
*/
|
||||
interface VirtualAccountAddFundsBottomSheetComponent : ComposableBottomSheetComponent {
|
||||
|
||||
data class Params(
|
||||
val userWalletId: UserWalletId,
|
||||
val requisites: List<RequisitesRow>,
|
||||
val dailyDepositLimit: String,
|
||||
val listener: VirtualAccountAddFundsListener,
|
||||
val shouldSkipIntro: Boolean = false,
|
||||
)
|
||||
|
||||
data class RequisitesRow(
|
||||
val title: String,
|
||||
val titleForShare: String,
|
||||
val value: String,
|
||||
)
|
||||
|
||||
interface Factory : ComponentFactory<Params, VirtualAccountAddFundsBottomSheetComponent>
|
||||
}
|
||||
|
||||
fun interface VirtualAccountAddFundsListener {
|
||||
fun onAddFundsDismiss()
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ import com.tangem.core.decompose.context.AppComponentContext
|
|||
import com.tangem.core.decompose.context.childByContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountMainComponent
|
||||
import com.tangem.features.virtualaccount.main.addfunds.VirtualAccountAddFundsBottomSheetComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
|
@ -20,6 +20,7 @@ import dagger.assisted.AssistedInject
|
|||
internal class DefaultVirtualAccountMainComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: VirtualAccountMainComponent.Params,
|
||||
private val addFundsComponentFactory: VirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
) : VirtualAccountMainComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val model: VirtualAccountMainModel = getOrCreateModel(params = params)
|
||||
|
|
@ -44,8 +45,8 @@ internal class DefaultVirtualAccountMainComponent @AssistedInject constructor(
|
|||
componentContext: ComponentContext,
|
||||
): ComposableBottomSheetComponent {
|
||||
return when (config) {
|
||||
is VirtualAccountMainNavigationBottomSheetConfig.AddFunds -> VirtualAccountAddFundsBottomSheetComponent(
|
||||
appComponentContext = childByContext(componentContext),
|
||||
is VirtualAccountMainNavigationBottomSheetConfig.AddFunds -> addFundsComponentFactory.create(
|
||||
context = childByContext(componentContext),
|
||||
params = VirtualAccountAddFundsBottomSheetComponent.Params(
|
||||
userWalletId = params.userWalletId,
|
||||
listener = model,
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import com.tangem.core.decompose.model.ParamsContainer
|
|||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsListener
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountMainComponent
|
||||
import com.tangem.features.virtualaccount.details.impl.R
|
||||
import com.tangem.features.virtualaccount.main.addfunds.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.main.addfunds.VirtualAccountAddFundsListener
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -57,22 +57,22 @@ internal class VirtualAccountMainModel @Inject constructor(
|
|||
|
||||
private fun buildRequisites(details: VirtualAccountDepositDetails) = listOf(
|
||||
VirtualAccountAddFundsBottomSheetComponent.RequisitesRow(
|
||||
title = stringReference("Beneficiary name and address"),
|
||||
title = "Beneficiary name and address",
|
||||
titleForShare = "Beneficiary name and address",
|
||||
value = "${details.beneficiaryName}\n${details.beneficiaryAddress}",
|
||||
),
|
||||
VirtualAccountAddFundsBottomSheetComponent.RequisitesRow(
|
||||
title = stringReference("Bank name and address"),
|
||||
title = "Bank name and address",
|
||||
titleForShare = "Bank name and address",
|
||||
value = "${details.bankName}\n${details.bankAddress}",
|
||||
),
|
||||
VirtualAccountAddFundsBottomSheetComponent.RequisitesRow(
|
||||
title = stringReference("Account number"),
|
||||
title = "Account number",
|
||||
titleForShare = "Account number",
|
||||
value = details.accountNumber,
|
||||
),
|
||||
VirtualAccountAddFundsBottomSheetComponent.RequisitesRow(
|
||||
title = stringReference("Routing number"),
|
||||
title = "Routing number",
|
||||
titleForShare = "Routing number",
|
||||
value = details.routingNumber,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.features.virtualaccount.main
|
||||
|
||||
import com.tangem.features.virtualaccount.main.addfunds.VirtualAccountAddFundsBottomSheetComponent.RequisitesRow
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent.RequisitesRow
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.tangem.features.virtualaccount.main.addfunds
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
||||
internal class DefaultVirtualAccountAddFundsBottomSheetComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
@Assisted params: VirtualAccountAddFundsBottomSheetComponent.Params,
|
||||
) : VirtualAccountAddFundsBottomSheetComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val model: VirtualAccountAddFundsModel = getOrCreateModel(params = params)
|
||||
|
||||
override fun dismiss() {
|
||||
model.onDismiss()
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun BottomSheet() {
|
||||
val state by model.uiState.collectAsStateWithLifecycle()
|
||||
VirtualAccountAddFundsBottomSheet(state = state)
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory : VirtualAccountAddFundsBottomSheetComponent.Factory {
|
||||
override fun create(
|
||||
context: AppComponentContext,
|
||||
params: VirtualAccountAddFundsBottomSheetComponent.Params,
|
||||
): DefaultVirtualAccountAddFundsBottomSheetComponent
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.tangem.features.virtualaccount.main.addfunds
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
||||
internal class VirtualAccountAddFundsBottomSheetComponent(
|
||||
appComponentContext: AppComponentContext,
|
||||
params: Params,
|
||||
) : ComposableBottomSheetComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val model: VirtualAccountAddFundsModel = getOrCreateModel(params = params)
|
||||
|
||||
override fun dismiss() {
|
||||
model.onDismiss()
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun BottomSheet() {
|
||||
val state by model.uiState.collectAsStateWithLifecycle()
|
||||
VirtualAccountAddFundsBottomSheet(state = state)
|
||||
}
|
||||
|
||||
data class Params(
|
||||
val userWalletId: UserWalletId,
|
||||
val requisites: List<RequisitesRow>,
|
||||
val dailyDepositLimit: String,
|
||||
val listener: VirtualAccountAddFundsListener,
|
||||
)
|
||||
|
||||
data class RequisitesRow(
|
||||
val title: TextReference,
|
||||
val titleForShare: String,
|
||||
val value: String,
|
||||
)
|
||||
}
|
||||
|
||||
internal interface VirtualAccountAddFundsListener {
|
||||
fun onAddFundsDismiss()
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@ import com.tangem.core.decompose.model.Model
|
|||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
import com.tangem.core.ui.clipboard.ClipboardManager
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -30,9 +31,7 @@ internal class VirtualAccountAddFundsModel @Inject constructor(
|
|||
field = MutableStateFlow(
|
||||
VirtualAccountAddFundsUM(
|
||||
onDismiss = ::onDismiss,
|
||||
content = VirtualAccountAddFundsUM.Content.Intro(
|
||||
onShowDetailsClick = { showDetailsContent() },
|
||||
),
|
||||
content = if (params.shouldSkipIntro) buildDetailsContent() else buildIntroContent(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -40,22 +39,24 @@ internal class VirtualAccountAddFundsModel @Inject constructor(
|
|||
params.listener.onAddFundsDismiss()
|
||||
}
|
||||
|
||||
private fun buildIntroContent() = VirtualAccountAddFundsUM.Content.Intro(
|
||||
onShowDetailsClick = ::showDetailsContent,
|
||||
)
|
||||
|
||||
private fun showDetailsContent() {
|
||||
uiState.update { state ->
|
||||
state.copy(
|
||||
content = VirtualAccountAddFundsUM.Content.Details(
|
||||
items = params.requisites
|
||||
.map { detailItem(label = it.title, value = it.value) }
|
||||
.toImmutableList(),
|
||||
dailyLimit = params.dailyDepositLimit,
|
||||
onShareClick = { shareManager.shareText(buildShareText()) },
|
||||
),
|
||||
)
|
||||
}
|
||||
uiState.update { state -> state.copy(content = buildDetailsContent()) }
|
||||
}
|
||||
|
||||
private fun detailItem(label: TextReference, value: String) = VirtualAccountAddFundsUM.DetailItem(
|
||||
label = label,
|
||||
private fun buildDetailsContent() = VirtualAccountAddFundsUM.Content.Details(
|
||||
items = params.requisites
|
||||
.map { detailItem(label = it.title, value = it.value) }
|
||||
.toImmutableList(),
|
||||
dailyLimit = params.dailyDepositLimit,
|
||||
onShareClick = { shareManager.shareText(buildShareText()) },
|
||||
)
|
||||
|
||||
private fun detailItem(label: String, value: String) = VirtualAccountAddFundsUM.DetailItem(
|
||||
label = stringReference(label),
|
||||
value = value,
|
||||
onCopyClick = { clipboardManager.setText(text = value, isSensitive = true) },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.tangem.features.virtualaccount.main.di
|
||||
|
||||
import com.tangem.features.virtualaccount.main.DefaultVirtualAccountMainComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountAddFundsBottomSheetComponent
|
||||
import com.tangem.features.virtualaccount.details.component.VirtualAccountMainComponent
|
||||
import com.tangem.features.virtualaccount.main.DefaultVirtualAccountMainComponent
|
||||
import com.tangem.features.virtualaccount.main.addfunds.DefaultVirtualAccountAddFundsBottomSheetComponent
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
@ -15,4 +17,9 @@ internal interface VirtualAccountMainComponentModule {
|
|||
fun bindVirtualAccountMainComponentFactory(
|
||||
factory: DefaultVirtualAccountMainComponent.Factory,
|
||||
): VirtualAccountMainComponent.Factory
|
||||
|
||||
@Binds
|
||||
fun bindVirtualAccountAddFundsComponentFactory(
|
||||
factory: DefaultVirtualAccountAddFundsBottomSheetComponent.Factory,
|
||||
): VirtualAccountAddFundsBottomSheetComponent.Factory
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue