Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-21 15:06:14 +03:00
parent e356f020f3
commit 71dfa1c99f
31 changed files with 146 additions and 81 deletions

View file

@ -835,8 +835,8 @@
<string name="wallet_settings_title">Wallet-Einstellungen</string>
<string name="wallet_title">Tangem</string>
<string name="warning_access_denied_message">Verwende %s oder scanne eine Karte, um den Zugriff auf deine Wallet freizuschalten.</string>
<string name="warning_approval_in_progress_message">Die Genehmigung des Swaps ist im Gange und wird in Kürze abgeschlossen sein.</string>
<string name="warning_approval_in_progress_title">Genehmigung in Arbeit</string>
<string name="warning_approval_in_progress_message">Das Genehmigungsverfahren ist derzeit im Gange und wird in Kürze abgeschlossen sein</string>
<string name="warning_approval_in_progress_title">Genehmigung läuft</string>
<string name="warning_backup_errors_message">Es scheint, dass die Aktivierung der Karte nicht korrekt abgeschlossen wurde. Dies kann an einem Problem mit dem NFC-Modul deines Gerätes oder an einem falschen Tippen der Karte auf dein Gerät liegen. Bitte wende dich an unser Support-Team, um Unterstützung zu erhalten.</string>
<string name="warning_backup_errors_title">Aktivierungsfehler</string>
<string name="warning_beacon_chain_retirement_content">Laut den Entwicklern des BNB-Netzes wird die Unterstützung für den BEP-2-Standard im Juni 2024 enden. Um den Verlust von Vermögenswerten mit diesem Standard zu vermeiden, konvertiere bitte in den BEP-20 Standard. Nutze gerne unseren Swap-Service, um sie auf das BNB Smart Chain Netzwerk zu übertragen.</string>
@ -854,12 +854,16 @@
<string name="warning_existential_deposit_title">Netzwerk erfordert eine Mindesteinzahlung</string>
<string name="warning_express_active_transaction_message">Der Swap wird nach Abschluss der Transaktion %s verfügbar sein.</string>
<string name="warning_express_active_transaction_title">Du hast aktive Transaktion</string>
<string name="warning_express_approval_in_progress_message">Die Genehmigung des Swaps ist im Gange und wird in Kürze abgeschlossen sein.</string>
<string name="warning_express_approval_in_progress_title">Genehmigung in Arbeit</string>
<string name="warning_express_dust_message">Der Mindestbetrag für den Tausch beträgt %1$s. Bitte stelle sicher, dass der Restsaldo nach dem Swap nicht unter %2$s liegt.</string>
<string name="warning_express_no_exchangeable_coins_description">Du hast keine %s Coins in deiner Liste</string>
<string name="warning_express_no_exchangeable_coins_title">Keine Token zum Tauschen verfügbar</string>
<string name="warning_express_not_enough_fee_for_token_tx_description">Um eine Transaktion durchzuführen, du etwas etwas einzahlen %1$s %2$s</string>
<string name="warning_express_not_enough_fee_for_token_tx_title">Die Gebühr %s kann nicht gedeckt werden</string>
<string name="warning_express_notification_invalid_reserve_amount_title">Der zu erhaltende Betrag muss mindestens %s betragen</string>
<string name="warning_express_pair_unavailable_message">Dies kann passieren, weil der Anbieter derzeit nicht in der Lage ist, dein ausgewähltes Paar zu swappen. Bitte warte einen Moment und versuche es später erneut. (Code %@)</string>
<string name="warning_express_pair_unavailable_title">Ausgewähltes Paar vorübergehend nicht verfügbar</string>
<string name="warning_express_refresh_required_title">Service vorübergehend nicht verfügbar</string>
<string name="warning_express_too_maximum_amount_title">Die Menge der zu tauschenden Token darf folgende Werte nicht überschreiten %s</string>
<string name="warning_express_too_minimal_amount_title">Der zu tauschende Betrag muss mindestens %s betragen</string>

View file

