From 0617e32475456bc1cb20a310d56e219167e4e340 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 13 Aug 2025 12:43:56 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../tangem/tap/routing/utils/ChildFactory.kt | 11 ++++ .../com/tangem/common/routing/AppRoute.kt | 5 ++ .../hotwallet/UpdateAccessCodeComponent.kt | 10 ++++ .../AccessCodeComponent.kt | 4 +- .../AccessCodeModel.kt | 4 +- .../hotwallet/accesscode/Constants.kt | 3 + .../di/AccessCodeModule.kt | 4 +- .../entity/AccessCodeUM.kt | 4 +- .../ui/AccessCode.kt | 4 +- .../HotAccessCodeRequestModel.kt | 2 +- .../entry/AddExistingWalletModel.kt | 2 +- .../routing/AddExistingWalletChildFactory.kt | 2 +- .../hotwallet/setaccesscode/Constants.kt | 3 - .../DefaultUpdateAccessCodeComponent.kt | 60 +++++++++++++++++++ .../UpdateAccessCodeContent.kt | 47 +++++++++++++++ .../updateaccesscode/UpdateAccessCodeModel.kt | 45 ++++++++++++++ .../di/UpdateAccessCodeModule.kt | 27 +++++++++ .../routing/UpdateAccessCodeChildFactory.kt | 38 ++++++++++++ .../routing/UpdateAccessCodeRoute.kt | 14 +++++ .../entry/WalletActivationModel.kt | 2 +- .../routing/WalletActivationChildFactory.kt | 2 +- .../model/WalletSettingsModel.kt | 2 +- 22 files changed, 276 insertions(+), 19 deletions(-) create mode 100644 features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/UpdateAccessCodeComponent.kt rename features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/{setaccesscode => accesscode}/AccessCodeComponent.kt (93%) rename features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/{setaccesscode => accesscode}/AccessCodeModel.kt (96%) create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/Constants.kt rename features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/{setaccesscode => accesscode}/di/AccessCodeModule.kt (78%) rename features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/{setaccesscode => accesscode}/entity/AccessCodeUM.kt (69%) rename features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/{setaccesscode => accesscode}/ui/AccessCode.kt (97%) delete mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/Constants.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/DefaultUpdateAccessCodeComponent.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeContent.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeModel.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/di/UpdateAccessCodeModule.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeChildFactory.kt create mode 100644 features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeRoute.kt diff --git a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt index ba64c1cfc6..8c05bbd7b2 100644 --- a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt +++ b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt @@ -17,6 +17,7 @@ import com.tangem.features.hotwallet.AddExistingWalletComponent import com.tangem.features.hotwallet.CreateMobileWalletComponent import com.tangem.features.hotwallet.WalletActivationComponent import com.tangem.features.hotwallet.WalletBackupComponent +import com.tangem.features.hotwallet.UpdateAccessCodeComponent import com.tangem.features.managetokens.component.ChooseManagedTokensComponent import com.tangem.features.managetokens.component.ManageTokensComponent import com.tangem.features.managetokens.component.ManageTokensSource @@ -95,6 +96,7 @@ internal class ChildFactory @Inject constructor( private val createMobileWalletComponentFactory: CreateMobileWalletComponent.Factory, private val addExistingWalletComponentFactory: AddExistingWalletComponent.Factory, private val walletActivationComponentFactory: WalletActivationComponent.Factory, + private val updateAccessCodeComponentFactory: UpdateAccessCodeComponent.Factory, private val sendWithSwapComponentFactory: SendWithSwapComponent.Factory, private val sendEntryPointComponentFactory: SendEntryPointComponent.Factory, private val walletConnectFeatureToggles: WalletConnectFeatureToggles, @@ -479,6 +481,15 @@ internal class ChildFactory @Inject constructor( componentFactory = walletActivationComponentFactory, ) } + is AppRoute.UpdateAccessCode -> { + createComponentChild( + context = context, + params = UpdateAccessCodeComponent.Params( + userWalletId = route.userWalletId, + ), + componentFactory = updateAccessCodeComponentFactory, + ) + } is AppRoute.SendEntryPoint -> { createComponentChild( context = context, diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt index 3b71b7518e..304f1cb956 100644 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt +++ b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt @@ -308,6 +308,11 @@ sealed class AppRoute(val path: String) : Route { val userWalletId: UserWalletId, ) : AppRoute(path = "/wallet_activation/${userWalletId.stringValue}") + @Serializable + data class UpdateAccessCode( + val userWalletId: UserWalletId, + ) : AppRoute(path = "/update_access_code/${userWalletId.stringValue}") + @Serializable data class SendEntryPoint( val userWalletId: UserWalletId, diff --git a/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/UpdateAccessCodeComponent.kt b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/UpdateAccessCodeComponent.kt new file mode 100644 index 0000000000..b2416c8d0a --- /dev/null +++ b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/UpdateAccessCodeComponent.kt @@ -0,0 +1,10 @@ +package com.tangem.features.hotwallet + +import com.tangem.core.decompose.factory.ComponentFactory +import com.tangem.core.ui.decompose.ComposableContentComponent +import com.tangem.domain.models.wallet.UserWalletId + +interface UpdateAccessCodeComponent : ComposableContentComponent { + data class Params(val userWalletId: UserWalletId) + interface Factory : ComponentFactory +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeComponent.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeComponent.kt similarity index 93% rename from features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeComponent.kt rename to features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeComponent.kt index 6cd119cdfb..5a044f85ef 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeComponent.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeComponent.kt @@ -1,4 +1,4 @@ -package com.tangem.features.hotwallet.setaccesscode +package com.tangem.features.hotwallet.accesscode import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -8,7 +8,7 @@ import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.model.getOrCreateModel import com.tangem.core.ui.decompose.ComposableContentComponent import com.tangem.core.ui.security.DisableScreenshotsDisposableEffect -import com.tangem.features.hotwallet.setaccesscode.ui.AccessCode +import com.tangem.features.hotwallet.accesscode.ui.AccessCode import com.tangem.domain.models.wallet.UserWalletId import dagger.assisted.Assisted import dagger.assisted.AssistedFactory diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeModel.kt similarity index 96% rename from features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeModel.kt rename to features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeModel.kt index e387f3e404..a7e9eec930 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/AccessCodeModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/AccessCodeModel.kt @@ -1,4 +1,4 @@ -package com.tangem.features.hotwallet.setaccesscode +package com.tangem.features.hotwallet.accesscode import androidx.compose.runtime.Stable import arrow.core.getOrElse @@ -9,7 +9,7 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.wallets.usecase.GetUserWalletUseCase import com.tangem.domain.wallets.usecase.SaveWalletUseCase -import com.tangem.features.hotwallet.setaccesscode.entity.AccessCodeUM +import com.tangem.features.hotwallet.accesscode.entity.AccessCodeUM import com.tangem.hot.sdk.TangemHotSdk import com.tangem.hot.sdk.model.HotAuth import com.tangem.hot.sdk.model.UnlockHotWallet diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/Constants.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/Constants.kt new file mode 100644 index 0000000000..ca5ecaa367 --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/Constants.kt @@ -0,0 +1,3 @@ +package com.tangem.features.hotwallet.accesscode + +const val ACCESS_CODE_LENGTH = 6 \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/di/AccessCodeModule.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/di/AccessCodeModule.kt similarity index 78% rename from features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/di/AccessCodeModule.kt rename to features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/di/AccessCodeModule.kt index c6fb7f93cc..57353dd676 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/di/AccessCodeModule.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/di/AccessCodeModule.kt @@ -1,7 +1,7 @@ -package com.tangem.features.hotwallet.setaccesscode.di +package com.tangem.features.hotwallet.accesscode.di import com.tangem.core.decompose.model.Model -import com.tangem.features.hotwallet.setaccesscode.AccessCodeModel +import com.tangem.features.hotwallet.accesscode.AccessCodeModel import dagger.Binds import dagger.Module import dagger.hilt.InstallIn diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/entity/AccessCodeUM.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/entity/AccessCodeUM.kt similarity index 69% rename from features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/entity/AccessCodeUM.kt rename to features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/entity/AccessCodeUM.kt index 9141f7f4c5..11eccc1463 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/entity/AccessCodeUM.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/entity/AccessCodeUM.kt @@ -1,6 +1,6 @@ -package com.tangem.features.hotwallet.setaccesscode.entity +package com.tangem.features.hotwallet.accesscode.entity -import com.tangem.features.hotwallet.setaccesscode.ACCESS_CODE_LENGTH +import com.tangem.features.hotwallet.accesscode.ACCESS_CODE_LENGTH internal data class AccessCodeUM( val accessCode: String, diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/ui/AccessCode.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/ui/AccessCode.kt similarity index 97% rename from features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/ui/AccessCode.kt rename to features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/ui/AccessCode.kt index 923b475395..987c94c953 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/ui/AccessCode.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscode/ui/AccessCode.kt @@ -1,4 +1,4 @@ -package com.tangem.features.hotwallet.setaccesscode.ui +package com.tangem.features.hotwallet.accesscode.ui import android.content.res.Configuration import androidx.compose.foundation.background @@ -16,7 +16,7 @@ import com.tangem.core.ui.components.fields.PinTextField import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.features.hotwallet.setaccesscode.entity.AccessCodeUM +import com.tangem.features.hotwallet.accesscode.entity.AccessCodeUM @Suppress("LongParameterList", "LongMethod") @Composable diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscoderequest/HotAccessCodeRequestModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscoderequest/HotAccessCodeRequestModel.kt index 05e2ef611b..305bd305bb 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscoderequest/HotAccessCodeRequestModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/accesscoderequest/HotAccessCodeRequestModel.kt @@ -3,7 +3,7 @@ package com.tangem.features.hotwallet.accesscoderequest import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.decompose.model.Model import com.tangem.domain.wallets.hot.HotWalletPasswordRequester -import com.tangem.features.hotwallet.setaccesscode.ACCESS_CODE_LENGTH +import com.tangem.features.hotwallet.accesscode.ACCESS_CODE_LENGTH import com.tangem.features.hotwallet.accesscoderequest.entity.HotAccessCodeRequestUM import com.tangem.hot.sdk.model.HotAuth import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt index ca924d1eb8..328e74cc8c 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt @@ -11,7 +11,7 @@ import com.tangem.features.hotwallet.addexistingwallet.entry.routing.AddExisting import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartComponent import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent -import com.tangem.features.hotwallet.setaccesscode.AccessCodeComponent +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent import com.tangem.features.hotwallet.stepper.api.HotWalletStepperComponent import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/routing/AddExistingWalletChildFactory.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/routing/AddExistingWalletChildFactory.kt index 8a25cc1176..1e0fd88f21 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/routing/AddExistingWalletChildFactory.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/routing/AddExistingWalletChildFactory.kt @@ -6,7 +6,7 @@ import com.tangem.features.hotwallet.addexistingwallet.entry.AddExistingWalletMo import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartComponent import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent -import com.tangem.features.hotwallet.setaccesscode.AccessCodeComponent +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent import com.tangem.features.pushnotifications.api.PushNotificationsComponent import com.tangem.features.pushnotifications.api.PushNotificationsParams diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/Constants.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/Constants.kt deleted file mode 100644 index 8494ba6e8b..0000000000 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/setaccesscode/Constants.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.tangem.features.hotwallet.setaccesscode - -const val ACCESS_CODE_LENGTH = 6 \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/DefaultUpdateAccessCodeComponent.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/DefaultUpdateAccessCodeComponent.kt new file mode 100644 index 0000000000..127f506d0c --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/DefaultUpdateAccessCodeComponent.kt @@ -0,0 +1,60 @@ +package com.tangem.features.hotwallet.updateaccesscode + +import androidx.activity.compose.BackHandler +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.extensions.compose.subscribeAsState +import com.arkivanov.decompose.router.stack.childStack +import com.tangem.core.decompose.context.AppComponentContext +import com.tangem.core.decompose.context.childByContext +import com.tangem.core.decompose.model.getOrCreateModel +import com.tangem.features.hotwallet.UpdateAccessCodeComponent +import com.tangem.features.hotwallet.updateaccesscode.routing.UpdateAccessCodeChildFactory +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject + +internal class DefaultUpdateAccessCodeComponent @AssistedInject constructor( + @Assisted private val appComponentContext: AppComponentContext, + @Assisted private val params: UpdateAccessCodeComponent.Params, + private val childFactory: UpdateAccessCodeChildFactory, +) : UpdateAccessCodeComponent, AppComponentContext by appComponentContext { + + private val model: UpdateAccessCodeModel = getOrCreateModel(params) + + private val innerStack = childStack( + key = "hotWalletAccessCodeInnerStack", + source = model.stackNavigation, + serializer = null, + initialConfiguration = model.startRoute, + handleBackButton = true, + childFactory = { configuration, factoryContext -> + childFactory.createChild( + route = configuration, + childContext = childByContext(factoryContext), + model = model, + ) + }, + ) + + @Composable + override fun Content(modifier: Modifier) { + val stackState by innerStack.subscribeAsState() + + BackHandler(onBack = model::onChildBack) + + SetAccessCodeContent( + onBackClick = model::onChildBack, + stackState = stackState, + ) + } + + @AssistedFactory + interface Factory : UpdateAccessCodeComponent.Factory { + override fun create( + context: AppComponentContext, + params: UpdateAccessCodeComponent.Params, + ): DefaultUpdateAccessCodeComponent + } +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeContent.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeContent.kt new file mode 100644 index 0000000000..e8f3c4a40d --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeContent.kt @@ -0,0 +1,47 @@ +package com.tangem.features.hotwallet.updateaccesscode + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.imePadding +import androidx.compose.foundation.layout.systemBarsPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.extensions.compose.stack.Children +import com.arkivanov.decompose.extensions.compose.stack.animation.slide +import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation +import com.arkivanov.decompose.router.stack.ChildStack +import com.tangem.core.ui.R +import com.tangem.core.ui.components.appbar.TangemTopAppBar +import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM +import com.tangem.core.ui.decompose.ComposableContentComponent +import com.tangem.core.ui.extensions.stringResourceSafe +import com.tangem.core.ui.res.TangemTheme +import com.tangem.features.hotwallet.updateaccesscode.routing.UpdateAccessCodeRoute + +@Composable +internal fun SetAccessCodeContent( + onBackClick: () -> Unit, + stackState: ChildStack, +) { + Column( + modifier = Modifier + .background(color = TangemTheme.colors.background.primary) + .fillMaxSize() + .imePadding() + .systemBarsPadding(), + ) { + TangemTopAppBar( + modifier = Modifier, + title = stringResourceSafe(R.string.access_code_navtitle), + startButton = TopAppBarButtonUM.Back(onBackClick), + ) + Children( + stack = stackState, + animation = stackAnimation(slide()), + modifier = Modifier.fillMaxSize(), + ) { + it.instance.Content(Modifier.fillMaxSize()) + } + } +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeModel.kt new file mode 100644 index 0000000000..19f8947793 --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/UpdateAccessCodeModel.kt @@ -0,0 +1,45 @@ +package com.tangem.features.hotwallet.updateaccesscode + +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.pop +import com.arkivanov.decompose.router.stack.push +import com.tangem.core.decompose.di.ModelScoped +import com.tangem.core.decompose.model.Model +import com.tangem.core.decompose.model.ParamsContainer +import com.tangem.core.decompose.navigation.Router +import com.tangem.domain.models.wallet.UserWalletId +import com.tangem.features.hotwallet.UpdateAccessCodeComponent +import com.tangem.features.hotwallet.updateaccesscode.routing.UpdateAccessCodeRoute +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.flow.MutableStateFlow +import javax.inject.Inject + +@ModelScoped +internal class UpdateAccessCodeModel @Inject constructor( + override val dispatchers: CoroutineDispatcherProvider, + private val router: Router, + paramsContainer: ParamsContainer, +) : Model(), AccessCodeComponent.ModelCallbacks { + + private val params = paramsContainer.require() + + val stackNavigation = StackNavigation() + val startRoute: UpdateAccessCodeRoute = UpdateAccessCodeRoute.SetAccessCode(params.userWalletId) + val currentRoute: MutableStateFlow = MutableStateFlow(startRoute) + + fun onChildBack() { + when (currentRoute.value) { + is UpdateAccessCodeRoute.SetAccessCode -> router.pop() + is UpdateAccessCodeRoute.ConfirmAccessCode -> stackNavigation.pop() + } + } + + override fun onAccessCodeSet(userWalletId: UserWalletId, accessCode: String) { + stackNavigation.push(UpdateAccessCodeRoute.ConfirmAccessCode(userWalletId, accessCode)) + } + + override fun onAccessCodeConfirmed(userWalletId: UserWalletId) { + router.pop() + } +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/di/UpdateAccessCodeModule.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/di/UpdateAccessCodeModule.kt new file mode 100644 index 0000000000..478deec433 --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/di/UpdateAccessCodeModule.kt @@ -0,0 +1,27 @@ +package com.tangem.features.hotwallet.updateaccesscode.di + +import com.tangem.core.decompose.model.Model +import com.tangem.features.hotwallet.UpdateAccessCodeComponent +import com.tangem.features.hotwallet.updateaccesscode.DefaultUpdateAccessCodeComponent +import com.tangem.features.hotwallet.updateaccesscode.UpdateAccessCodeModel +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import dagger.multibindings.ClassKey +import dagger.multibindings.IntoMap + +@Module +@InstallIn(SingletonComponent::class) +internal interface UpdateAccessCodeModule { + + @Binds + fun bindUpdateAccessCodeComponentFactory( + impl: DefaultUpdateAccessCodeComponent.Factory, + ): UpdateAccessCodeComponent.Factory + + @Binds + @IntoMap + @ClassKey(UpdateAccessCodeModel::class) + fun bindUpdateAccessCodeModel(model: UpdateAccessCodeModel): Model +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeChildFactory.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeChildFactory.kt new file mode 100644 index 0000000000..354156a4c0 --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeChildFactory.kt @@ -0,0 +1,38 @@ +package com.tangem.features.hotwallet.updateaccesscode.routing + +import com.tangem.core.decompose.context.AppComponentContext +import com.tangem.core.ui.decompose.ComposableContentComponent +import com.tangem.features.hotwallet.updateaccesscode.UpdateAccessCodeModel +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent +import javax.inject.Inject + +internal class UpdateAccessCodeChildFactory @Inject constructor( + private val accessCodeComponentFactory: AccessCodeComponent.Factory, +) { + + fun createChild( + route: UpdateAccessCodeRoute, + childContext: AppComponentContext, + model: UpdateAccessCodeModel, + ): ComposableContentComponent { + return when (route) { + is UpdateAccessCodeRoute.SetAccessCode -> accessCodeComponentFactory.create( + context = childContext, + params = AccessCodeComponent.Params( + isConfirmMode = false, + userWalletId = route.userWalletId, + callbacks = model, + ), + ) + is UpdateAccessCodeRoute.ConfirmAccessCode -> accessCodeComponentFactory.create( + context = childContext, + params = AccessCodeComponent.Params( + isConfirmMode = true, + accessCodeToConfirm = route.accessCode, + userWalletId = route.userWalletId, + callbacks = model, + ), + ) + } + } +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeRoute.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeRoute.kt new file mode 100644 index 0000000000..a414995364 --- /dev/null +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/updateaccesscode/routing/UpdateAccessCodeRoute.kt @@ -0,0 +1,14 @@ +package com.tangem.features.hotwallet.updateaccesscode.routing + +import com.tangem.core.decompose.navigation.Route +import com.tangem.domain.models.wallet.UserWalletId +import kotlinx.serialization.Serializable + +internal sealed class UpdateAccessCodeRoute : Route { + + @Serializable + data class SetAccessCode(val userWalletId: UserWalletId) : UpdateAccessCodeRoute() + + @Serializable + data class ConfirmAccessCode(val userWalletId: UserWalletId, val accessCode: String) : UpdateAccessCodeRoute() +} \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt index 3d03a96a04..f163ba6e18 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt @@ -14,7 +14,7 @@ import com.tangem.features.hotwallet.manualbackup.check.ManualBackupCheckCompone import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent import com.tangem.features.hotwallet.manualbackup.phrase.ManualBackupPhraseComponent import com.tangem.features.hotwallet.manualbackup.start.ManualBackupStartComponent -import com.tangem.features.hotwallet.setaccesscode.AccessCodeComponent +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent import com.tangem.features.hotwallet.walletactivation.entry.routing.WalletActivationRoute import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/routing/WalletActivationChildFactory.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/routing/WalletActivationChildFactory.kt index 2b93835929..59762e8fe3 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/routing/WalletActivationChildFactory.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/routing/WalletActivationChildFactory.kt @@ -6,7 +6,7 @@ import com.tangem.features.hotwallet.manualbackup.check.ManualBackupCheckCompone import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent import com.tangem.features.hotwallet.manualbackup.phrase.ManualBackupPhraseComponent import com.tangem.features.hotwallet.manualbackup.start.ManualBackupStartComponent -import com.tangem.features.hotwallet.setaccesscode.AccessCodeComponent +import com.tangem.features.hotwallet.accesscode.AccessCodeComponent import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent import com.tangem.features.hotwallet.walletactivation.entry.WalletActivationModel import com.tangem.features.pushnotifications.api.PushNotificationsComponent diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index 061c68bb82..22dd035507 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -330,6 +330,6 @@ internal class WalletSettingsModel @Inject constructor( } private fun onAccessCodeClick() { - // TODO [REDACTED_TASK_KEY] + router.push(AppRoute.UpdateAccessCode(params.userWalletId)) } } \ No newline at end of file