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 3be7df1c1f..91d8e2b8d8 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 @@ -582,6 +582,7 @@ internal class ChildFactory @Inject constructor( analyticsSource = route.analyticsSource, analyticsAction = route.analyticsAction, nextScreen = route.nextScreen, + shouldShowBackButton = route.shouldShowBackButton, ), componentFactory = createWalletBackupComponentFactory, ) @@ -593,6 +594,7 @@ internal class ChildFactory @Inject constructor( userWalletId = route.userWalletId, source = route.source, nextScreen = route.nextScreen, + shouldShowBackButton = route.shouldShowBackButton, ), componentFactory = updateAccessCodeComponentFactory, ) 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 4854b69392..7c574717fe 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 @@ -409,6 +409,7 @@ sealed class AppRoute(val path: String) : Route { val analyticsAction: String, val isUpgradeFlow: Boolean = false, val nextScreen: AppRoute? = null, + val shouldShowBackButton: Boolean = true, ) : AppRoute(path = "/create_wallet_backup/${userWalletId.stringValue}") @Serializable @@ -416,6 +417,7 @@ sealed class AppRoute(val path: String) : Route { val userWalletId: UserWalletId, val source: String, val nextScreen: AppRoute? = null, + val shouldShowBackButton: Boolean = true, ) : AppRoute(path = "/update_access_code/${userWalletId.stringValue}") @Serializable diff --git a/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/CreateWalletBackupComponent.kt b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/CreateWalletBackupComponent.kt index 0c2bc00e51..a4cd0e88fb 100644 --- a/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/CreateWalletBackupComponent.kt +++ b/features/hot-wallet/api/src/main/kotlin/com/tangem/features/hotwallet/CreateWalletBackupComponent.kt @@ -13,6 +13,7 @@ interface CreateWalletBackupComponent : ComposableContentComponent { val analyticsSource: String, val analyticsAction: String, val nextScreen: AppRoute? = null, + val shouldShowBackButton: Boolean = true, ) interface Factory : ComponentFactory 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 index 7c7627342b..7ebac8a85d 100644 --- 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 @@ -10,6 +10,7 @@ interface UpdateAccessCodeComponent : ComposableContentComponent { val userWalletId: UserWalletId, val source: String, val nextScreen: AppRoute? = null, + val shouldShowBackButton: Boolean = true, ) interface Factory : ComponentFactory } \ No newline at end of file diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/CreateWalletBackupModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/CreateWalletBackupModel.kt index 75ba090edd..2f9245f98b 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/CreateWalletBackupModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/CreateWalletBackupModel.kt @@ -67,6 +67,11 @@ internal class CreateWalletBackupModel @Inject constructor( } } + fun isBackButtonVisible(route: CreateWalletBackupRoute): Boolean = when (route) { + is CreateWalletBackupRoute.RecoveryPhraseStart -> params.shouldShowBackButton + else -> true + } + fun onManualBackupStarted() { analyticsEventHandler.send( event = WalletSettingsAnalyticEvents.RecoveryPhraseScreen( diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/DefaultCreateWalletBackupComponent.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/DefaultCreateWalletBackupComponent.kt index 7ac2d2ca7e..3d682b9540 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/DefaultCreateWalletBackupComponent.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/DefaultCreateWalletBackupComponent.kt @@ -65,6 +65,7 @@ internal class DefaultCreateWalletBackupComponent @AssistedInject constructor( stackState = stackState, modifier = modifier, showTopBar = currentRoute !is CreateWalletBackupRoute.BackupCompleted, + showBackButton = model.isBackButtonVisible(currentRoute), onBackClick = model::onBack, ) } diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/ui/CreateWalletBackupContent.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/ui/CreateWalletBackupContent.kt index 2ec840a129..f53d781a48 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/ui/CreateWalletBackupContent.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createwalletbackup/ui/CreateWalletBackupContent.kt @@ -6,6 +6,7 @@ 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.Alignment import androidx.compose.ui.Modifier import com.arkivanov.decompose.extensions.compose.stack.Children import com.arkivanov.decompose.extensions.compose.stack.animation.slide @@ -23,6 +24,7 @@ import com.tangem.features.hotwallet.createwalletbackup.routing.CreateWalletBack internal fun CreateWalletBackupContent( stackState: ChildStack, showTopBar: Boolean, + showBackButton: Boolean, onBackClick: () -> Unit, modifier: Modifier = Modifier, ) { @@ -34,13 +36,19 @@ internal fun CreateWalletBackupContent( .systemBarsPadding(), ) { if (showTopBar) { - TangemTopAppBar( - modifier = Modifier, - startButton = TopAppBarButtonUM.Back( - onBackClicked = onBackClick, - ), - title = stringResourceSafe(id = R.string.common_backup), - ) + if (showBackButton) { + TangemTopAppBar( + modifier = Modifier, + startButton = TopAppBarButtonUM.Back(onBackClicked = onBackClick), + title = stringResourceSafe(id = R.string.common_backup), + ) + } else { + TangemTopAppBar( + modifier = Modifier, + title = stringResourceSafe(id = R.string.common_backup), + titleAlignment = Alignment.CenterHorizontally, + ) + } } Children( 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 index 790f91c922..66d8a7d7cc 100644 --- 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 @@ -55,11 +55,13 @@ internal class DefaultUpdateAccessCodeComponent @AssistedInject constructor( @Composable override fun Content(modifier: Modifier) { val stackState by innerStack.subscribeAsState() + val currentRoute = stackState.active.configuration BackHandler(onBack = model::onChildBack) SetAccessCodeContent( onBackClick = model::onChildBack, + showBackButton = model.isBackButtonVisible(currentRoute), stackState = stackState, ) } 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 index 5ff0f472db..ad6402dd3d 100644 --- 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 @@ -23,6 +23,7 @@ import com.tangem.features.hotwallet.updateaccesscode.routing.UpdateAccessCodeRo @Composable internal fun SetAccessCodeContent( onBackClick: () -> Unit, + showBackButton: Boolean, stackState: ChildStack, ) { Column( @@ -32,17 +33,17 @@ internal fun SetAccessCodeContent( .imePadding() .systemBarsPadding(), ) { - if (stackState.active.configuration is UpdateAccessCodeRoute.SetupFinished) { + if (showBackButton) { TangemTopAppBar( modifier = Modifier, title = stringResourceSafe(R.string.access_code_navtitle), - titleAlignment = Alignment.CenterHorizontally, + startButton = TopAppBarButtonUM.Back(onBackClick), ) } else { TangemTopAppBar( modifier = Modifier, title = stringResourceSafe(R.string.access_code_navtitle), - startButton = TopAppBarButtonUM.Back(onBackClick), + titleAlignment = Alignment.CenterHorizontally, ) } Children( 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 index b822a2ca71..8309b39ebb 100644 --- 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 @@ -45,6 +45,12 @@ internal class UpdateAccessCodeModel @Inject constructor( } } + fun isBackButtonVisible(route: UpdateAccessCodeRoute): Boolean = when (route) { + is UpdateAccessCodeRoute.SetAccessCode -> params.shouldShowBackButton + is UpdateAccessCodeRoute.ConfirmAccessCode -> true + is UpdateAccessCodeRoute.SetupFinished -> false + } + override fun onNewAccessCodeInput(userWalletId: UserWalletId, accessCode: String) { analyticsEventHandler.send(WalletSettingsAnalyticEvents.ReEnterAccessCodeScreen(source = params.source)) stackNavigation.push(UpdateAccessCodeRoute.ConfirmAccessCode(userWalletId, accessCode)) diff --git a/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModel.kt b/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModel.kt index ac8975a3e1..f0585fb4f5 100644 --- a/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModel.kt +++ b/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModel.kt @@ -80,14 +80,16 @@ internal class TangemPayHotWalletOnboardingModel @Inject constructor( TangemLogger.i("[TangemPay][HWO]Hot wallet created") clearAppsFlyerDeeplinkUseCase(AppsFlyerDeeplinkSource.TangemPayHotWalletOnboarding) - router.replaceCurrent( + router.replaceAll( AppRoute.CreateWalletBackup( userWalletId = userWallet.walletId, analyticsSource = AnalyticsParam.ScreensSources.TangemPayHotWalletOnboarding.value, analyticsAction = WalletSettingsAnalyticEvents.RecoveryPhraseScreenAction.Backup.value, + shouldShowBackButton = false, nextScreen = AppRoute.UpdateAccessCode( userWalletId = userWallet.walletId, source = AnalyticsParam.ScreensSources.TangemPayHotWalletOnboarding.value, + shouldShowBackButton = false, nextScreen = AppRoute.TangemPayOnboarding( mode = AppRoute.TangemPayOnboarding.Mode.FirstSetup(userWallet.walletId), ), diff --git a/features/tangempay/onboarding/impl/src/test/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModelTest.kt b/features/tangempay/onboarding/impl/src/test/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModelTest.kt index 2ba50a36c5..a2d4591f4d 100644 --- a/features/tangempay/onboarding/impl/src/test/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModelTest.kt +++ b/features/tangempay/onboarding/impl/src/test/kotlin/com/tangem/features/tangempay/hotwallet/TangemPayHotWalletOnboardingModelTest.kt @@ -82,8 +82,12 @@ internal class TangemPayHotWalletOnboardingModelTest { coVerify { clearAppsFlyerDeeplinkUseCase(AppsFlyerDeeplinkSource.TangemPayHotWalletOnboarding) } verify { - router.replaceCurrent( - match { it is AppRoute.CreateWalletBackup && it.userWalletId == testUserWalletId }, + router.replaceAll( + match { route -> + route is AppRoute.CreateWalletBackup && + route.userWalletId == testUserWalletId && + !route.shouldShowBackButton + }, ) } } @@ -102,7 +106,7 @@ internal class TangemPayHotWalletOnboardingModelTest { assertThat(model.uiState.value.isLoading).isFalse() verify { uiMessageSender.send(match { true }) } coVerify(exactly = 0) { clearAppsFlyerDeeplinkUseCase(any()) } - verify(exactly = 0) { router.replaceCurrent(any()) } + verify(exactly = 0) { router.replaceAll(*anyVararg()) } } }