@ -98,6 +98,7 @@
<string name="common_enable">有効にする</string>
<string name="common_enabled">有効</string>
<string name="common_error">エラー</string>
<string name="common_exchange">交換</string>
<string name="common_explore">移動する</string>
<string name="common_explore_transaction_history">取引履歴を調べる</string>
<string name="common_explorer">エクスプローラー</string>
@ -823,8 +824,8 @@
<string name="wallet_settings_title">ウォレット設定</string>
<string name="wallet_title">Tangem</string>
<string name="warning_access_denied_message">%sを使用するか、カードをスキャンしてウォレットにアクセスしてください</string>
<string name="warning_approval_in_progress_message">スワップの承認は現在進行中で、まもなく完了する予定です。</string>
<string name="warning_approval_in_progress_title">承認が進行</string>
<string name="warning_approval_in_progress_message">許可付与のプロセスは現在進行中であり、まもなく完了する予定です。</string>
<string name="warning_approval_in_progress_title">承認中</string>
<string name="warning_backup_errors_message">カードのアクティベーションが正しく完了しませんでした。デバイスの NFCモジュールに問題があるか、カードをデバイスに正しくタップしていないことが原因かもしれません。サポートチームにお問い合わせください。</string>
<string name="warning_backup_errors_title">アクティベーションに失敗しました</string>
<string name="warning_beacon_chain_retirement_content">BNBネットワーク開発者によると、BEP-2規格のサポートは2024年6月に終了します。この規格の資産を失わないために、BEP-20規格に変換してください。BNBスマートチェーンネットワークへ移行するには、Tangemのスワップサービスをご利用ください。</string>
@ -842,6 +843,8 @@
<string name="warning_existential_deposit_title">ネットワークには最低残高が必要です</string>
<string name="warning_express_active_transaction_message">スワップは、%s の取引完了後に利用可能となります。</string>
<string name="warning_express_active_transaction_title">アクティブな取引があります</string>
<string name="warning_express_approval_in_progress_message">スワップの承認は現在進行中で、まもなく完了する予定です。</string>
<string name="warning_express_approval_in_progress_title">承認が進行中</string>
<string name="warning_express_dust_message">最低のスワップ金額は%1$s です。スワップ後の残金が%2$s を下回らないようにしてください。</string>
<string name="warning_express_no_exchangeable_coins_description">あなたのリストには、交換可能な %s トークンがありません。</string>
<string name="warning_express_no_exchangeable_coins_title">スワップ可能なトークンがありません</string>

View file

@ -684,7 +684,7 @@
<string name="staking_notification_earn_rewards_text_period_week">Стейкинг дает возможность вам получать %1$s. Награда будет зачисляться каждую неделю.</string>
<string name="staking_notification_earn_rewards_title">Получите награду за стейкинг</string>
<string name="staking_notification_unstake_text">Награда перестанет начисляться сразу после завершения стейкинга. Процесс завершения длится %s.</string>
<string name="staking_restake">Повторный стейкинг</string>
<string name="staking_restake">Сменить валидатора</string>
<string name="staking_restake_rewards">Застейкать вознаграждения</string>
<string name="staking_revoke">Отозвать</string>
<string name="staking_revote">Переголосовать</string>
@ -702,6 +702,7 @@
<string name="staking_stake_locked">Стейкинг закрыт</string>
<string name="staking_stake_more">Застейкать еще</string>
<string name="staking_title_stake">Застейкать %s</string>
<string name="staking_title_unstake">Вывести %s</string>
<string name="staking_unlocked_locked">Разблокировать</string>
<string name="staking_unstaked">Выведено из стейкинга</string>
<string name="staking_unstaked_footer">Проверьте процесс завершения стейкинга, чтобы вывести свои средства.</string>

View file

@ -704,7 +704,7 @@
<string name="staking_reward_schedule_month">Місяць</string>
<string name="staking_reward_schedule_week">Тиждень</string>
<string name="staking_rewards">Винагороди</string>
<string name="staking_stake_locked">Застейкати</string>
<string name="staking_stake_locked">Стейкінг закрито</string>
<string name="staking_stake_more">Застейкати більше</string>
<string name="staking_title_stake">Застейкати %s</string>
<string name="staking_title_unstake">Зняти зі стейкінгу %s</string>
@ -869,6 +869,7 @@
<string name="warning_express_not_enough_fee_for_token_tx_description">Щоб здійснити транзакцію, вам потрібно внести трохи %1$s %2$s</string>
<string name="warning_express_not_enough_fee_for_token_tx_title">Неможливо покрити комісію %s</string>
<string name="warning_express_notification_invalid_reserve_amount_title">Сума отримання не може бути меншою за %s</string>
<string name="warning_express_pair_unavailable_message">Це може статися тому, що провайдер наразі не може обміняти обрану пару. Будь ласка, зачекайте трохи та спробуйте ще раз. (Код %@)</string>
<string name="warning_express_refresh_required_title">Сервіс тимчасово недоступний</string>
<string name="warning_express_too_maximum_amount_title">Сума до обміну не повинна перевищувати %s</string>
<string name="warning_express_too_minimal_amount_title">Сума для обміну має бути не менше %s</string>

View file

@ -63,6 +63,7 @@
<string name="common_no"></string>
<string name="common_ok">OK</string>
<string name="common_origin_card">主卡片</string>
<string name="common_range">%1$s-%2$s</string>
<string name="common_reject">拒絕</string>
<string name="common_rename">重新命名</string>
<string name="common_save_changes">保存設置</string>

View file

@ -669,10 +669,10 @@
<string name="staking_details_warmup_period_info">The allocated time for activating participation in staking.</string>
<string name="staking_migrate">Migrate</string>
<string name="staking_native">Native staking</string>
<string name="staking_notification_earn_rewards_text_period_day">Staking allow you to earn %1$s. Your staking rewards arrive every day.</string>
<string name="staking_notification_earn_rewards_text_period_hour">Staking allow you to earn %1$s. Your staking rewards arrive every hour.</string>
<string name="staking_notification_earn_rewards_text_period_month">Staking allow you to earn %1$s. Your staking rewards arrive every month.</string>
<string name="staking_notification_earn_rewards_text_period_week">Staking allow you to earn %1$s. Your staking rewards arrive every week.</string>
<string name="staking_notification_earn_rewards_text_period_day">Staking allows you to earn %1$s. Your staking rewards arrive every day.</string>
<string name="staking_notification_earn_rewards_text_period_hour">Staking allows you to earn %1$s. Your staking rewards arrive every hour.</string>
<string name="staking_notification_earn_rewards_text_period_month">Staking allows you to earn %1$s. Your staking rewards arrive every month.</string>
<string name="staking_notification_earn_rewards_text_period_week">Staking allows you to earn %1$s. Your staking rewards arrive every week.</string>
<string name="staking_notification_earn_rewards_title">Earn staking rewards</string>
<string name="staking_notification_unstake_text">Rewards stop accruing immediately after you unstake. The unstaking process takes %s.</string>
<string name="staking_rebond">Rebond</string>

View file

@ -148,8 +148,8 @@ internal class DefaultStakingRepository(
val yield = getYield(cryptoCurrencyId, symbol)
StakingEntryInfo(
interestRate = requireNotNull(yield.validators.maxByOrNull { it.apr.orZero() }?.apr),
periodInDays = yield.metadata.cooldownPeriod.days,
apr = requireNotNull(yield.validators.maxByOrNull { it.apr.orZero() }?.apr),
rewardSchedule = yield.metadata.rewardSchedule,
tokenSymbol = yield.token.symbol,
)
}

View file

@ -1,9 +1,10 @@
package com.tangem.domain.staking.model
import com.tangem.domain.staking.model.stakekit.Yield
import java.math.BigDecimal
data class StakingEntryInfo(
val interestRate: BigDecimal,
val periodInDays: Int,
val apr: BigDecimal,
val rewardSchedule: Yield.Metadata.RewardSchedule,
val tokenSymbol: String,
)

View file

