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.base.util.asText
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.TooltipData
|
import com.x8bit.bitwarden.ui.platform.components.model.TooltipData
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
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.
|
* A custom composable representing a multi-select button.
|
||||||
|
@ -53,7 +55,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
@Composable
|
@Composable
|
||||||
fun BitwardenMultiSelectButton(
|
fun BitwardenMultiSelectButton(
|
||||||
label: String,
|
label: String,
|
||||||
options: List<String>,
|
options: ImmutableList<String>,
|
||||||
selectedOption: String,
|
selectedOption: String,
|
||||||
onOptionSelected: (String) -> Unit,
|
onOptionSelected: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
@ -156,7 +158,7 @@ private fun BitwardenMultiSelectButton_preview() {
|
||||||
BitwardenTheme {
|
BitwardenTheme {
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = "Label",
|
label = "Label",
|
||||||
options = listOf("a", "b"),
|
options = persistentListOf("a", "b"),
|
||||||
selectedOption = "",
|
selectedOption = "",
|
||||||
onOptionSelected = {},
|
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_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_MAX
|
||||||
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Passcode.PasscodeType.Password.Companion.PASSWORD_LENGTH_SLIDER_MIN
|
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.
|
* Top level composable for the generator screen.
|
||||||
|
@ -300,7 +301,7 @@ private fun MainStateOptionsItem(
|
||||||
|
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.what_would_you_like_to_generate),
|
label = stringResource(id = R.string.what_would_you_like_to_generate),
|
||||||
options = optionsWithStrings.values.toList(),
|
options = optionsWithStrings.values.toImmutableList(),
|
||||||
selectedOption = stringResource(id = selectedType.displayStringResId),
|
selectedOption = stringResource(id = selectedType.displayStringResId),
|
||||||
onOptionSelected = { selectedOption ->
|
onOptionSelected = { selectedOption ->
|
||||||
val selectedOptionId =
|
val selectedOptionId =
|
||||||
|
@ -353,7 +354,7 @@ private fun PasscodeOptionsItem(
|
||||||
|
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.password_type),
|
label = stringResource(id = R.string.password_type),
|
||||||
options = optionsWithStrings.values.toList(),
|
options = optionsWithStrings.values.toImmutableList(),
|
||||||
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
||||||
onOptionSelected = { selectedOption ->
|
onOptionSelected = { selectedOption ->
|
||||||
val selectedOptionId =
|
val selectedOptionId =
|
||||||
|
@ -752,7 +753,7 @@ private fun UsernameOptionsItem(
|
||||||
|
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.username_type),
|
label = stringResource(id = R.string.username_type),
|
||||||
options = optionsWithStrings.values.toList(),
|
options = optionsWithStrings.values.toImmutableList(),
|
||||||
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
selectedOption = stringResource(id = currentSubState.selectedType.displayStringResId),
|
||||||
onOptionSelected = { selectedOption ->
|
onOptionSelected = { selectedOption ->
|
||||||
val selectedOptionId =
|
val selectedOptionId =
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
||||||
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays UX for choosing deletion date of a send.
|
* Displays UX for choosing deletion date of a send.
|
||||||
|
@ -43,7 +44,7 @@ fun SendDeletionDateChooser(
|
||||||
) {
|
) {
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.deletion_date),
|
label = stringResource(id = R.string.deletion_date),
|
||||||
options = options,
|
options = options.toImmutableList(),
|
||||||
selectedOption = selectedOption,
|
selectedOption = selectedOption,
|
||||||
onOptionSelected = { selectedOption = it },
|
onOptionSelected = { selectedOption = it },
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
||||||
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays UX for choosing expiration date of a send.
|
* Displays UX for choosing expiration date of a send.
|
||||||
|
@ -44,7 +45,7 @@ fun SendExpirationDateChooser(
|
||||||
) {
|
) {
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.expiration_date),
|
label = stringResource(id = R.string.expiration_date),
|
||||||
options = options,
|
options = options.toImmutableList(),
|
||||||
selectedOption = selectedOption,
|
selectedOption = selectedOption,
|
||||||
onOptionSelected = { selectedOption = it },
|
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.BitwardenTextFieldWithActions
|
||||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenTopAppBar
|
import com.x8bit.bitwarden.ui.platform.components.BitwardenTopAppBar
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
|
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
|
||||||
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top level composable for the vault add item screen.
|
* Top level composable for the vault add item screen.
|
||||||
|
@ -159,7 +160,7 @@ private fun TypeOptionsItem(
|
||||||
|
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.type),
|
label = stringResource(id = R.string.type),
|
||||||
options = optionsWithStrings.values.toList(),
|
options = optionsWithStrings.values.toImmutableList(),
|
||||||
selectedOption = stringResource(id = selectedType.displayStringResId),
|
selectedOption = stringResource(id = selectedType.displayStringResId),
|
||||||
onOptionSelected = { selectedOption ->
|
onOptionSelected = { selectedOption ->
|
||||||
val selectedOptionId =
|
val selectedOptionId =
|
||||||
|
@ -290,7 +291,7 @@ private fun AddLoginTypeItemContent(
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.folder),
|
label = stringResource(id = R.string.folder),
|
||||||
options = state.availableFolders,
|
options = state.availableFolders.toImmutableList(),
|
||||||
selectedOption = state.folder,
|
selectedOption = state.folder,
|
||||||
onOptionSelected = loginItemTypeHandlers.onFolderTextChange,
|
onOptionSelected = loginItemTypeHandlers.onFolderTextChange,
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
|
@ -375,7 +376,7 @@ private fun AddLoginTypeItemContent(
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
BitwardenMultiSelectButton(
|
BitwardenMultiSelectButton(
|
||||||
label = stringResource(id = R.string.who_owns_this_item),
|
label = stringResource(id = R.string.who_owns_this_item),
|
||||||
options = state.availableOwners,
|
options = state.availableOwners.toImmutableList(),
|
||||||
selectedOption = state.ownership,
|
selectedOption = state.ownership,
|
||||||
onOptionSelected = loginItemTypeHandlers.onOwnershipTextChange,
|
onOptionSelected = loginItemTypeHandlers.onOwnershipTextChange,
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
|
|
Loading…
Reference in a new issue