PM-14184: Update the switch thoughout the app (#4170)

This commit is contained in:
David Perez 2024-10-28 12:09:29 -05:00 committed by GitHub
parent 064db9fb6a
commit 4a91d87d9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 158 additions and 343 deletions

View file

@ -46,7 +46,7 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.image.BitwardenGifImage
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
@ -167,7 +167,7 @@ private fun SetupAutoFillContent(
.standardHorizontalMargin(),
)
Spacer(modifier = Modifier.height(24.dp))
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(
R.string.autofill_services,
),

View file

@ -53,7 +53,7 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
import com.x8bit.bitwarden.ui.platform.composition.LocalNfcManager
@ -263,7 +263,7 @@ private fun TwoFactorLoginScreenContent(
Spacer(modifier = Modifier.height(12.dp))
}
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.remember_me),
isChecked = state.isRememberMeEnabled,
onCheckedChange = onRememberMeToggle,

View file

@ -2,14 +2,14 @@ package com.x8bit.bitwarden.ui.platform.components.toggle
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.ripple
@ -17,23 +17,35 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
import com.x8bit.bitwarden.ui.platform.components.toggle.color.bitwardenSwitchColors
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* Represents a Bitwarden-styled [Switch].
* A wide custom switch composable
*
* @param label The label for the switch.
* @param isChecked Whether or not the switch is currently checked.
* @param onCheckedChange A callback for when the checked state changes.
* @param modifier The [Modifier] to be applied to the button.
* @param description The description of the switch to be displayed below the [label].
* @param label The descriptive text label to be displayed adjacent to the switch.
* @param isChecked The current state of the switch (either checked or unchecked).
* @param onCheckedChange A lambda that is invoked when the switch's state changes.
* @param modifier A [Modifier] that you can use to apply custom modifications to the composable.
* @param description An optional description label to be displayed below the [label].
* @param contentDescription A description of the switch's UI for accessibility purposes.
* @param readOnly Disables the click functionality without modifying the other UI characteristics.
* @param enabled Whether or not this switch is enabled. This is similar to setting [readOnly] but
* comes with some additional visual changes.
* @param actions A lambda containing the set of actions (usually icons or similar) to display
* in between the [label] and the toggle. This lambda extends [RowScope], allowing flexibility in
* defining the layout of the actions.
*/
@Suppress("LongMethod")
@Composable
fun BitwardenSwitch(
label: String,
@ -41,82 +53,115 @@ fun BitwardenSwitch(
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
description: String? = null,
contentDescription: String? = null,
readOnly: Boolean = false,
enabled: Boolean = true,
actions: (@Composable RowScope.() -> Unit)? = null,
) {
Row(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.run {
if (onCheckedChange != null) {
this.clickable(
.wrapContentHeight()
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = ripple(
color = BitwardenTheme.colorScheme.background.pressed,
),
onClick = { onCheckedChange.invoke(!isChecked) },
onClick = { onCheckedChange?.invoke(!isChecked) },
enabled = !readOnly && enabled,
)
} else {
this
}
}
.semantics(mergeDescendants = true) {
toggleableState = ToggleableState(isChecked)
contentDescription?.let { this.contentDescription = it }
}
.then(modifier),
) {
Switch(
Row(
modifier = Modifier.weight(weight = 1f),
verticalAlignment = Alignment.CenterVertically,
) {
Column(
modifier = Modifier
.padding(vertical = 8.dp)
.height(32.dp)
.width(52.dp),
checked = isChecked,
onCheckedChange = null,
colors = bitwardenSwitchColors(),
)
Spacer(modifier = Modifier.width(16.dp))
Column {
Spacer(modifier = Modifier.height(4.dp))
.weight(weight = 1f, fill = false)
.padding(vertical = 8.dp),
) {
Text(
text = label,
style = BitwardenTheme.typography.bodyLarge,
color = BitwardenTheme.colorScheme.text.primary,
color = if (enabled) {
BitwardenTheme.colorScheme.text.primary
} else {
BitwardenTheme.colorScheme.filledButton.foregroundDisabled
},
modifier = Modifier.testTag(tag = "SwitchText"),
)
description?.let {
Text(
text = it,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.secondary,
color = if (enabled) {
BitwardenTheme.colorScheme.text.secondary
} else {
BitwardenTheme.colorScheme.filledButton.foregroundDisabled
},
)
}
Spacer(modifier = Modifier.height(4.dp))
}
actions
?.invoke(this)
?: Spacer(modifier = Modifier.width(width = 16.dp))
}
Switch(
modifier = Modifier
.height(height = 56.dp)
.testTag(tag = "SwitchToggle"),
enabled = enabled,
checked = isChecked,
onCheckedChange = null,
colors = bitwardenSwitchColors(),
)
}
}
@Preview(showBackground = true)
@Composable
private fun BitwardenSwitch_preview_isChecked() {
private fun BitwardenSwitch_preview() {
Column {
BitwardenSwitch(
label = "Label",
description = "Description",
isChecked = true,
onCheckedChange = {},
modifier = Modifier.fillMaxWidth(),
)
}
@Preview(showBackground = true)
@Composable
private fun BitwardenSwitch_preview_isNotChecked() {
BitwardenSwitch(
label = "Label",
isChecked = false,
onCheckedChange = {},
modifier = Modifier.fillMaxWidth(),
)
BitwardenSwitch(
label = "Label",
isChecked = true,
onCheckedChange = {},
actions = {
BitwardenStandardIconButton(
vectorIconRes = R.drawable.ic_question_circle,
contentDescription = "content description",
onClick = {},
)
},
)
BitwardenSwitch(
label = "Label",
isChecked = false,
onCheckedChange = {},
actions = {
BitwardenStandardIconButton(
vectorIconRes = R.drawable.ic_question_circle,
contentDescription = "content description",
onClick = {},
)
},
)
}
}

View file

@ -1,89 +0,0 @@
package com.x8bit.bitwarden.ui.platform.components.toggle
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.Switch
import androidx.compose.material3.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.tooling.preview.Preview
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenRowOfActions
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* Represents a Bitwarden-styled [Switch].
*
* @param label The label for the switch.
* @param isChecked Whether or not the switch is currently checked.
* @param onCheckedChange A callback for when the checked state changes.
* @param modifier The [Modifier] to be applied to the button.
* @param actions A lambda containing the set of actions (usually icons or similar) to display
* in the app bar's trailing side. This lambda extends [RowScope], allowing flexibility in
* defining the layout of the actions.
*/
@Composable
fun BitwardenSwitchWithActions(
label: String,
isChecked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
actions: @Composable RowScope.() -> Unit = {},
) {
Row(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = ripple(
color = BitwardenTheme.colorScheme.background.pressed,
),
onClick = { onCheckedChange?.invoke(!isChecked) },
)
.semantics(mergeDescendants = true) {
toggleableState = ToggleableState(isChecked)
}
.then(modifier),
) {
BitwardenSwitch(
label = label,
isChecked = isChecked,
onCheckedChange = null,
)
BitwardenRowOfActions(actions = actions)
}
}
@Preview
@Composable
private fun BitwardenSwitchWithActions_preview() {
BitwardenTheme {
BitwardenSwitchWithActions(
label = "Label",
isChecked = true,
onCheckedChange = {},
actions = {
BitwardenStandardIconButton(
vectorIconRes = R.drawable.ic_question_circle,
contentDescription = stringResource(
id = R.string.master_password_re_prompt_help,
),
onClick = {},
)
},
)
}
}

View file

@ -34,7 +34,7 @@ fun BitwardenUnlockWithBiometricsSwitch(
BiometricSupportStatus.NOT_SUPPORTED -> return
}
BitwardenWideSwitch(
BitwardenSwitch(
modifier = modifier,
label = stringResource(
id = R.string.unlock_with,

View file

@ -32,7 +32,7 @@ fun BitwardenUnlockWithPinSwitch(
var shouldShowPinInputDialog by rememberSaveable { mutableStateOf(value = false) }
var shouldShowPinConfirmationDialog by rememberSaveable { mutableStateOf(value = false) }
var pin by remember { mutableStateOf(value = "") }
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.unlock_with_pin),
isChecked = isUnlockWithPinEnabled,
onCheckedChange = { isChecked ->

View file

@ -1,137 +0,0 @@
package com.x8bit.bitwarden.ui.platform.components.toggle
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.ui.platform.components.toggle.color.bitwardenSwitchColors
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* A wide custom switch composable
*
* @param label The descriptive text label to be displayed adjacent to the switch.
* @param isChecked The current state of the switch (either checked or unchecked).
* @param onCheckedChange A lambda that is invoked when the switch's state changes.
* @param modifier A [Modifier] that you can use to apply custom modifications to the composable.
* @param description An optional description label to be displayed below the [label].
* @param contentDescription A description of the switch's UI for accessibility purposes.
* @param readOnly Disables the click functionality without modifying the other UI characteristics.
* @param enabled Whether or not this switch is enabled. This is similar to setting [readOnly] but
* comes with some additional visual changes.
*/
@Composable
fun BitwardenWideSwitch(
label: String,
isChecked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
description: String? = null,
contentDescription: String? = null,
readOnly: Boolean = false,
enabled: Boolean = true,
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.wrapContentHeight()
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = ripple(
color = BitwardenTheme.colorScheme.background.pressed,
),
onClick = { onCheckedChange?.invoke(!isChecked) },
enabled = !readOnly && enabled,
)
.semantics(mergeDescendants = true) {
toggleableState = ToggleableState(isChecked)
contentDescription?.let { this.contentDescription = it }
}
.then(modifier),
) {
Column(
modifier = Modifier
.weight(1f)
.padding(vertical = 8.dp),
) {
Text(
text = label,
style = BitwardenTheme.typography.bodyLarge,
color = if (enabled) {
BitwardenTheme.colorScheme.text.primary
} else {
BitwardenTheme.colorScheme.filledButton.foregroundDisabled
},
modifier = Modifier.testTag("SwitchText"),
)
description?.let {
Text(
text = it,
style = BitwardenTheme.typography.bodyMedium,
color = if (enabled) {
BitwardenTheme.colorScheme.text.secondary
} else {
BitwardenTheme.colorScheme.filledButton.foregroundDisabled
},
)
}
}
Spacer(modifier = Modifier.width(16.dp))
Switch(
modifier = Modifier
.height(56.dp)
.testTag("SwitchToggle"),
enabled = enabled,
checked = isChecked,
onCheckedChange = null,
colors = bitwardenSwitchColors(),
)
}
}
@Preview
@Composable
private fun BitwardenWideSwitch_preview_isChecked() {
BitwardenTheme {
BitwardenWideSwitch(
label = "Label",
isChecked = true,
onCheckedChange = {},
)
}
}
@Preview
@Composable
private fun BitwardenWideSwitch_preview_isNotChecked() {
BitwardenTheme {
BitwardenWideSwitch(
label = "Label",
isChecked = false,
onCheckedChange = {},
)
}
}

View file

@ -5,7 +5,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
/**
* Creates a list item for a [FlagKey].
@ -48,7 +48,7 @@ private fun BooleanFlagItem(
onValueChange: (key: FlagKey<Boolean>, value: Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = label,
isChecked = currentValue,
onCheckedChange = {

View file

@ -44,7 +44,7 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.divider.BitwardenHorizontalDivider
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
@ -165,7 +165,7 @@ private fun ContentColumn(
) {
Spacer(modifier = Modifier.height(8.dp))
if (state.shouldShowCrashLogsButton) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.submit_crash_logs),
isChecked = state.isSubmitCrashLogsEnabled,
onCheckedChange = onSubmitCrashLogsCheckedChange,

View file

@ -56,9 +56,9 @@ import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenUnlockWithBiometricsSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenUnlockWithPinSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalBiometricsManager
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
@ -705,7 +705,7 @@ private fun SyncWithAuthenticatorRow(
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(R.string.allow_bitwarden_authenticator_syncing),
onCheckedChange = onCheckedChange,
isChecked = isChecked,

View file

@ -33,7 +33,7 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenSelectionDialo
import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenSelectionRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppLanguage
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
@ -100,7 +100,7 @@ fun AppearanceScreen(
.fillMaxWidth(),
)
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.show_website_icons),
description = stringResource(id = R.string.show_website_icons_description),
isChecked = state.showWebsiteIcons,

View file

@ -46,7 +46,7 @@ import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
import com.x8bit.bitwarden.ui.platform.feature.settings.autofill.util.displayLabel
@ -165,7 +165,7 @@ fun AutoFillScreen(
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.autofill_services),
description = stringResource(id = R.string.autofill_services_explanation_long),
isChecked = state.isAutoFillServicesEnabled,
@ -178,7 +178,7 @@ fun AutoFillScreen(
.padding(horizontal = 16.dp),
)
if (state.showInlineAutofillOption) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.inline_autofill),
description = stringResource(
id = R.string.use_inline_autofill_explanation_long,
@ -226,7 +226,7 @@ fun AutoFillScreen(
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.copy_totp_automatically),
description = stringResource(id = R.string.copy_totp_automatically_description),
isChecked = state.isCopyTotpAutomaticallyEnabled,
@ -238,7 +238,7 @@ fun AutoFillScreen(
.testTag("CopyTotpAutomaticallySwitch")
.padding(horizontal = 16.dp),
)
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.ask_to_add_login),
description = stringResource(id = R.string.ask_to_add_login_description),
isChecked = state.isAskToAddLoginEnabled,
@ -281,7 +281,7 @@ private fun AccessibilityAutofillSwitch(
modifier: Modifier = Modifier,
) {
var shouldShowDialog by rememberSaveable { mutableStateOf(value = false) }
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.accessibility),
description = stringResource(id = R.string.accessibility_description5),
isChecked = isAccessibilityAutoFillEnabled,

View file

@ -42,7 +42,7 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenSelectionRow
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
@ -100,7 +100,7 @@ fun OtherScreen(
.fillMaxSize()
.verticalScroll(rememberScrollState()),
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.enable_sync_on_refresh),
description = stringResource(id = R.string.enable_sync_on_refresh_description),
isChecked = state.allowSyncOnRefresh,
@ -183,7 +183,7 @@ private fun ScreenCaptureRow(
) {
var shouldShowScreenCaptureConfirmDialog by remember { mutableStateOf(false) }
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.allow_screen_capture),
isChecked = currentValue,
onCheckedChange = {

View file

@ -57,7 +57,7 @@ import com.x8bit.bitwarden.ui.platform.components.snackbar.BitwardenSnackbarData
import com.x8bit.bitwarden.ui.platform.components.snackbar.BitwardenSnackbarHost
import com.x8bit.bitwarden.ui.platform.components.snackbar.rememberBitwardenSnackbarHostState
import com.x8bit.bitwarden.ui.platform.components.stepper.BitwardenStepper
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.nonLetterColorVisualTransformation
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
@ -531,7 +531,7 @@ private fun PasswordCapitalLettersToggleItem(
onPasswordToggleCapitalLettersChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = "A—Z",
isChecked = useCapitals,
onCheckedChange = onPasswordToggleCapitalLettersChange,
@ -550,7 +550,7 @@ private fun PasswordLowercaseLettersToggleItem(
onPasswordToggleLowercaseLettersChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = "a—z",
isChecked = useLowercase,
onCheckedChange = onPasswordToggleLowercaseLettersChange,
@ -569,7 +569,7 @@ private fun PasswordNumbersToggleItem(
onPasswordToggleNumbersChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = "0-9",
isChecked = useNumbers,
onCheckedChange = onPasswordToggleNumbersChange,
@ -588,7 +588,7 @@ private fun PasswordSpecialCharactersToggleItem(
onPasswordToggleSpecialCharactersChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = "!@#$%^&*",
isChecked = useSpecialChars,
onCheckedChange = onPasswordToggleSpecialCharactersChange,
@ -647,7 +647,7 @@ private fun PasswordAvoidAmbiguousCharsToggleItem(
onPasswordToggleAvoidAmbiguousCharsChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.avoid_ambiguous_characters),
isChecked = avoidAmbiguousChars,
enabled = enabled,
@ -758,7 +758,7 @@ private fun PassphraseCapitalizeToggleItem(
onPassphraseCapitalizeToggleChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.capitalize),
isChecked = capitalize,
onCheckedChange = onPassphraseCapitalizeToggleChange,
@ -776,7 +776,7 @@ private fun PassphraseIncludeNumberToggleItem(
onPassphraseIncludeNumberToggleChange: (Boolean) -> Unit,
enabled: Boolean,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.include_number),
isChecked = includeNumber,
enabled = enabled,
@ -1127,7 +1127,7 @@ private fun RandomWordCapitalizeToggleItem(
capitalize: Boolean,
onRandomWordCapitalizeToggleChange: (Boolean) -> Unit,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.capitalize),
isChecked = capitalize,
onCheckedChange = onRandomWordCapitalizeToggleChange,
@ -1143,7 +1143,7 @@ private fun RandomWordIncludeNumberToggleItem(
includeNumber: Boolean,
onRandomWordIncludeNumberToggleChange: (Boolean) -> Unit,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = stringResource(id = R.string.include_number),
isChecked = includeNumber,
onCheckedChange = onRandomWordIncludeNumberToggleChange,

View file

@ -45,7 +45,7 @@ import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.segment.BitwardenSegmentedButton
import com.x8bit.bitwarden.ui.platform.components.segment.SegmentedButtonState
import com.x8bit.bitwarden.ui.platform.components.stepper.BitwardenStepper
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
@ -242,7 +242,7 @@ fun AddSendContent(
onValueChange = addSendHandlers.onTextChange,
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenWideSwitch(
BitwardenSwitch(
modifier = Modifier
.testTag(tag = "SendHideTextByDefaultToggle")
.fillMaxWidth()
@ -502,7 +502,7 @@ private fun AddSendOptions(
.padding(horizontal = 16.dp),
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenWideSwitch(
BitwardenSwitch(
modifier = Modifier
.testTag("SendHideEmailSwitch")
.fillMaxWidth()
@ -514,7 +514,7 @@ private fun AddSendOptions(
enabled = state.common.isHideEmailChecked || state.common.isHideEmailAddressEnabled,
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenWideSwitch(
BitwardenSwitch(
modifier = Modifier
.testTag("SendDeactivateSwitch")
.fillMaxWidth()

View file

@ -15,7 +15,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.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.model.VaultCollection
@ -43,7 +43,7 @@ fun LazyListScope.collectionItemsSelector(
if (collectionList?.isNotEmpty() == true) {
items(collectionList) {
Spacer(modifier = Modifier.height(8.dp))
BitwardenWideSwitch(
BitwardenSwitch(
label = it.name,
isChecked = it.isSelected,
onCheckedChange = { _ ->

View file

@ -23,7 +23,6 @@ import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCardTypeHandlers
@ -214,7 +213,7 @@ fun LazyListScope.vaultAddEditCardItems(
if (commonState.isUnlockWithPasswordEnabled) {
item {
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitchWithActions(
BitwardenSwitch(
label = stringResource(id = R.string.password_prompt),
isChecked = commonState.masterPasswordReprompt,
onCheckedChange = commonHandlers.onToggleMasterPasswordReprompt,

View file

@ -20,7 +20,7 @@ import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectB
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordFieldWithActions
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenRowOfActions
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.vault.feature.addedit.model.CustomFieldAction
import com.x8bit.bitwarden.ui.vault.model.VaultLinkedFieldType
import kotlinx.collections.immutable.ImmutableList
@ -146,7 +146,7 @@ private fun CustomFieldBoolean(
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
BitwardenWideSwitch(
BitwardenSwitch(
label = label,
isChecked = value,
onCheckedChange = onValueChanged,

View file

@ -18,7 +18,6 @@ import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectB
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
@ -315,7 +314,7 @@ fun LazyListScope.vaultAddEditIdentityItems(
if (commonState.isUnlockWithPasswordEnabled) {
item {
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitchWithActions(
BitwardenSwitch(
label = stringResource(id = R.string.password_prompt),
isChecked = commonState.masterPasswordReprompt,
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,

View file

@ -29,7 +29,6 @@ import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
@ -235,7 +234,7 @@ fun LazyListScope.vaultAddEditLoginItems(
if (commonState.isUnlockWithPasswordEnabled) {
item {
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitchWithActions(
BitwardenSwitch(
label = stringResource(id = R.string.password_prompt),
isChecked = commonState.masterPasswordReprompt,
onCheckedChange = commonActionHandler.onToggleMasterPasswordReprompt,

View file

@ -16,7 +16,6 @@ import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectB
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
@ -94,7 +93,7 @@ fun LazyListScope.vaultAddEditSecureNotesItems(
if (commonState.isUnlockWithPasswordEnabled) {
item {
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitchWithActions(
BitwardenSwitch(
label = stringResource(id = R.string.password_prompt),
isChecked = commonState.masterPasswordReprompt,
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,

View file

@ -9,7 +9,7 @@ import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordFieldWi
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
/**
@ -26,7 +26,7 @@ fun CustomField(
) {
when (customField) {
is VaultItemState.ViewState.Content.Common.Custom.BooleanField -> {
BitwardenWideSwitch(
BitwardenSwitch(
label = customField.name,
isChecked = customField.value,
readOnly = true,