Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-05 11:32:57 +03:00
commit 6e32f37a10
8 changed files with 29 additions and 5 deletions

View file

@ -268,6 +268,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
private fun refreshWalletData() {
Analytics.send(Portfolio.Refreshed())
store.dispatch(WalletAction.LoadData.Refresh)
learn2earnViewModel.onMainScreenRefreshed()
}
private fun showWarningsIfPresent(warnings: List<WarningMessage>) {

View file

@ -174,7 +174,7 @@
<string name="main_no_backup_warning_title">Бэкап кошелька не был произведен</string>
<string name="main_page_balance">Баланс</string>
<string name="main_processing_full_amount">В сумме учтены не все монеты</string>
<string name="main_promotion_credited">Токены 1inch будут зачислены на адрес вашего кошелька в течение 2 дней</string>
<string name="main_promotion_credited">Токены 1inch будут зачислены на адрес вашего кошелька %s в течение 24 часов</string>
<string name="main_promotion_no_purchase">По вашему промокоду не было покупки кошелька, а значит вы не можете получить бонус. Купите кошелек Tangem, отсканируйте его в приложении и получите бонус.</string>
<string name="main_scan_card_warning_view_subtitle">Чтобы получить доступ ко всем сетям, вам необходимо отсканировать карту</string>
<string name="main_scan_card_warning_view_title">Отсканируйте карту</string>

View file

@ -170,7 +170,7 @@
<string name="main_no_backup_warning_title">Your wallet has not been backed up</string>
<string name="main_page_balance">Total balance</string>
<string name="main_processing_full_amount">The amount does not include some of your funds</string>
<string name="main_promotion_credited">1inch tokens will be credited to your wallet address within 2 days</string>
<string name="main_promotion_credited">1inch tokens will be credited to your %s wallet address within 24 hours</string>
<string name="main_promotion_no_purchase">There was no purchase of a wallet using your promo code, which means you cannot receive a bonus. Buy Tangem wallet, scan it in the app, and get the bonus.</string>
<string name="main_scan_card_warning_view_subtitle">To access all the networks you need to scan the card</string>
<string name="main_scan_card_warning_view_title">Scan your card</string>

View file

@ -48,8 +48,18 @@ class DefaultLearn2earnInteractor(
override suspend fun isNeedToShowViewOnMainScreen(): Boolean {
if (!promotionIsActive()) return false
val response = repository.validate(userWalletManager.getWalletId())
return response.valid == true
val promoCode = repository.getUserData().promoCode
val userWalletId = userWalletManager.getWalletId()
return if (promoCode == null) {
val response = repository.validate(userWalletId)
response.valid == true
} else {
val response = repository.validateCode(userWalletId, promoCode)
when (val error = response.error?.toDomainError()) {
null -> response.valid == true
else -> error !is PromotionError.CodeWasNotAppliedInShop
}
}
}
override fun isUserRegisteredInPromotion(): Boolean {
@ -63,6 +73,11 @@ class DefaultLearn2earnInteractor(
return awardAmount
}
override fun getAwardNetworkName(): String {
val networkId = promotion.getPromotionInfo().awardPaymentToken.networkId
return userWalletManager.getNativeTokenForNetwork(networkId).name
}
@Throws(IllegalArgumentException::class)
override suspend fun requestAward(): Result<Unit> {
val awardCurrency = getCurrencyForAward()

View file

@ -21,6 +21,8 @@ interface Learn2earnInteractor : WebViewRedirectHandler {
fun getAwardAmount(): Int
fun getAwardNetworkName(): String
@Throws(IllegalArgumentException::class)
suspend fun requestAward(): Result<Unit>

View file

@ -45,6 +45,10 @@ class Learn2earnViewModel @Inject constructor(
updateMainScreenViews()
}
fun onMainScreenRefreshed() {
updateMainScreenViews()
}
private fun updateMainScreenViews() {
viewModelScope.launch(dispatchers.io) {
if (interactor.isNeedToShowViewOnMainScreen()) {
@ -81,6 +85,7 @@ class Learn2earnViewModel @Inject constructor(
.hideDialog()
}
val successDialog = MainScreenState.Dialog.Claimed(
networkFullName = interactor.getAwardNetworkName(),
onOk = onHideDialog,
onDismissRequest = onHideDialog,
)

View file

@ -28,7 +28,7 @@ private fun ClaimedDialog(dialog: MainScreenState.Dialog.Claimed) {
Text(text = stringResource(id = R.string.common_success))
},
text = {
Text(text = stringResource(id = R.string.main_promotion_credited))
Text(text = stringResource(id = R.string.main_promotion_credited, dialog.networkFullName))
},
confirmButton = {
TextButton(

View file

@ -50,6 +50,7 @@ data class MainScreenState(
sealed class Dialog {
data class Claimed(
val networkFullName: String,
val onOk: () -> Unit,
val onDismissRequest: () -> Unit,
) : Dialog()