Updated on 2026-08-14
This commit is contained in:
parent
45ab6836ad
commit
5c56f04c38
52 changed files with 228 additions and 72 deletions
|
|
@ -24,6 +24,7 @@ dependencies {
|
|||
implementation(projects.core.decompose)
|
||||
implementation(projects.libs.crypto)
|
||||
implementation(projects.common.routing)
|
||||
implementation(projects.common.ui)
|
||||
|
||||
/** AndroidX */
|
||||
implementation(deps.androidx.appCompat)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -147,13 +148,18 @@ internal class ReferralModel @Inject constructor(
|
|||
url = tosLink,
|
||||
expectedAwards = expectedAwards,
|
||||
)
|
||||
is ReferralData.NonParticipantData -> ReferralInfoState.NonParticipantContent(
|
||||
award = getAwardValue(),
|
||||
networkName = getNetworkName(),
|
||||
discount = getDiscountValue(),
|
||||
url = tosLink,
|
||||
onParticipateClicked = ::participate,
|
||||
)
|
||||
is ReferralData.NonParticipantData -> {
|
||||
val userWallet = getUserWalletUseCase(params.userWalletId).getOrNull() ?: error("User wallet not found")
|
||||
|
||||
ReferralInfoState.NonParticipantContent(
|
||||
award = getAwardValue(),
|
||||
networkName = getNetworkName(),
|
||||
discount = getDiscountValue(),
|
||||
url = tosLink,
|
||||
onParticipateClicked = ::participate,
|
||||
participateButtonIcon = walletInterationIcon(userWallet),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ReferralData.getAwardValue(): String = "$award ${getToken().symbol}"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.referral.models
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.feature.referral.domain.models.ExpectedAwards
|
||||
|
||||
internal data class ReferralStateHolder(
|
||||
|
|
@ -36,6 +37,7 @@ internal data class ReferralStateHolder(
|
|||
override val networkName: String,
|
||||
override val discount: String,
|
||||
override val url: String,
|
||||
@DrawableRes val participateButtonIcon: Int?,
|
||||
val onParticipateClicked: () -> Unit,
|
||||
) : ReferralInfoState, ReferralInfoContentState
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.referral.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -15,7 +16,11 @@ import com.tangem.core.ui.res.TangemThemePreview
|
|||
import com.tangem.feature.referral.presentation.R
|
||||
|
||||
@Composable
|
||||
internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipateClick: () -> Unit) {
|
||||
internal fun NonParticipateBottomBlock(
|
||||
@DrawableRes buttonIconRes: Int?,
|
||||
onAgreementClick: () -> Unit,
|
||||
onParticipateClick: () -> Unit,
|
||||
) {
|
||||
Column {
|
||||
AgreementText(
|
||||
firstPartResId = R.string.referral_tos_not_enroled_prefix,
|
||||
|
|
@ -24,7 +29,7 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa
|
|||
|
||||
PrimaryButtonIconEnd(
|
||||
text = stringResourceSafe(id = R.string.referral_button_participate),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = buttonIconRes,
|
||||
onClick = onParticipateClick,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
@ -39,7 +44,7 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa
|
|||
private fun Preview_NonParticipateBottomBlock() {
|
||||
TangemThemePreview {
|
||||
Column(Modifier.background(TangemTheme.colors.background.primary)) {
|
||||
NonParticipateBottomBlock(onAgreementClick = {}, onParticipateClick = {})
|
||||
NonParticipateBottomBlock(buttonIconRes = null, onAgreementClick = {}, onParticipateClick = {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -183,6 +183,7 @@ private fun ReferralInfo(
|
|||
NonParticipateBottomBlock(
|
||||
onAgreementClick = onAgreementClick,
|
||||
onParticipateClick = state.onParticipateClicked,
|
||||
buttonIconRes = state.participateButtonIcon,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +466,7 @@ private fun Preview_ReferralScreen_NonParticipant() {
|
|||
discount = "10%",
|
||||
url = "",
|
||||
onParticipateClicked = {},
|
||||
participateButtonIcon = R.drawable.ic_tangem_24,
|
||||
),
|
||||
errorSnackbar = null,
|
||||
analytics = Analytics(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue