Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all factor sources screens #1303

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.babylon.wallet.android.domain.usecases.factorsources

import com.radixdlt.sargon.FactorSource
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapConcat
import rdx.works.profile.domain.GetProfileUseCase
import javax.inject.Inject

class GetFactorSourcesOfTypeUseCase @Inject constructor(
val getProfileUseCase: GetProfileUseCase
) {

@OptIn(ExperimentalCoroutinesApi::class)
inline operator fun <reified T : FactorSource> invoke(): Flow<T> {
return getProfileUseCase.flow
.flatMapConcat { profile ->
profile.factorSources.asFlow()
}
.filterIsInstance<T>()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.babylon.wallet.android.domain.model.Selectable
import com.babylon.wallet.android.presentation.common.UiMessage
import com.babylon.wallet.android.presentation.dialogs.info.GlossaryItem
import com.babylon.wallet.android.presentation.settings.linkedconnectors.AddLinkConnectorViewModel
import com.babylon.wallet.android.presentation.settings.securitycenter.ledgerhardwarewallets.AddLedgerDeviceViewModel
import com.babylon.wallet.android.presentation.settings.securitycenter.ledgerhardwarewallets.ShowLinkConnectorPromptState
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.ledgerdevice.AddLedgerDeviceViewModel
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.ledgerdevice.ShowLinkConnectorPromptState
import com.babylon.wallet.android.presentation.ui.composables.AddLedgerDeviceScreen
import com.babylon.wallet.android.presentation.ui.composables.AddLinkConnectorScreen
import com.babylon.wallet.android.presentation.ui.composables.BackIconType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.babylon.wallet.android.presentation.common.OneOffEventHandlerImpl
import com.babylon.wallet.android.presentation.common.StateViewModel
import com.babylon.wallet.android.presentation.common.UiMessage
import com.babylon.wallet.android.presentation.common.UiState
import com.babylon.wallet.android.presentation.settings.securitycenter.ledgerhardwarewallets.ShowLinkConnectorPromptState
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.ledgerdevice.ShowLinkConnectorPromptState
import com.babylon.wallet.android.utils.AppEvent
import com.babylon.wallet.android.utils.AppEventBus
import com.radixdlt.sargon.FactorSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ enum class GlossaryItem {
possibledappcalls,
securityshields,
buildingshield,
emergencyFallback,
biometricsPIN, // TODO pending the right glossary item
emergencyFallback
arculus, // TODO pending the right glossary item
ledgerNano, // TODO pending the right glossary item
passwords, // TODO pending the right glossary item
offDeviceMnemonic, // TODO pending the right glossary item
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ private fun GlossaryItem.resolveTextFromGlossaryItem() = when (this) {
GlossaryItem.securityshields -> stringResource(id = R.string.infoLink_glossary_securityshields)
GlossaryItem.buildingshield -> stringResource(id = R.string.infoLink_glossary_buildingshield)
GlossaryItem.biometricsPIN -> stringResource(id = R.string.infoLink_glossary_biometricspin)
GlossaryItem.arculus -> stringResource(id = R.string.infoLink_glossary_arculus)
GlossaryItem.ledgerNano -> stringResource(id = R.string.infoLink_glossary_ledgernano)
GlossaryItem.passwords -> stringResource(id = R.string.infoLink_glossary_passwords)
GlossaryItem.offDeviceMnemonic -> stringResource(id = R.string.infoLink_glossary_passphrases)
GlossaryItem.emergencyFallback -> "" // TODO crowdin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ sealed interface SettingsItem {
data object LedgerNano : SecurityFactorsSettingsItem
data object ArculusCard : SecurityFactorsSettingsItem
data object Password : SecurityFactorsSettingsItem
data object Passphrase : SecurityFactorsSettingsItem
data object OffDeviceMnemonic : SecurityFactorsSettingsItem

@StringRes
fun titleRes(): Int {
return when (this) {
is BiometricsPin -> R.string.factorSources_card_deviceTitle
LedgerNano -> R.string.factorSources_card_ledgerTitle
ArculusCard -> R.string.factorSources_card_arculusCardTitle
Passphrase -> R.string.factorSources_card_passphraseTitle
OffDeviceMnemonic -> R.string.factorSources_card_passphraseTitle
Password -> R.string.factorSources_card_passwordTitle
}
}
Expand All @@ -108,7 +108,7 @@ sealed interface SettingsItem {
is BiometricsPin -> R.string.factorSources_card_deviceDescription
LedgerNano -> R.string.factorSources_card_ledgerDescription
ArculusCard -> R.string.factorSources_card_arculusCardDescription
Passphrase -> R.string.factorSources_card_passphraseDescription
OffDeviceMnemonic -> R.string.factorSources_card_passphraseDescription
Password -> R.string.factorSources_card_passwordDescription
}
}
Expand All @@ -120,7 +120,7 @@ sealed interface SettingsItem {
LedgerNano -> DSR.ic_ledger_nano
ArculusCard -> DSR.ic_arculus_card
Password -> DSR.ic_password
Passphrase -> DSR.ic_passphrase
OffDeviceMnemonic -> DSR.ic_passphrase
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import com.babylon.wallet.android.presentation.onboarding.restore.mnemonics.Rest
import com.babylon.wallet.android.presentation.onboarding.restore.mnemonics.restoreMnemonics
import com.babylon.wallet.android.presentation.settings.SettingsItem
import com.babylon.wallet.android.presentation.settings.securitycenter.backup.backupScreen
import com.babylon.wallet.android.presentation.settings.securitycenter.ledgerhardwarewallets.ledgerHardwareWalletsScreen
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.arculuscard.arculusCards
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.biometricspin.biometricsPin
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.securityFactors
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.ledgerdevice.ledgerDevices
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.offdevicemnemonic.offDeviceMnemonics
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.password.passwords
import com.babylon.wallet.android.presentation.settings.securitycenter.securityfactors.securityFactorTypes
import com.babylon.wallet.android.presentation.settings.securitycenter.securityshields.onboarding.securityShieldOnboardingScreen
import com.babylon.wallet.android.presentation.settings.securitycenter.securityshields.securityShieldsNavGraph
import com.babylon.wallet.android.presentation.settings.securitycenter.securityshields.securityShieldsScreen
Expand Down Expand Up @@ -64,7 +67,7 @@ fun NavGraphBuilder.securityCenterNavGraph(
navController.securityShieldOnboardingScreen()
},
onSecurityFactorsClick = {
navController.securityFactors()
navController.securityFactorTypes()
},
onBackupConfigurationClick = {
navController.backupScreen()
Expand All @@ -84,55 +87,68 @@ fun NavGraphBuilder.securityCenterNavGraph(
) {
navController.popBackStack()
}
securityFactors(
securityFactorTypes(
onBackClick = {
navController.popBackStack()
},
onSecurityFactorSettingItemClick = { item ->
onSecurityFactorTypeClick = { item ->
when (item) {
is SettingsItem.SecurityFactorsSettingsItem.LedgerNano -> {
navController.ledgerHardwareWalletsScreen()
}

is SettingsItem.SecurityFactorsSettingsItem.BiometricsPin -> {
navController.biometricsPin()
}

is SettingsItem.SecurityFactorsSettingsItem.LedgerNano -> {
navController.ledgerDevices()
}

SettingsItem.SecurityFactorsSettingsItem.ArculusCard -> {
// TODO
navController.arculusCards()
}
SettingsItem.SecurityFactorsSettingsItem.Passphrase -> {
// TODO
SettingsItem.SecurityFactorsSettingsItem.OffDeviceMnemonic -> {
navController.offDeviceMnemonics()
}
SettingsItem.SecurityFactorsSettingsItem.Password -> {
// TODO
navController.passwords()
}
}
}
)
biometricsPin(
onBackClick = { navController.popBackStack() },
onNavigateToDeviceFactorSourceDetails = {}, // TODO next task
onNavigateToDeviceFactorSourceDetails = { }, // TODO next task
onNavigateToAddBiometricPin = { }, // TODO next task
onInfoClick = { glossaryItem ->
navController.infoDialog(glossaryItem)
}
onInfoClick = { glossaryItem -> navController.infoDialog(glossaryItem) },
onBackClick = { navController.popBackStack() }
)
seedPhrases(
ledgerDevices(
onNavigateToLedgerFactorSourceDetails = { }, // TODO next task
onInfoClick = { glossaryItem -> navController.infoDialog(glossaryItem) },
onBackClick = { navController.navigateUp() }
)
arculusCards(
onNavigateToArculusFactorSourceDetails = { }, // TODO next task
onNavigateToAddArculusCard = { },
onInfoClick = { glossaryItem -> navController.infoDialog(glossaryItem) },
onBackClick = { navController.navigateUp() }
)
offDeviceMnemonics(
onNavigateToOffDeviceMnemonicFactorSourceDetails = { }, // TODO next task
onNavigateToOffDeviceAddMnemonic = { },
onInfoClick = { glossaryItem -> navController.infoDialog(glossaryItem) },
onBackClick = { navController.navigateUp() }
)
passwords(
onNavigateToPasswordFactorSourceDetails = { }, // TODO next task
onNavigateToAddPassword = { },
onInfoClick = { glossaryItem -> navController.infoDialog(glossaryItem) },
onBackClick = { navController.navigateUp() }
)
seedPhrases( // TODO remove it later
onBackClick = { navController.popBackStack() },
onNavigateToRecoverMnemonic = {
navController.restoreMnemonics(args = RestoreMnemonicsArgs(requestSource = RestoreMnemonicsRequestSource.Settings))
},
onNavigateToSeedPhrase = { navController.revealSeedPhrase(it) }
)
ledgerHardwareWalletsScreen(
onInfoClick = { glossaryItem ->
navController.infoDialog(glossaryItem)
},
onBackClick = {
navController.navigateUp()
}
)
securityShieldsNavGraph(navController)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.babylon.wallet.android.presentation.settings.SettingsItem

private const val ROUTE_SECURITY_FACTORS_SCREEN = "settings_security_factors_screen"
private const val ROUTE_SECURITY_FACTOR_TYPES_SCREEN = "settings_security_factor_types_screen"

fun NavController.securityFactors() {
navigate(ROUTE_SECURITY_FACTORS_SCREEN) {
fun NavController.securityFactorTypes() {
navigate(ROUTE_SECURITY_FACTOR_TYPES_SCREEN) {
launchSingleTop = true
}
}

fun NavGraphBuilder.securityFactors(
fun NavGraphBuilder.securityFactorTypes(
onBackClick: () -> Unit,
onSecurityFactorSettingItemClick: (SettingsItem.SecurityFactorsSettingsItem) -> Unit
onSecurityFactorTypeClick: (SettingsItem.SecurityFactorsSettingsItem) -> Unit
) {
composable(
route = ROUTE_SECURITY_FACTORS_SCREEN,
route = ROUTE_SECURITY_FACTOR_TYPES_SCREEN,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
Expand All @@ -36,10 +36,10 @@ fun NavGraphBuilder.securityFactors(
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
}
) {
SecurityFactorsScreen(
SecurityFactorTypesScreen(
viewModel = hiltViewModel(),
onBackClick = onBackClick,
onSecurityFactorSettingItemClick = onSecurityFactorSettingItemClick
onSecurityFactorTypeClick = onSecurityFactorTypeClick
)
}
}
Loading
Loading