Skip to content

Commit

Permalink
Merge branch 'feature/ABW-3960-factor-instance-card' into feature/sec…
Browse files Browse the repository at this point in the history
…urity-shields-onboarding
  • Loading branch information
sergiupuhalschi-rdx committed Dec 6, 2024
2 parents 5b9b3eb + 7ed25b1 commit b9dab89
Show file tree
Hide file tree
Showing 18 changed files with 1,251 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,15 @@ sealed interface SettingsItem {

data object InspectCloudBackups : DebugSettingsItem

data object SecurityFactorSamples : DebugSettingsItem

@StringRes
fun titleRes(): Int {
return when (this) {
InspectProfile -> R.string.settings_debugSettings_inspectProfile
LinkConnectionStatusIndicator -> R.string.linkedConnectors_title
InspectCloudBackups -> R.string.settings_debugSettings_inspectCloudBackups
SecurityFactorSamples -> R.string.settings_debugSettings_securityFactorSamples
}
}

Expand All @@ -222,14 +225,16 @@ sealed interface SettingsItem {
InspectProfile -> com.babylon.wallet.android.designsystem.R.drawable.ic_personas
LinkConnectionStatusIndicator -> com.babylon.wallet.android.designsystem.R.drawable.ic_desktop_connection
InspectCloudBackups -> com.babylon.wallet.android.designsystem.R.drawable.ic_backup
SecurityFactorSamples -> com.babylon.wallet.android.designsystem.R.drawable.ic_security
}
}

companion object {
fun values() = setOf(
InspectProfile,
LinkConnectionStatusIndicator,
InspectCloudBackups
InspectCloudBackups,
SecurityFactorSamples
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.navigation.navigation
import com.babylon.wallet.android.presentation.settings.SettingsItem
import com.babylon.wallet.android.presentation.settings.SettingsItem.DebugSettingsItem.InspectProfile
import com.babylon.wallet.android.presentation.settings.debug.backups.inspectGoogleBackups
import com.babylon.wallet.android.presentation.settings.debug.factors.securityFactorSamples
import com.babylon.wallet.android.presentation.settings.debug.profile.inspectProfile

const val ROUTE_DEBUG_SETTINGS_SCREEN = "settings_debug_settings_screen"
Expand Down Expand Up @@ -54,6 +55,7 @@ fun NavGraphBuilder.debugSettings(
InspectProfile -> navController.inspectProfile()
SettingsItem.DebugSettingsItem.LinkConnectionStatusIndicator -> {}
SettingsItem.DebugSettingsItem.InspectCloudBackups -> navController.inspectGoogleBackups()
SettingsItem.DebugSettingsItem.SecurityFactorSamples -> navController.securityFactorSamples()
}
}
)
Expand All @@ -68,5 +70,10 @@ fun NavGraphBuilder.debugSettings(
navController.popBackStack()
}
)
securityFactorSamples(
onBackClick = {
navController.popBackStack()
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.babylon.wallet.android.presentation.settings.debug.factors

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable

private const val ROUTE = "security_factor_samples"

fun NavController.securityFactorSamples() {
navigate(route = ROUTE)
}

fun NavGraphBuilder.securityFactorSamples(
onBackClick: () -> Unit
) {
composable(
route = ROUTE,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
exitTransition = {
ExitTransition.None
},
popEnterTransition = {
EnterTransition.None
},
popExitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
}
) {
SecurityFactorSamplesScreen(
viewModel = hiltViewModel(),
onBackClick = onBackClick
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.babylon.wallet.android.presentation.settings.debug.factors

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.babylon.wallet.android.R
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.presentation.ui.RadixWalletPreviewTheme
import com.babylon.wallet.android.presentation.ui.composables.RadixCenteredTopAppBar
import com.babylon.wallet.android.presentation.ui.composables.card.FactorSourceCardView
import com.babylon.wallet.android.presentation.ui.composables.card.RemovableFactorSourceCard
import com.babylon.wallet.android.presentation.ui.composables.card.SelectableMultiChoiceFactorSourceCard
import com.babylon.wallet.android.presentation.ui.composables.card.SelectableSingleChoiceFactorSourceCard
import com.babylon.wallet.android.presentation.ui.composables.statusBarsAndBanner
import com.babylon.wallet.android.presentation.ui.model.factors.FactorSourceCard

@Composable
fun SecurityFactorSamplesScreen(
viewModel: SecurityFactorSamplesViewModel,
onBackClick: () -> Unit
) {
val state = viewModel.state.collectAsState().value

SecurityFactorSamplesContent(
state = state,
onBackClick = onBackClick,
onSelect = viewModel::onSelect,
onCheckedChange = viewModel::onCheckedChange,
onRemoveClick = viewModel::onRemoveClick
)
}

@Composable
private fun SecurityFactorSamplesContent(
modifier: Modifier = Modifier,
state: SecurityFactorSamplesViewModel.State,
onBackClick: () -> Unit,
onSelect: (FactorSourceCard) -> Unit,
onCheckedChange: (FactorSourceCard, Boolean) -> Unit,
onRemoveClick: (FactorSourceCard) -> Unit
) {
Scaffold(
modifier = modifier.fillMaxSize(),
topBar = {
RadixCenteredTopAppBar(
title = stringResource(R.string.securityFactors_title),
onBackClick = onBackClick,
windowInsets = WindowInsets.statusBarsAndBanner
)
},
containerColor = RadixTheme.colors.gray5
) { padding ->
LazyColumn(
modifier = Modifier.padding(padding),
contentPadding = PaddingValues(RadixTheme.dimensions.paddingDefault),
verticalArrangement = Arrangement.spacedBy(RadixTheme.dimensions.paddingMedium)
) {
items(state.displayOnlyItems) {
FactorSourceCardView(
item = it
)
}

items(state.singleChoiceItems) {
SelectableSingleChoiceFactorSourceCard(
item = it.item,
isSelected = it.isSelected,
onSelect = onSelect
)
}

items(state.multiChoiceItems) {
SelectableMultiChoiceFactorSourceCard(
item = it.item,
isChecked = it.isSelected,
onCheckedChange = onCheckedChange
)
}

items(state.removableItems) {
RemovableFactorSourceCard(
item = it,
onRemoveClick = onRemoveClick
)
}
}
}
}

@Composable
@Preview
private fun SecurityFactorSamplesPreview() {
RadixWalletPreviewTheme {
SecurityFactorSamplesContent(
state = SecurityFactorSamplesViewModel.State(),
onBackClick = {},
onSelect = {},
onCheckedChange = { _, _ -> },
onRemoveClick = {}
)
}
}
Loading

0 comments on commit b9dab89

Please sign in to comment.