Updated on 2026-08-14
This commit is contained in:
parent
ba02ab2cd9
commit
e727b40042
14 changed files with 186 additions and 38 deletions
|
|
@ -32,6 +32,7 @@ dependencies {
|
|||
implementation(projects.domain.wallets)
|
||||
implementation(projects.domain.wallets.models)
|
||||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.settings)
|
||||
|
||||
/** Common */
|
||||
implementation(projects.common.ui)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ internal class AddExistingWalletImportComponent @AssistedInject constructor(
|
|||
}
|
||||
|
||||
interface ModelCallbacks {
|
||||
fun onBackClick()
|
||||
fun onWalletImported()
|
||||
}
|
||||
|
||||
data class Params(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.hotwallet.addexistingwallet.im.port.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.model.AddExistingWalletImportModel
|
||||
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 AddExistingWalletImportModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(AddExistingWalletImportModel::class)
|
||||
fun bindAddExistingWalletImportModel(model: AddExistingWalletImportModel): Model
|
||||
}
|
||||
|
|
@ -2,8 +2,10 @@ package com.tangem.features.hotwallet.addexistingwallet.im.port.model
|
|||
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.crypto.bip39.Mnemonic
|
||||
import com.tangem.features.hotwallet.MnemonicRepository
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.entity.AddExistingWalletImportUM
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -13,10 +15,13 @@ import javax.inject.Inject
|
|||
|
||||
@ModelScoped
|
||||
internal class AddExistingWalletImportModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val mnemonicRepository: MnemonicRepository,
|
||||
) : Model() {
|
||||
|
||||
private val params: AddExistingWalletImportComponent.Params = paramsContainer.require()
|
||||
|
||||
private val importSeedPhraseUiStateBuilder: ImportSeedPhraseUiStateBuilder
|
||||
|
||||
init {
|
||||
|
|
@ -40,5 +45,6 @@ internal class AddExistingWalletImportModel @Inject constructor(
|
|||
@Suppress("UnusedPrivateMember")
|
||||
private fun importWallet(mnemonic: Mnemonic, passphrase: String?) {
|
||||
// TODO implement importing seed phrase
|
||||
params.callbacks.onWalletImported()
|
||||
}
|
||||
}
|
||||
|
|
@ -3,30 +3,51 @@ package com.tangem.features.hotwallet.addexistingwallet.root
|
|||
import com.arkivanov.decompose.router.stack.StackNavigation
|
||||
import com.arkivanov.decompose.router.stack.pop
|
||||
import com.arkivanov.decompose.router.stack.push
|
||||
import com.arkivanov.decompose.router.stack.replaceCurrent
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.domain.settings.ShouldAskPermissionUseCase
|
||||
import com.tangem.features.hotwallet.setaccesscode.SetAccessCodeComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.root.routing.AddExistingWalletRoute
|
||||
import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent
|
||||
import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsComponent
|
||||
import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@ModelScoped
|
||||
internal class AddExistingWalletModel @Inject constructor(
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val router: Router,
|
||||
private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase,
|
||||
) : Model() {
|
||||
|
||||
val addExistingWalletStartModelCallbacks = AddExistingWalletStartModelCallbacks()
|
||||
val addExistingWalletImportModelCallbacks = AddExistingWalletImportModelCallbacks()
|
||||
val pushNotificationsComponentModelCallbacks = PushNotificationsComponentModelCallbacks()
|
||||
val manualBackupCompletedComponentModelCallbacks = ManualBackupCompletedComponentModelCallbacks()
|
||||
val accessCodeModelCallbacks = AccessCodeModelCallbacks()
|
||||
val pushNotificationsComponentModelCallbacks = PushNotificationsComponentModelCallbacks()
|
||||
val mobileWalletSetupFinishedComponentModelCallbacks = MobileWalletSetupFinishedComponentModelCallbacks()
|
||||
|
||||
val stackNavigation = StackNavigation<AddExistingWalletRoute>()
|
||||
|
||||
fun onChildBack(currentRoute: AddExistingWalletRoute) {
|
||||
when (currentRoute) {
|
||||
AddExistingWalletRoute.Import -> stackNavigation.pop()
|
||||
AddExistingWalletRoute.BackupCompleted -> Unit
|
||||
AddExistingWalletRoute.AccessCode -> stackNavigation.pop()
|
||||
AddExistingWalletRoute.PushNotifications -> Unit
|
||||
AddExistingWalletRoute.SetupFinished -> Unit
|
||||
AddExistingWalletRoute.Start -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
inner class AddExistingWalletStartModelCallbacks : AddExistingWalletStartComponent.ModelCallbacks {
|
||||
override fun onBackClick() {
|
||||
router.pop()
|
||||
|
|
@ -38,24 +59,45 @@ internal class AddExistingWalletModel @Inject constructor(
|
|||
}
|
||||
|
||||
inner class AddExistingWalletImportModelCallbacks : AddExistingWalletImportComponent.ModelCallbacks {
|
||||
override fun onBackClick() {
|
||||
stackNavigation.pop()
|
||||
override fun onWalletImported() {
|
||||
stackNavigation.replaceCurrent(AddExistingWalletRoute.BackupCompleted)
|
||||
}
|
||||
}
|
||||
|
||||
inner class PushNotificationsComponentModelCallbacks : PushNotificationsComponent.ModelCallbacks {
|
||||
override fun onResult() {
|
||||
// TODO [REDACTED_TASK_KEY]
|
||||
inner class ManualBackupCompletedComponentModelCallbacks : ManualBackupCompletedComponent.ModelCallbacks {
|
||||
override fun onContinueClick() {
|
||||
stackNavigation.push(AddExistingWalletRoute.AccessCode)
|
||||
}
|
||||
}
|
||||
|
||||
inner class AccessCodeModelCallbacks : SetAccessCodeComponent.ModelCallbacks {
|
||||
override fun onBackClick() {
|
||||
// TODO [REDACTED_TASK_KEY]
|
||||
stackNavigation.pop()
|
||||
}
|
||||
|
||||
override fun onAccessCodeSet() {
|
||||
// TODO [REDACTED_TASK_KEY]
|
||||
modelScope.launch {
|
||||
val shouldRequestPush = shouldAskPermissionUseCase(PUSH_PERMISSION)
|
||||
if (shouldRequestPush) {
|
||||
// is yet blocked by [REDACTED_TASK_KEY]
|
||||
// stackNavigation.replaceCurrent(AddExistingWalletRoute.PushNotifications)
|
||||
stackNavigation.replaceCurrent(AddExistingWalletRoute.SetupFinished)
|
||||
} else {
|
||||
stackNavigation.replaceCurrent(AddExistingWalletRoute.SetupFinished)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inner class PushNotificationsComponentModelCallbacks : PushNotificationsComponent.ModelCallbacks {
|
||||
override fun onResult() {
|
||||
stackNavigation.replaceCurrent(AddExistingWalletRoute.SetupFinished)
|
||||
}
|
||||
}
|
||||
|
||||
inner class MobileWalletSetupFinishedComponentModelCallbacks : MobileWalletSetupFinishedComponent.ModelCallbacks {
|
||||
override fun onContinueClick() {
|
||||
router.replaceAll(AppRoute.Wallet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,8 @@ internal class DefaultAddExistingWalletComponent @AssistedInject constructor(
|
|||
if (isEmptyStack) {
|
||||
router.pop()
|
||||
} else {
|
||||
model.stackNavigation.pop()
|
||||
val currentRoute = innerStack.value.active.configuration
|
||||
model.onChildBack(currentRoute)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ package com.tangem.features.hotwallet.addexistingwallet.root.di
|
|||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.AddExistingWalletComponent
|
||||
import com.tangem.features.hotwallet.setaccesscode.SetAccessCodeModel
|
||||
import com.tangem.features.hotwallet.addexistingwallet.root.AddExistingWalletModel
|
||||
import com.tangem.features.hotwallet.addexistingwallet.root.DefaultAddExistingWalletComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartModel
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.model.AddExistingWalletImportModel
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
@ -17,11 +14,7 @@ import javax.inject.Singleton
|
|||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object AddExistingWalletModule
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal interface AddExistingWalletModuleBinds {
|
||||
internal interface AddExistingWalletModule {
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
|
|
@ -33,19 +26,4 @@ internal interface AddExistingWalletModuleBinds {
|
|||
@IntoMap
|
||||
@ClassKey(AddExistingWalletModel::class)
|
||||
fun bindAddExistingWalletModel(model: AddExistingWalletModel): Model
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(AddExistingWalletStartModel::class)
|
||||
fun bindAddExistingWalletStartModel(model: AddExistingWalletStartModel): Model
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(AddExistingWalletImportModel::class)
|
||||
fun bindAddExistingWalletImportModel(model: AddExistingWalletImportModel): Model
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(SetAccessCodeModel::class)
|
||||
fun bindAccessCodeModel(model: SetAccessCodeModel): Model
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ import com.tangem.features.hotwallet.setaccesscode.SetAccessCodeComponent
|
|||
import com.tangem.features.hotwallet.addexistingwallet.root.AddExistingWalletModel
|
||||
import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartComponent
|
||||
import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent
|
||||
import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedComponent
|
||||
import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedComponent
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsComponent
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -31,10 +33,10 @@ internal class AddExistingWalletChildFactory @Inject constructor(
|
|||
callbacks = model.addExistingWalletImportModelCallbacks,
|
||||
),
|
||||
)
|
||||
is AddExistingWalletRoute.PushNotifications -> pushNotificationsComponent.create(
|
||||
is AddExistingWalletRoute.BackupCompleted -> ManualBackupCompletedComponent(
|
||||
context = childContext,
|
||||
params = PushNotificationsComponent.Params.Callbacks(
|
||||
callbacks = model.pushNotificationsComponentModelCallbacks,
|
||||
params = ManualBackupCompletedComponent.Params(
|
||||
callbacks = model.manualBackupCompletedComponentModelCallbacks,
|
||||
),
|
||||
)
|
||||
is AddExistingWalletRoute.AccessCode -> SetAccessCodeComponent(
|
||||
|
|
@ -43,6 +45,18 @@ internal class AddExistingWalletChildFactory @Inject constructor(
|
|||
callbacks = model.accessCodeModelCallbacks,
|
||||
),
|
||||
)
|
||||
is AddExistingWalletRoute.PushNotifications -> pushNotificationsComponent.create(
|
||||
context = childContext,
|
||||
params = PushNotificationsComponent.Params.Callbacks(
|
||||
callbacks = model.pushNotificationsComponentModelCallbacks,
|
||||
),
|
||||
)
|
||||
AddExistingWalletRoute.SetupFinished -> MobileWalletSetupFinishedComponent(
|
||||
context = childContext,
|
||||
params = MobileWalletSetupFinishedComponent.Params(
|
||||
callbacks = model.mobileWalletSetupFinishedComponentModelCallbacks,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,14 @@ internal sealed class AddExistingWalletRoute : Route {
|
|||
object Import : AddExistingWalletRoute()
|
||||
|
||||
@Serializable
|
||||
object PushNotifications : AddExistingWalletRoute()
|
||||
object BackupCompleted : AddExistingWalletRoute()
|
||||
|
||||
@Serializable
|
||||
object AccessCode : AddExistingWalletRoute()
|
||||
|
||||
@Serializable
|
||||
object PushNotifications : AddExistingWalletRoute()
|
||||
|
||||
@Serializable
|
||||
object SetupFinished : AddExistingWalletRoute()
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.hotwallet.addexistingwallet.start.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.addexistingwallet.start.AddExistingWalletStartModel
|
||||
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 AddExistingWalletStartModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(AddExistingWalletStartModel::class)
|
||||
fun bindAddExistingWalletStartModel(model: AddExistingWalletStartModel): Model
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import dagger.multibindings.IntoMap
|
|||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal interface CreateMobileWalletModuleBinds {
|
||||
internal interface CreateMobileWalletModule {
|
||||
|
||||
@Binds
|
||||
fun bindCreateMobileWalletComponentFactory(
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.hotwallet.manualbackup.completed.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.manualbackup.completed.ManualBackupCompletedModel
|
||||
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 ManualBackupCompletedModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(ManualBackupCompletedModel::class)
|
||||
fun bindManualBackupCompletedModel(model: ManualBackupCompletedModel): Model
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.hotwallet.setaccesscode.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.setaccesscode.SetAccessCodeModel
|
||||
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 SetAccessCodeModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(SetAccessCodeModel::class)
|
||||
fun bindSetAccessCodeModel(model: SetAccessCodeModel): Model
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.hotwallet.setupfinished.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.hotwallet.setupfinished.MobileWalletSetupFinishedModel
|
||||
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 MobileWalletSetupFinishedModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(MobileWalletSetupFinishedModel::class)
|
||||
fun bindMobileWalletSetupFinishedModel(model: MobileWalletSetupFinishedModel): Model
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue