mirror of
https://github.com/bitwarden/android.git
synced 2025-01-30 19:53:47 +03:00
PM-14644: Segmented control should be conditionally displayed for modal generator screen (#4262)
This commit is contained in:
parent
b76f7202a4
commit
27666c193e
3 changed files with 19 additions and 12 deletions
|
@ -29,6 +29,7 @@ fun BitwardenSegmentedButton(
|
||||||
options: ImmutableList<SegmentedButtonState>,
|
options: ImmutableList<SegmentedButtonState>,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
if (options.isEmpty()) return
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.background(color = BitwardenTheme.colorScheme.background.secondary)
|
.background(color = BitwardenTheme.colorScheme.background.secondary)
|
||||||
|
|
|
@ -202,16 +202,14 @@ fun GeneratorScreen(
|
||||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
Column(modifier = Modifier.padding(innerPadding)) {
|
Column(modifier = Modifier.padding(innerPadding)) {
|
||||||
if (state.generatorMode == GeneratorMode.Default) {
|
MainStateOptionsItem(
|
||||||
MainStateOptionsItem(
|
selectedType = state.selectedType,
|
||||||
selectedType = state.selectedType,
|
passcodePolicyOverride = state.passcodePolicyOverride,
|
||||||
passcodePolicyOverride = state.passcodePolicyOverride,
|
possibleMainStates = state.typeOptions.toImmutableList(),
|
||||||
possibleMainStates = state.typeOptions.toImmutableList(),
|
onMainStateOptionClicked = onMainStateOptionClicked,
|
||||||
onMainStateOptionClicked = onMainStateOptionClicked,
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.scrolledContainerBottomDivider(topAppBarScrollBehavior = scrollBehavior),
|
||||||
.scrolledContainerBottomDivider(topAppBarScrollBehavior = scrollBehavior),
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
ScrollContent(
|
ScrollContent(
|
||||||
state = state,
|
state = state,
|
||||||
onRegenerateClick = onRegenerateClick,
|
onRegenerateClick = onRegenerateClick,
|
||||||
|
|
|
@ -53,6 +53,7 @@ import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.collections.filter
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
private const val KEY_STATE = "state"
|
private const val KEY_STATE = "state"
|
||||||
|
@ -1726,10 +1727,17 @@ data class GeneratorState(
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a list of available main types for the generator.
|
* Provides a list of available main types for the generator based on the [GeneratorMode].
|
||||||
*/
|
*/
|
||||||
val typeOptions: List<MainTypeOption>
|
val typeOptions: List<MainTypeOption>
|
||||||
get() = MainTypeOption.entries.toList()
|
get() = when (generatorMode) {
|
||||||
|
GeneratorMode.Default -> MainTypeOption.entries.toList()
|
||||||
|
GeneratorMode.Modal.Password -> MainTypeOption
|
||||||
|
.entries
|
||||||
|
.filter { it != MainTypeOption.USERNAME }
|
||||||
|
|
||||||
|
is GeneratorMode.Modal.Username -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing the main type options for the generator, such as PASSWORD PASSPHRASE, and
|
* Enum representing the main type options for the generator, such as PASSWORD PASSPHRASE, and
|
||||||
|
|
Loading…
Add table
Reference in a new issue