mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
BitwardenMultiSelectButton options update to use ImmutableList (#314)
This commit is contained in:
parent
ff8b9cd0b4
commit
19df16d049
5 changed files with 16 additions and 10 deletions
|
@ -33,6 +33,8 @@ import com.x8bit.bitwarden.R
|
|||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||
import com.x8bit.bitwarden.ui.platform.components.model.TooltipData
|
||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
/**
|
||||
* A custom composable representing a multi-select button.
|
||||
|
@ -53,7 +55,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
@Composable
|
||||
fun BitwardenMultiSelectButton(
|
||||
label: String,
|
||||
options: List<String>,
|
||||
options: ImmutableList<String>,
|
||||
selectedOption: String,
|
||||
onOptionSelected: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
@ -156,7 +158,7 @@ private fun BitwardenMultiSelectButton_preview() {
|
|||
BitwardenTheme {
|
||||
BitwardenMultiSelectButton(
|
||||
label = "Label",
|
||||
options = listOf("a", "b"),
|
||||
options = persistentListOf("a", "b"),
|
||||
selectedOption = "",
|
||||
onOptionSelected = {},
|
||||
)
|
||||
|
|
|
@ -69,6 +69,7 @@ import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Pa
|
|||
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Passcode.PasscodeType.Password.Companion.PASSWORD_COUNTER_MIN
|
||||
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Passcode.PasscodeType.Password.Companion.PASSWORD_LENGTH_SLIDER_MAX
|
||||
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Passcode.PasscodeType.Password.Companion.PASSWORD_LENGTH_SLIDER_MIN
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Top level composable for the generator screen.
|
||||
|
@ -300,7 +301,7 @@ private fun MainStateOptionsItem(
|
|||
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.what_would_you_like_to_generate),
|
||||
options = optionsWithStrings.values.toList(),
|
||||
options = optionsWithStrings.values.toImmutableList(),
|
||||
selectedOption = stringResource(id = selectedType.displayStringResId),
|
||||
onOptionSelected = { selectedOption ->
|
||||
val selectedOptionId =
|
||||
|
@ -353,7 +354,7 @@ private fun PasscodeOptionsItem(
|
|||
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.password_type),
|
||||
options = optionsWithStrings.values.toList(),
|
||||
options = optionsWithStrings.values.toImmutableList(),
|
||||
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
||||
onOptionSelected = { selectedOption ->
|
||||
val selectedOptionId =
|
||||
|
@ -752,7 +753,7 @@ private fun UsernameOptionsItem(
|
|||
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.username_type),
|
||||
options = optionsWithStrings.values.toList(),
|
||||
options = optionsWithStrings.values.toImmutableList(),
|
||||
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
||||
onOptionSelected = { selectedOption ->
|
||||
val selectedOptionId =
|
||||
|
|
|
@ -17,6 +17,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Displays UX for choosing deletion date of a send.
|
||||
|
@ -43,7 +44,7 @@ fun SendDeletionDateChooser(
|
|||
) {
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.deletion_date),
|
||||
options = options,
|
||||
options = options.toImmutableList(),
|
||||
selectedOption = selectedOption,
|
||||
onOptionSelected = { selectedOption = it },
|
||||
)
|
||||
|
|
|
@ -17,6 +17,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Displays UX for choosing expiration date of a send.
|
||||
|
@ -44,7 +45,7 @@ fun SendExpirationDateChooser(
|
|||
) {
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.expiration_date),
|
||||
options = options,
|
||||
options = options.toImmutableList(),
|
||||
selectedOption = selectedOption,
|
||||
onOptionSelected = { selectedOption = it },
|
||||
)
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.x8bit.bitwarden.ui.platform.components.BitwardenTextField
|
|||
import com.x8bit.bitwarden.ui.platform.components.BitwardenTextFieldWithActions
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Top level composable for the vault add item screen.
|
||||
|
@ -159,7 +160,7 @@ private fun TypeOptionsItem(
|
|||
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.type),
|
||||
options = optionsWithStrings.values.toList(),
|
||||
options = optionsWithStrings.values.toImmutableList(),
|
||||
selectedOption = stringResource(id = selectedType.displayStringResId),
|
||||
onOptionSelected = { selectedOption ->
|
||||
val selectedOptionId =
|
||||
|
@ -290,7 +291,7 @@ private fun AddLoginTypeItemContent(
|
|||
Spacer(modifier = Modifier.height(8.dp))
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.folder),
|
||||
options = state.availableFolders,
|
||||
options = state.availableFolders.toImmutableList(),
|
||||
selectedOption = state.folder,
|
||||
onOptionSelected = loginItemTypeHandlers.onFolderTextChange,
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
|
@ -375,7 +376,7 @@ private fun AddLoginTypeItemContent(
|
|||
Spacer(modifier = Modifier.height(8.dp))
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.who_owns_this_item),
|
||||
options = state.availableOwners,
|
||||
options = state.availableOwners.toImmutableList(),
|
||||
selectedOption = state.ownership,
|
||||
onOptionSelected = loginItemTypeHandlers.onOwnershipTextChange,
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
|
|
Loading…
Reference in a new issue