Updated on 2026-08-14

This commit is contained in:
Tangem 2021-10-28 01:53:25 +03:00
parent b96179be53
commit f94f78eb48
7 changed files with 28 additions and 11 deletions

View file

@ -13,10 +13,10 @@ fun Blockchain.isNoAccountError(exception: Throwable): Boolean {
}
}
fun Blockchain.amountToCreateAccount(token: Token? = null): Double? {
fun Blockchain.amountToCreateAccount(token: Token? = null): BigDecimal? {
return when (this) {
Blockchain.Stellar -> if (token?.symbol == NODL) 1.5 else 1.toDouble()
Blockchain.XRP -> 10.toDouble()
Blockchain.Stellar -> if (token?.symbol == NODL) BigDecimal(1.5) else BigDecimal.ZERO
Blockchain.XRP -> BigDecimal(10)
else -> null
}
}

View file

@ -15,7 +15,6 @@ import com.tangem.tangem_sdk_new.extensions.fadeIn
import com.tangem.tangem_sdk_new.extensions.fadeOut
import com.tangem.tap.common.extensions.getDrawableCompat
import com.tangem.tap.common.extensions.stripZeroPlainString
import com.tangem.tap.common.postUi
import com.tangem.tap.common.redux.navigation.ShareElement
import com.tangem.tap.common.toggleWidget.RefreshBalanceWidget
import com.tangem.tap.common.transitions.InternalNoteLayoutTransition
@ -137,14 +136,22 @@ class OnboardingNoteFragment : BaseOnboardingFragment<OnboardingNoteState>() {
}
tv_header.setText(R.string.onboarding_top_up_header)
tv_body.setText(R.string.onboarding_top_up_body)
if (state.balanceNonCriticalError == null) {
tv_body.setText(R.string.onboarding_top_up_body)
} else {
state.walletBalance.amountToCreateAccount?.let { amount ->
val tvBodyMessage = getString(
R.string.onboarding_top_up_body_no_account_error,
amount, state.walletBalance.currency.currencySymbol
)
tv_body.text = tvBodyMessage
}
}
btnRefreshBalanceWidget.changeState(state.walletBalance.state)
if (btnRefreshBalanceWidget.isShowing != true) {
postUi(300) {
btnRefreshBalanceWidget.mainView.setOnClickListener {
store.dispatch(OnboardingNoteAction.Balance.Update)
}
btnRefreshBalanceWidget.mainView.setOnClickListener {
store.dispatch(OnboardingNoteAction.Balance.Update)
}
}
imv_card_background.setBackgroundDrawable(requireContext().getDrawableCompat(R.drawable.shape_rectangle_rounded_8))

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.onboarding.products.note.redux
import com.tangem.blockchain.common.WalletManager
import com.tangem.tap.domain.TapError
import com.tangem.tap.features.onboarding.OnboardingWalletBalance
import com.tangem.tap.features.wallet.redux.Artwork
import org.rekotlin.Action
@ -26,6 +27,7 @@ sealed class OnboardingNoteAction : Action {
sealed class Balance {
object Update : OnboardingNoteAction()
data class Set(val balance: OnboardingWalletBalance) : OnboardingNoteAction()
data class SetNonCriticalError(val error: TapError?) : OnboardingNoteAction()
}
sealed class Confetti {

View file

@ -119,9 +119,11 @@ private fun handleNoteAction(action: Action, dispatch: DispatchFunction) {
val loadedBalance = onboardingManager.updateBalance(walletManager)
loadedBalance.criticalError?.let { store.dispatchErrorNotification(it) }
delay(if (isLoadedBefore) 0 else 300)
withMainContext { store.dispatch(OnboardingNoteAction.Balance.Set(loadedBalance)) }
withMainContext {
store.dispatch(OnboardingNoteAction.Balance.Set(loadedBalance))
store.dispatch(OnboardingNoteAction.Balance.SetNonCriticalError(loadedBalance.error))
}
}
}
is OnboardingNoteAction.Balance.Set -> {
if (action.balance.balanceIsToppedUp()) {

View file

@ -26,6 +26,9 @@ private fun internalReduce(action: Action, appState: AppState): OnboardingNoteSt
is OnboardingNoteAction.Balance.Set -> {
state = state.copy(walletBalance = action.balance)
}
is OnboardingNoteAction.Balance.SetNonCriticalError -> {
state = state.copy(balanceNonCriticalError = action.error)
}
is OnboardingNoteAction.SetStepOfScreen -> {
if (action.step != state.currentStep && state.steps.contains(action.step)) {
state = state.copy(currentStep = action.step)

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.onboarding.products.note.redux
import com.tangem.blockchain.common.WalletManager
import com.tangem.tap.domain.TapError
import com.tangem.tap.features.onboarding.OnboardingWalletBalance
import com.tangem.tap.features.wallet.redux.Artwork
import org.rekotlin.StateType
@ -13,6 +14,7 @@ data class OnboardingNoteState(
// UI
val cardArtwork: Artwork? = null,
val walletBalance: OnboardingWalletBalance = OnboardingWalletBalance.loading(),
val balanceNonCriticalError: TapError? = null,
val currentStep: OnboardingNoteStep = OnboardingNoteStep.None,
val steps: List<OnboardingNoteStep> = OnboardingNoteStep.values().toList(),
val showConfetti: Boolean = false,

View file

@ -181,6 +181,7 @@
<string name="onboarding_top_up_header" translatable="false">Top up your wallet</string>
<string name="onboarding_top_up_body" translatable="false">To get started, simply top up the card with any amount</string>
<string name="onboarding_top_up_body_no_account_error" translatable="false">To get started, simply top up the wallet with more than %s %s.</string>
<string name="onboarding_top_up_button_but_crypto" translatable="false">Buy crypto</string>
<string name="onboarding_top_up_button_show_wallet_address" translatable="false">Show the wallets address</string>
<string name="onboarding_dialog_wallet_address" translatable="false">Scan the address to top up your wallet</string>