mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +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>,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (options.isEmpty()) return
|
||||
Box(
|
||||
modifier = modifier
|
||||
.background(color = BitwardenTheme.colorScheme.background.secondary)
|
||||
|
|
|
@ -202,16 +202,14 @@ fun GeneratorScreen(
|
|||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
) { innerPadding ->
|
||||
Column(modifier = Modifier.padding(innerPadding)) {
|
||||
if (state.generatorMode == GeneratorMode.Default) {
|
||||
MainStateOptionsItem(
|
||||
selectedType = state.selectedType,
|
||||
passcodePolicyOverride = state.passcodePolicyOverride,
|
||||
possibleMainStates = state.typeOptions.toImmutableList(),
|
||||
onMainStateOptionClicked = onMainStateOptionClicked,
|
||||
modifier = Modifier
|
||||
.scrolledContainerBottomDivider(topAppBarScrollBehavior = scrollBehavior),
|
||||
)
|
||||
}
|
||||
MainStateOptionsItem(
|
||||
selectedType = state.selectedType,
|
||||
passcodePolicyOverride = state.passcodePolicyOverride,
|
||||
possibleMainStates = state.typeOptions.toImmutableList(),
|
||||
onMainStateOptionClicked = onMainStateOptionClicked,
|
||||
modifier = Modifier
|
||||
.scrolledContainerBottomDivider(topAppBarScrollBehavior = scrollBehavior),
|
||||
)
|
||||
ScrollContent(
|
||||
state = state,
|
||||
onRegenerateClick = onRegenerateClick,
|
||||
|
|
|
@ -53,6 +53,7 @@ import kotlinx.coroutines.flow.update
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.filter
|
||||
import kotlin.math.max
|
||||
|
||||
private const val KEY_STATE = "state"
|
||||
|
@ -1726,10 +1727,17 @@ data class GeneratorState(
|
|||
) : 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>
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue