Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-27 21:04:28 +05:00
parent e3d2e7f2e1
commit f25adffe54
12 changed files with 692 additions and 8 deletions

View file

@ -0,0 +1,40 @@
package com.tangem.features.approval.api
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
/**
* Entry component that wraps the two approval-flow variants:
*
* - [Mode.FullApproval] original [GiveApprovalComponent] which renders the approval-type
* selector together with the fee selector and submits the approval transaction.
* - [Mode.SelectOnly] [SelectApprovalTypeComponent] which only collects the approval-type
* choice and returns it to the caller via its own [SelectApprovalTypeComponent.Callback].
*
* Callers depend only on this single factory and pass the appropriate [Mode]; the entry
* component internally creates the corresponding child and delegates the bottom sheet
* rendering and dismissal to it.
*/
interface GiveApprovalEntryComponent : ComposableBottomSheetComponent {
data class Params(
val mode: Mode,
)
sealed interface Mode {
/** Full flow: approval-type selector + fee selector + transaction submission. */
data class FullApproval(
val params: GiveApprovalComponent.Params,
) : Mode
/** Selection-only flow: returns the chosen approval type without sending anything. */
data class SelectOnly(
val params: SelectApprovalTypeComponent.Params,
) : Mode
}
interface Factory {
fun create(context: AppComponentContext, params: Params): GiveApprovalEntryComponent
}
}

View file

@ -0,0 +1,39 @@
package com.tangem.features.approval.api
import com.tangem.common.ui.bottomsheet.permission.state.ApproveType
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
import com.tangem.core.ui.extensions.TextReference
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWalletId
/**
* Selection-only variant of [GiveApprovalComponent].
*
* Shows the same approval-type selector UI (LIMITED vs UNLIMITED) but does NOT submit the
* approval transaction. Instead, the chosen [ApproveType] is returned to the caller via
* [Callback.onApproveTypeSelected] when the user confirms. The caller is responsible for any
* downstream action (e.g. building the transaction, sending it, navigation).
*
* Intended for flows where the approval-type choice has to be collected separately from the
* actual fee selection / transaction submission step.
*/
interface SelectApprovalTypeComponent : ComposableBottomSheetComponent {
data class Params(
val userWalletId: UserWalletId,
val cryptoCurrencyStatus: CryptoCurrencyStatus,
val amountFooter: TextReference,
val initialApproveType: ApproveType = ApproveType.LIMITED,
val callback: Callback,
)
interface Callback {
fun onApproveTypeSelected(approveType: ApproveType)
fun onCancelClick()
}
interface Factory {
fun create(context: AppComponentContext, params: Params): SelectApprovalTypeComponent
}
}