Updated on 2026-08-14

This commit is contained in:
Tangem 2020-12-02 17:09:28 +03:00
parent db314577a0
commit 86c103c40b
10 changed files with 50 additions and 15 deletions

View file

@ -18,6 +18,7 @@ sealed class DetailsAction : Action {
val card: Card,
val scanNoteResponse: ScanNoteResponse,
val wallet: Wallet?,
val isCreatingTwinWalletAllowed: Boolean?,
val fiatCurrencyName: FiatCurrencyName,
val fiatCurrencies: List<FiatCurrencyName>? = null,
) : DetailsAction()

View file

@ -10,7 +10,6 @@ import com.tangem.tap.domain.TwinsHelper
import com.tangem.tap.domain.extensions.toSendableAmounts
import com.tangem.tap.features.details.redux.twins.CreateTwinWalletReducer
import com.tangem.tap.features.details.redux.twins.CreateTwinWalletState
import com.tangem.wallet.BuildConfig
import org.rekotlin.Action
import java.util.*
@ -62,7 +61,7 @@ private fun handlePrepareScreen(action: DetailsAction.PrepareScreen, state: Deta
twinCardNumber = TwinsHelper.getTwinCardNumber(action.card.cardId),
createTwinWallet = null,
showAlert = false,
allowRecreatingWallet = BuildConfig.DEBUG
allowRecreatingWallet = action.isCreatingTwinWalletAllowed
)
} else {
null

View file

@ -94,11 +94,14 @@ sealed class WalletAction : Action {
data class TopUp(val context: Context, val toolbarColor: Int) : TopUpAction()
}
data class ChangeSelectedAddress(val type: AddressType): WalletAction()
data class ChangeSelectedAddress(val type: AddressType) : WalletAction()
sealed class TwinsAction : WalletAction() {
object ShowOnboarding : TwinsAction()
object SetOnboardingShown : TwinsAction()
data class SetTwinCard(val secondCardId: String, val number: TwinCardNumber) : TwinsAction()
data class SetTwinCard(
val secondCardId: String, val number: TwinCardNumber,
val isCreatingTwinCardsAllowed: Boolean
) : TwinsAction()
}
}

View file

@ -34,12 +34,17 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
when (action) {
is WalletAction.ResetState -> newState = WalletState()
is WalletAction.EmptyWallet -> newState = newState.copy(
state = ProgressState.Done,
currencyData = BalanceWidgetData(BalanceStatus.EmptyCard),
mainButton = WalletMainButton.CreateWalletButton(true),
topUpState = TopUpState(false)
)
is WalletAction.EmptyWallet -> {
val creatingWalletAllowed = !(newState.twinCardsState != null &&
newState.twinCardsState?.isCreatingTwinCardsAllowed != true)
newState = newState.copy(
state = ProgressState.Done,
currencyData = BalanceWidgetData(BalanceStatus.EmptyCard),
mainButton = WalletMainButton.CreateWalletButton(creatingWalletAllowed),
topUpState = TopUpState(false)
)
}
is WalletAction.LoadData.Failure -> {
when (action.error) {
is TapError.NoInternetConnection -> {
@ -224,13 +229,18 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
twinCardsState = TwinCardsState(
secondCardId = action.secondCardId,
cardNumber = action.number,
newState.twinCardsState?.showTwinOnboarding ?: false)
showTwinOnboarding = newState.twinCardsState?.showTwinOnboarding
?: false,
isCreatingTwinCardsAllowed = action.isCreatingTwinCardsAllowed
)
)
}
is WalletAction.TwinsAction.ShowOnboarding -> {
newState = newState.copy(
twinCardsState = newState.twinCardsState?.copy(showTwinOnboarding = true)
?: TwinCardsState(null, null, true)
?: TwinCardsState(null, null,
showTwinOnboarding = true,
isCreatingTwinCardsAllowed = false)
)
}
is WalletAction.TwinsAction.SetOnboardingShown -> {

View file

@ -105,5 +105,6 @@ data class TopUpState(
data class TwinCardsState(
val secondCardId: String?,
val cardNumber: TwinCardNumber?,
val showTwinOnboarding: Boolean
val showTwinOnboarding: Boolean,
val isCreatingTwinCardsAllowed: Boolean
)

View file

@ -101,7 +101,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
}
tv_twin_card_number.text = getString(R.string.wallet_twins_chip_format, number)
}
if (state.twinCardsState?.cardNumber == null){
if (state.twinCardsState?.cardNumber == null) {
tv_twin_card_number.hide()
iv_twin_card.hide()
}
@ -308,6 +308,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
store.dispatch(DetailsAction.PrepareScreen(
scanNoteResponse.card, scanNoteResponse,
store.state.walletState.wallet,
store.state.globalState.configManager?.config?.isCreatingTwinCardsAllowed,
store.state.globalState.appCurrency
))
store.dispatch(NavigationAction.NavigateTo(AppScreen.Details))