@ -32,9 +32,9 @@ class MockStakingRepository : StakingRepository {
override suspend fun getEntryInfo(cryptoCurrencyId: CryptoCurrency.ID, symbol: String): StakingEntryInfo =
StakingEntryInfo(
interestRate = 1.toBigDecimal(),
periodInDays = 2,
apr = 1.toBigDecimal(),
tokenSymbol = "SOL",
rewardSchedule = Yield.Metadata.RewardSchedule.DAY,
)
override suspend fun getYield(cryptoCurrencyId: CryptoCurrency.ID, symbol: String): Yield = Yield(

View file

@ -6,7 +6,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency
import java.math.BigDecimal
@Immutable
sealed class FeeState {
internal sealed class FeeState {
data class Content(
val fee: Fee?,

View file

@ -1,6 +1,6 @@
package com.tangem.features.staking.impl.presentation.state
enum class InnerConfirmationStakingState {
internal enum class InnerConfirmationStakingState {
ASSENT,
IN_PROGRESS,
COMPLETED,

View file

@ -1,10 +1,7 @@
package com.tangem.features.staking.impl.presentation.state
import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.extensions.*
import com.tangem.features.staking.impl.R
internal sealed class StakingNotification(val config: NotificationConfig) {
@ -50,14 +47,10 @@ internal sealed class StakingNotification(val config: NotificationConfig) {
),
) {
data class EarnRewards(
val subtitleResourceId: Int,
val currencyName: String,
val subtitleText: TextReference,
) : Warning(
title = resourceReference(R.string.staking_notification_earn_rewards_title),
subtitle = resourceReference(
subtitleResourceId,
wrappedList(currencyName),
),
subtitle = subtitleText,
)
data class Unstake(
@ -66,7 +59,13 @@ internal sealed class StakingNotification(val config: NotificationConfig) {
title = resourceReference(R.string.common_unstake),
subtitle = resourceReference(
R.string.staking_notification_unstake_text,
wrappedList(cooldownPeriodDays, cooldownPeriodDays),
wrappedList(
pluralReference(
id = R.plurals.common_days,
count = cooldownPeriodDays,
formatArgs = wrappedList(cooldownPeriodDays),
),
),
),
)

View file

@ -9,8 +9,8 @@ import com.tangem.core.ui.event.StateEvent
import com.tangem.core.ui.extensions.TextReference
import com.tangem.domain.staking.model.stakekit.PendingAction
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import com.tangem.features.staking.impl.presentation.state.events.StakingEvent
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
import kotlinx.collections.immutable.ImmutableList

View file

@ -0,0 +1,9 @@
package com.tangem.features.staking.impl.presentation.state.bottomsheet
internal enum class InfoType {
ANNUAL_PERCENTAGE_RATE,
UNBONDING_PERIOD,
REWARD_CLAIMING,
WARMUP_PERIOD,
REWARD_SCHEDULE,
}

View file

@ -3,7 +3,7 @@ package com.tangem.features.staking.impl.presentation.state.bottomsheet
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
import com.tangem.core.ui.extensions.TextReference
data class StakingInfoBottomSheetConfig(
internal data class StakingInfoBottomSheetConfig(
val title: TextReference,
val text: TextReference,
) : TangemBottomSheetConfigContent

View file

@ -3,6 +3,8 @@ package com.tangem.features.staking.impl.presentation.state.previewdata
import com.tangem.blockchain.common.Amount
import com.tangem.blockchain.common.AmountType.Coin
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.features.staking.impl.R
@ -81,8 +83,10 @@ internal object ConfirmationStatePreviewData {
footerText = "You stake \$715.11 and will be receiving ~\$35 monthly",
notifications = persistentListOf(
StakingNotification.Warning.EarnRewards(
currencyName = "Solana",
subtitleResourceId = R.string.staking_notification_earn_rewards_text_period_day,
subtitleText = resourceReference(
id = R.string.staking_notification_earn_rewards_text_period_day,
formatArgs = wrappedList("Solana"),
),
),
),
transactionDoneState = TransactionDoneState.Empty,

View file

@ -4,12 +4,12 @@ import com.tangem.domain.staking.model.stakekit.PendingAction
import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.features.staking.impl.presentation.state.BalanceState
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
import kotlinx.collections.immutable.ImmutableList
@Suppress("TooManyFunctions")
object StakingClickIntentsStub : StakingClickIntents {
internal object StakingClickIntentsStub : StakingClickIntents {
override fun onBackClick() {}

View file

@ -1,5 +1,7 @@
package com.tangem.features.staking.impl.presentation.state.transformers
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.features.staking.impl.R
@ -45,8 +47,10 @@ internal class SetConfirmationStateLoadingTransformer(
)
} else {
StakingNotification.Warning.EarnRewards(
currencyName = yield.token.name,
subtitleResourceId = getEarnRewardsPeriod(yield.metadata.rewardSchedule),
subtitleText = resourceReference(
id = getEarnRewardsPeriod(yield.metadata.rewardSchedule),
formatArgs = wrappedList(yield.token.name),
),
)
},
)

View file

@ -18,6 +18,7 @@ import com.tangem.features.staking.impl.presentation.state.StakingStates
import com.tangem.features.staking.impl.presentation.state.StakingUiState
import com.tangem.features.staking.impl.presentation.state.TransactionDoneState
import com.tangem.features.staking.impl.presentation.state.ValidatorState
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import com.tangem.features.staking.impl.presentation.state.converters.RewardsValidatorStateConverter
import com.tangem.features.staking.impl.presentation.state.converters.YieldBalancesConverter
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents

View file

@ -4,6 +4,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.features.staking.impl.R
import com.tangem.features.staking.impl.presentation.state.StakingUiState
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import com.tangem.features.staking.impl.presentation.state.bottomsheet.StakingInfoBottomSheetConfig
import com.tangem.utils.transformer.Transformer
@ -42,12 +43,4 @@ internal class ShowInfoBottomSheetStateTransformer(
),
)
}
}
enum class InfoType {
ANNUAL_PERCENTAGE_RATE,
UNBONDING_PERIOD,
REWARD_CLAIMING,
WARMUP_PERIOD,
REWARD_SCHEDULE,
}

View file

@ -8,8 +8,8 @@ import com.tangem.utils.transformer.Transformer
internal class AmountChangeStateTransformer(
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
private val yield: Yield,
private val value: String,
yield: Yield,
) : Transformer<StakingUiState> {
private val amountRequirementStateTransformer = AmountRequirementStateTransformer(

View file

@ -9,7 +9,7 @@ import com.tangem.utils.transformer.Transformer
internal class AmountMaxValueStateTransformer(
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
private val yield: Yield,
yield: Yield,
) : Transformer<StakingUiState> {
private val amountRequirementStateTransformer = AmountRequirementStateTransformer(

View file

@ -5,7 +5,7 @@ import com.tangem.domain.staking.model.stakekit.PendingAction
import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.features.staking.impl.presentation.state.BalanceState
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

View file

@ -43,6 +43,7 @@ import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
import com.tangem.features.staking.impl.navigation.InnerStakingRouter
import com.tangem.features.staking.impl.presentation.state.*
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
import com.tangem.features.staking.impl.presentation.state.events.StakingEventFactory
import com.tangem.features.staking.impl.presentation.state.transformers.*
import com.tangem.features.staking.impl.presentation.state.transformers.amount.AmountChangeStateTransformer
@ -327,7 +328,7 @@ internal class StakingViewModel @Inject constructor(
}
override fun onInitialInfoBannerClick() {
// innerRouter.openUrl(WHAT_IS_STAKING_ARTICLE_URL)
innerRouter.openUrl(WHAT_IS_STAKING_ARTICLE_URL)
}
override fun onInfoClick(infoType: InfoType) {
@ -339,7 +340,7 @@ internal class StakingViewModel @Inject constructor(
}
override fun onAmountValueChange(value: String) {
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, yield, value))
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, value, yield))
}
override fun onAmountPasteTriggerDismiss() {
@ -369,7 +370,7 @@ internal class StakingViewModel @Inject constructor(
StakingActionCommonType.PENDING_OTHER
}
stateController.update(ValidatorSelectChangeTransformer(activeStake.validator))
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, yield, activeStake.cryptoValue))
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, activeStake.cryptoValue, yield))
onNextClick(actionType, activeStake.pendingActions)
}
@ -696,7 +697,7 @@ internal class StakingViewModel @Inject constructor(
}
private companion object {
const val WHAT_IS_STAKING_ARTICLE_URL = "TODO staking"
const val WHAT_IS_STAKING_ARTICLE_URL = "https://tangem.com/en/blog/post/how-to-stake-cryptocurrency/"
const val ALLOWANCE_UPDATE_DELAY = 10_000L
const val BALANCE_UPDATE_DELAY = 11_000L
}

View file

@ -143,9 +143,14 @@ internal object TokenDetailsPreviewData {
val stakingErrorBlock = StakingBlockUM.Error(iconState)
val stakingAvailableBlock = StakingBlockUM.StakeAvailable(
interestRate = "7.38",
periodInDays = 4,
tokenSymbol = "XLM",
titleText = resourceReference(
id = R.string.token_details_staking_block_title,
formatArgs = wrappedList("3.27%"),
),
subtitleText = resourceReference(
id = R.string.staking_notification_earn_rewards_text_period_day,
formatArgs = wrappedList("Solana"),
),
iconState = iconState,
onStakeClicked = {},
)

View file

@ -21,9 +21,8 @@ internal sealed interface StakingBlockUM {
data class StakeAvailable(
val iconState: IconState,
val interestRate: String,
val periodInDays: Int,
val tokenSymbol: String,
val titleText: TextReference,
val subtitleText: TextReference,
val onStakeClicked: () -> Unit,
) : StakingBlockUM
}

View file

@ -22,6 +22,7 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDeta
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsTxHistoryTransactionStateConverter
import com.tangem.feature.tokendetails.presentation.tokendetails.state.utils.getBalance
import com.tangem.feature.tokendetails.presentation.tokendetails.state.utils.getStringResourceId
import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents
import com.tangem.features.staking.api.featuretoggles.StakingFeatureToggles
import com.tangem.features.tokendetails.impl.R
@ -191,13 +192,19 @@ internal class TokenDetailsLoadedBalanceConverter(
stakingEntryInfo: StakingEntryInfo,
iconState: IconState,
): StakingBlockUM.StakeAvailable {
val apr = BigDecimalFormatter.formatPercent(
percent = stakingEntryInfo.apr,
useAbsoluteValue = true,
)
return StakingBlockUM.StakeAvailable(
interestRate = BigDecimalFormatter.formatPercent(
percent = stakingEntryInfo.interestRate,
useAbsoluteValue = true,
titleText = resourceReference(
id = R.string.token_details_staking_block_title,
formatArgs = wrappedList(apr),
),
subtitleText = resourceReference(
id = stakingEntryInfo.rewardSchedule.getStringResourceId(),
formatArgs = wrappedList(stakingEntryInfo.tokenSymbol),
),
periodInDays = stakingEntryInfo.periodInDays,
tokenSymbol = stakingEntryInfo.tokenSymbol,
iconState = iconState,
onStakeClicked = clickIntents::onStakeBannerClick,
)

View file

@ -1,12 +1,16 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory
import arrow.core.Either
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.utils.BigDecimalFormatter
import com.tangem.domain.staking.model.StakingEntryInfo
import com.tangem.domain.staking.model.stakekit.StakingError
import com.tangem.feature.tokendetails.presentation.tokendetails.state.StakingBlockUM
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
import com.tangem.feature.tokendetails.presentation.tokendetails.state.utils.getStringResourceId
import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents
import com.tangem.features.tokendetails.impl.R
import com.tangem.utils.Provider
import com.tangem.utils.converter.Converter
@ -24,14 +28,20 @@ internal class TokenStakingStateConverter(
ifLeft = {
StakingBlockUM.Error(iconState = iconState)
},
ifRight = {
ifRight = { stakingEntryInfo ->
val apr = BigDecimalFormatter.formatPercent(
percent = stakingEntryInfo.apr,
useAbsoluteValue = true,
)
StakingBlockUM.StakeAvailable(
interestRate = BigDecimalFormatter.formatPercent(
percent = it.interestRate,
useAbsoluteValue = true,
titleText = resourceReference(
id = R.string.token_details_staking_block_title,
formatArgs = wrappedList(apr),
),
subtitleText = resourceReference(
id = stakingEntryInfo.rewardSchedule.getStringResourceId(),
formatArgs = wrappedList(stakingEntryInfo.tokenSymbol),
),
periodInDays = it.periodInDays,
tokenSymbol = it.tokenSymbol,
iconState = iconState,
onStakeClicked = clickIntents::onStakeBannerClick,
)

View file

@ -3,7 +3,7 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.utils
import com.tangem.feature.tokendetails.presentation.tokendetails.state.BalanceType
import java.math.BigDecimal
fun BigDecimal.getBalance(selectedBalanceType: BalanceType, stakingAmount: BigDecimal?): BigDecimal {
internal fun BigDecimal.getBalance(selectedBalanceType: BalanceType, stakingAmount: BigDecimal?): BigDecimal {
return if (selectedBalanceType == BalanceType.ALL && stakingAmount != null) {
this.plus(stakingAmount)
} else {

View file

@ -0,0 +1,26 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.state.utils
import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.features.tokendetails.impl.R
internal fun Yield.Metadata.RewardSchedule.getStringResourceId(): Int {
return when (this) {
Yield.Metadata.RewardSchedule.BLOCK,
Yield.Metadata.RewardSchedule.DAY,
Yield.Metadata.RewardSchedule.ERA,
Yield.Metadata.RewardSchedule.EPOCH,
-> R.string.staking_notification_earn_rewards_text_period_day
Yield.Metadata.RewardSchedule.HOUR,
-> R.string.staking_notification_earn_rewards_text_period_hour
Yield.Metadata.RewardSchedule.WEEK,
-> R.string.staking_notification_earn_rewards_text_period_week
Yield.Metadata.RewardSchedule.MONTH,
-> R.string.staking_notification_earn_rewards_text_period_month
else
-> R.string.staking_notification_earn_rewards_text_period_day
}
}

View file

@ -17,6 +17,8 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
import com.tangem.core.ui.components.RectangleShimmer
import com.tangem.core.ui.components.SecondaryButton
import com.tangem.core.ui.components.SpacerW8
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.utils.getGreyScaleColorFilter
@ -86,10 +88,7 @@ private fun StakingAvailableContent(state: StakingBlockUM.StakeAvailable, modifi
SpacerW8()
Column {
Text(
text = stringResource(
R.string.token_details_staking_block_title,
state.interestRate,
),
text = state.titleText.resolveReference(),
color = TangemTheme.colors.text.primary1,
style = TangemTheme.typography.subtitle2,
)
@ -97,11 +96,7 @@ private fun StakingAvailableContent(state: StakingBlockUM.StakeAvailable, modifi
Spacer(modifier = Modifier.size(TangemTheme.dimens.size4))
Text(
text = stringResource(
R.string.token_details_staking_block_subtitle,
state.tokenSymbol,
state.periodInDays,
),
text = state.subtitleText.resolveReference(),
color = TangemTheme.colors.text.tertiary,
style = TangemTheme.typography.body2,
)
@ -161,8 +156,9 @@ private fun StakingLoading(iconState: IconState, modifier: Modifier = Modifier)
}
SecondaryButton(
modifier = Modifier.fillMaxWidth(),
text = "Loading", // TODO staking
onClick = { /* [REDACTED_TODO_COMMENT] */ },
showProgress = true,
text = TextReference.EMPTY.resolveReference(),
onClick = { /* no-op */ },
)
}
}