Updated on 2026-08-14
This commit is contained in:
parent
b5dde35172
commit
5841bc65f4
13 changed files with 68 additions and 30 deletions
|
|
@ -15,7 +15,6 @@ import com.tangem.feature.learn2earn.domain.models.toDomainError
|
|||
import com.tangem.lib.crypto.DerivationManager
|
||||
import com.tangem.lib.crypto.UserWalletManager
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
import java.text.DecimalFormat
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -62,7 +61,7 @@ class DefaultLearn2earnInteractor(
|
|||
return repository.getUserData().isRegisteredInPromotion
|
||||
}
|
||||
|
||||
override fun getAwardAmount(): String {
|
||||
override fun getAwardAmount(): Pair<Int, String> {
|
||||
val userInfo = repository.getUserData()
|
||||
val promotionInfo = promotion.getPromotionInfo()
|
||||
|
||||
|
|
@ -70,9 +69,9 @@ class DefaultLearn2earnInteractor(
|
|||
promotionInfo.awardForOldCard
|
||||
} else {
|
||||
promotionInfo.awardForNewCard
|
||||
}
|
||||
}.toInt()
|
||||
|
||||
return DecimalFormat("0.#").format(awardAmount)
|
||||
return awardAmount to awardAmount.toString()
|
||||
}
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ interface Learn2earnInteractor : WebViewRedirectHandler {
|
|||
|
||||
fun isUserRegisteredInPromotion(): Boolean
|
||||
|
||||
fun getAwardAmount(): String
|
||||
fun getAwardAmount(): Pair<Int, String>
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
suspend fun requestAward(): Result<Unit>
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ class Learn2earnViewModel @Inject constructor(
|
|||
return if (interactor.isUserRegisteredInPromotion()) {
|
||||
MainScreenState.Description.GetBonus
|
||||
} else {
|
||||
MainScreenState.Description.Learn(interactor.getAwardAmount())
|
||||
val (count, award) = interactor.getAwardAmount()
|
||||
MainScreenState.Description.Learn(count, award)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,6 @@ private fun OneInchStoriesContentPreview_Dark() {
|
|||
private fun makePreviewState(): MainScreenState = MainScreenState(
|
||||
isVisible = true,
|
||||
onClick = {},
|
||||
description = MainScreenState.Description.Learn("0"),
|
||||
description = MainScreenState.Description.Learn(0, "0"),
|
||||
showProgress = false,
|
||||
)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.learn2earn.presentation.ui.state
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.WrappedList
|
||||
import com.tangem.feature.learn2earn.domain.models.PromotionError
|
||||
import com.tangem.feature.learn2earn.impl.R
|
||||
|
||||
|
|
@ -30,9 +31,9 @@ data class MainScreenState(
|
|||
|
||||
sealed class Description(val title: TextReference, val subtitle: TextReference) {
|
||||
|
||||
class Learn(awardAmount: String) : Description(
|
||||
class Learn(count: Int, award: String) : Description(
|
||||
TextReference.Res(R.string.main_learn_title),
|
||||
TextReference.Res(R.string.main_learn_subtitle, listOf(awardAmount)),
|
||||
TextReference.PluralRes(R.plurals.main_learn_subtitle, count, WrappedList(listOf(award))),
|
||||
)
|
||||
|
||||
object GetBonus : Description(
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ internal fun Learn2earnState.Companion.init(uiActions: UiActions): Learn2earnSta
|
|||
mainScreenState = MainScreenState(
|
||||
isVisible = false,
|
||||
onClick = uiActions.buttonMainClick,
|
||||
description = MainScreenState.Description.Learn("0"),
|
||||
description = MainScreenState.Description.Learn(0, "0"),
|
||||
showProgress = false,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue