-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ABW-3960-factor-instance-card' into feature/sec…
…urity-shields-onboarding
- Loading branch information
Showing
18 changed files
with
1,251 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...om/babylon/wallet/android/presentation/settings/debug/factors/SecurityFactorSamplesNav.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
...babylon/wallet/android/presentation/settings/debug/factors/SecurityFactorSamplesScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} | ||
) | ||
} | ||
} |
Oops, something went wrong.