Updated on 2026-08-14
This commit is contained in:
parent
2bc1fe2c8f
commit
1c71c2b112
5 changed files with 99 additions and 4 deletions
|
|
@ -83,7 +83,9 @@ internal class DefaultOnboardingEntryComponent @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun linkToInnerNavigation() {
|
||||
// stepper linking
|
||||
innerStack.observe { stack ->
|
||||
val activeChild = stack.active.instance
|
||||
if (activeChild is InnerNavigationHolder) {
|
||||
|
|
@ -99,6 +101,15 @@ internal class DefaultOnboardingEntryComponent @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
}.saveIn(innerNavigationLinkJobHolder)
|
||||
} else {
|
||||
stepperComponent.state.update {
|
||||
it.copy(
|
||||
currentStep = if (stack.active.configuration is OnboardingRoute.ManageTokens) 7 else 8,
|
||||
steps = 8,
|
||||
title = model.titleProvider.currentTitle.value,
|
||||
showProgress = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
package com.tangem.features.onboarding.v2.multiwallet.impl.child.chooseoption
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.features.onboarding.v2.impl.R
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.MultiWalletChildComponent
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.MultiWalletChildParams
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.chooseoption.model.Wallet1ChooseOptionModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.chooseoption.ui.Wallet1ChooseOption
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.model.OnboardingMultiWalletState
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class Wallet1ChooseOptionComponent(
|
||||
context: AppComponentContext,
|
||||
|
|
@ -17,6 +21,8 @@ class Wallet1ChooseOptionComponent(
|
|||
private val onNextStep: (OnboardingMultiWalletState.Step) -> Unit,
|
||||
) : AppComponentContext by context, MultiWalletChildComponent {
|
||||
|
||||
private val model: Wallet1ChooseOptionModel = getOrCreateModel(params)
|
||||
|
||||
init {
|
||||
params.innerNavigation.update {
|
||||
it.copy(
|
||||
|
|
@ -28,6 +34,12 @@ class Wallet1ChooseOptionComponent(
|
|||
params.parentParams.titleProvider.changeTitle(
|
||||
text = resourceReference(R.string.onboarding_create_wallet_header),
|
||||
)
|
||||
|
||||
componentScope.launch {
|
||||
model.returnToParentFlow.collect {
|
||||
onNextStep(OnboardingMultiWalletState.Step.Done)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
@ -36,8 +48,10 @@ class Wallet1ChooseOptionComponent(
|
|||
onBackupClick = {
|
||||
onNextStep(OnboardingMultiWalletState.Step.AddBackupDevice)
|
||||
},
|
||||
onScipClick = {
|
||||
onNextStep(OnboardingMultiWalletState.Step.Done)
|
||||
onSkipClick = remember(model) {
|
||||
{
|
||||
model.onSkipClick()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.tangem.features.onboarding.v2.multiwallet.impl.child.chooseoption.model
|
||||
|
||||
import com.tangem.core.decompose.di.ComponentScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.domain.card.repository.CardRepository
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.domain.wallets.builder.UserWalletBuilder
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.usecase.GenerateWalletNameUseCase
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.MultiWalletChildParams
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@ComponentScoped
|
||||
class Wallet1ChooseOptionModel @Inject constructor(
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
paramsContainer: ParamsContainer,
|
||||
private val generateWalletNameUseCase: GenerateWalletNameUseCase,
|
||||
private val userWalletsListManager: UserWalletsListManager,
|
||||
private val cardRepository: CardRepository,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<MultiWalletChildParams>()
|
||||
private var skipClicked = false
|
||||
val returnToParentFlow = MutableSharedFlow<Unit>()
|
||||
|
||||
fun onSkipClick() {
|
||||
// TODO show confirmation dialog
|
||||
|
||||
if (skipClicked) return
|
||||
skipClicked = true
|
||||
|
||||
modelScope.launch {
|
||||
val scanResponse = params.multiWalletState.value.currentScanResponse
|
||||
|
||||
val userWallet = createUserWallet(scanResponse)
|
||||
userWalletsListManager.save(
|
||||
userWallet = userWallet,
|
||||
canOverride = true,
|
||||
)
|
||||
|
||||
cardRepository.finishCardActivation(scanResponse.card.cardId)
|
||||
|
||||
// save user wallet for manage tokens screen
|
||||
params.multiWalletState.update {
|
||||
it.copy(resultUserWallet = userWallet)
|
||||
}
|
||||
|
||||
returnToParentFlow.emit(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun createUserWallet(scanResponse: ScanResponse): UserWallet {
|
||||
return requireNotNull(
|
||||
value = UserWalletBuilder(scanResponse, generateWalletNameUseCase).build(),
|
||||
lazyMessage = { "User wallet not created" },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import com.tangem.core.ui.res.TangemTheme
|
|||
import com.tangem.features.onboarding.v2.impl.R
|
||||
|
||||
@Composable
|
||||
fun Wallet1ChooseOption(onScipClick: () -> Unit, onBackupClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
fun Wallet1ChooseOption(onSkipClick: () -> Unit, onBackupClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
|
|
@ -61,7 +61,7 @@ fun Wallet1ChooseOption(onScipClick: () -> Unit, onBackupClick: () -> Unit, modi
|
|||
.padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
text = stringResource(R.string.onboarding_button_skip_backup),
|
||||
onClick = onScipClick,
|
||||
onClick = onSkipClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import com.tangem.features.onboarding.v2.multiwallet.api.OnboardingMultiWalletCo
|
|||
import com.tangem.features.onboarding.v2.multiwallet.impl.DefaultOnboardingMultiWalletComponent
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.accesscode.model.MultiWalletAccessCodeModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.backup.model.MultiWalletBackupModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.chooseoption.model.Wallet1ChooseOptionModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.createwallet.model.MultiWalletCreateWalletModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.finalize.model.MultiWalletFinalizeModel
|
||||
import com.tangem.features.onboarding.v2.multiwallet.impl.child.seedphrase.model.MultiWalletSeedPhraseModel
|
||||
|
|
@ -60,4 +61,9 @@ internal interface ModelModule {
|
|||
@IntoMap
|
||||
@ClassKey(MultiWalletFinalizeModel::class)
|
||||
fun provideModel6(model: MultiWalletFinalizeModel): Model
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(Wallet1ChooseOptionModel::class)
|
||||
fun provideModel7(model: Wallet1ChooseOptionModel): Model
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue