mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-14184: Update the switch thoughout the app (#4170)
This commit is contained in:
parent
064db9fb6a
commit
4a91d87d9d
22 changed files with 158 additions and 343 deletions
|
@ -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.dialog.BitwardenTwoButtonDialog
|
||||||
import com.x8bit.bitwarden.ui.platform.components.image.BitwardenGifImage
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
||||||
|
@ -167,7 +167,7 @@ private fun SetupAutoFillContent(
|
||||||
.standardHorizontalMargin(),
|
.standardHorizontalMargin(),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(24.dp))
|
Spacer(modifier = Modifier.height(24.dp))
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(
|
label = stringResource(
|
||||||
R.string.autofill_services,
|
R.string.autofill_services,
|
||||||
),
|
),
|
||||||
|
|
|
@ -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.dialog.LoadingDialogState
|
||||||
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalNfcManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalNfcManager
|
||||||
|
@ -263,7 +263,7 @@ private fun TwoFactorLoginScreenContent(
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
}
|
}
|
||||||
|
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.remember_me),
|
label = stringResource(id = R.string.remember_me),
|
||||||
isChecked = state.isRememberMeEnabled,
|
isChecked = state.isRememberMeEnabled,
|
||||||
onCheckedChange = onRememberMeToggle,
|
onCheckedChange = onRememberMeToggle,
|
||||||
|
|
|
@ -2,14 +2,14 @@ package com.x8bit.bitwarden.ui.platform.components.toggle
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.wrapContentHeight
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.ripple
|
import androidx.compose.material3.ripple
|
||||||
|
@ -17,23 +17,35 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
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.semantics
|
||||||
import androidx.compose.ui.semantics.toggleableState
|
import androidx.compose.ui.semantics.toggleableState
|
||||||
import androidx.compose.ui.state.ToggleableState
|
import androidx.compose.ui.state.ToggleableState
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
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.components.toggle.color.bitwardenSwitchColors
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
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 label The descriptive text label to be displayed adjacent to the switch.
|
||||||
* @param isChecked Whether or not the switch is currently checked.
|
* @param isChecked The current state of the switch (either checked or unchecked).
|
||||||
* @param onCheckedChange A callback for when the checked state changes.
|
* @param onCheckedChange A lambda that is invoked when the switch's state changes.
|
||||||
* @param modifier The [Modifier] to be applied to the button.
|
* @param modifier A [Modifier] that you can use to apply custom modifications to the composable.
|
||||||
* @param description The description of the switch to be displayed below the [label].
|
* @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
|
@Composable
|
||||||
fun BitwardenSwitch(
|
fun BitwardenSwitch(
|
||||||
label: String,
|
label: String,
|
||||||
|
@ -41,82 +53,115 @@ fun BitwardenSwitch(
|
||||||
onCheckedChange: ((Boolean) -> Unit)?,
|
onCheckedChange: ((Boolean) -> Unit)?,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
|
contentDescription: String? = null,
|
||||||
|
readOnly: Boolean = false,
|
||||||
|
enabled: Boolean = true,
|
||||||
|
actions: (@Composable RowScope.() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
horizontalArrangement = Arrangement.Start,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.run {
|
.wrapContentHeight()
|
||||||
if (onCheckedChange != null) {
|
.clickable(
|
||||||
this.clickable(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = ripple(
|
indication = ripple(
|
||||||
color = BitwardenTheme.colorScheme.background.pressed,
|
color = BitwardenTheme.colorScheme.background.pressed,
|
||||||
),
|
),
|
||||||
onClick = { onCheckedChange.invoke(!isChecked) },
|
onClick = { onCheckedChange?.invoke(!isChecked) },
|
||||||
|
enabled = !readOnly && enabled,
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.semantics(mergeDescendants = true) {
|
.semantics(mergeDescendants = true) {
|
||||||
toggleableState = ToggleableState(isChecked)
|
toggleableState = ToggleableState(isChecked)
|
||||||
|
contentDescription?.let { this.contentDescription = it }
|
||||||
}
|
}
|
||||||
.then(modifier),
|
.then(modifier),
|
||||||
) {
|
) {
|
||||||
Switch(
|
Row(
|
||||||
|
modifier = Modifier.weight(weight = 1f),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = 8.dp)
|
.weight(weight = 1f, fill = false)
|
||||||
.height(32.dp)
|
.padding(vertical = 8.dp),
|
||||||
.width(52.dp),
|
) {
|
||||||
checked = isChecked,
|
|
||||||
onCheckedChange = null,
|
|
||||||
colors = bitwardenSwitchColors(),
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = BitwardenTheme.typography.bodyLarge,
|
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 {
|
description?.let {
|
||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
style = BitwardenTheme.typography.bodyMedium,
|
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)
|
@Preview(showBackground = true)
|
||||||
@Composable
|
@Composable
|
||||||
private fun BitwardenSwitch_preview_isChecked() {
|
private fun BitwardenSwitch_preview() {
|
||||||
|
Column {
|
||||||
BitwardenSwitch(
|
BitwardenSwitch(
|
||||||
label = "Label",
|
label = "Label",
|
||||||
description = "Description",
|
|
||||||
isChecked = true,
|
isChecked = true,
|
||||||
onCheckedChange = {},
|
onCheckedChange = {},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
|
||||||
@Composable
|
|
||||||
private fun BitwardenSwitch_preview_isNotChecked() {
|
|
||||||
BitwardenSwitch(
|
BitwardenSwitch(
|
||||||
label = "Label",
|
label = "Label",
|
||||||
isChecked = false,
|
isChecked = false,
|
||||||
onCheckedChange = {},
|
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 = {},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 = {},
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,7 +34,7 @@ fun BitwardenUnlockWithBiometricsSwitch(
|
||||||
|
|
||||||
BiometricSupportStatus.NOT_SUPPORTED -> return
|
BiometricSupportStatus.NOT_SUPPORTED -> return
|
||||||
}
|
}
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
label = stringResource(
|
label = stringResource(
|
||||||
id = R.string.unlock_with,
|
id = R.string.unlock_with,
|
||||||
|
|
|
@ -32,7 +32,7 @@ fun BitwardenUnlockWithPinSwitch(
|
||||||
var shouldShowPinInputDialog by rememberSaveable { mutableStateOf(value = false) }
|
var shouldShowPinInputDialog by rememberSaveable { mutableStateOf(value = false) }
|
||||||
var shouldShowPinConfirmationDialog by rememberSaveable { mutableStateOf(value = false) }
|
var shouldShowPinConfirmationDialog by rememberSaveable { mutableStateOf(value = false) }
|
||||||
var pin by remember { mutableStateOf(value = "") }
|
var pin by remember { mutableStateOf(value = "") }
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.unlock_with_pin),
|
label = stringResource(id = R.string.unlock_with_pin),
|
||||||
isChecked = isUnlockWithPinEnabled,
|
isChecked = isUnlockWithPinEnabled,
|
||||||
onCheckedChange = { isChecked ->
|
onCheckedChange = { isChecked ->
|
||||||
|
|
|
@ -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 = {},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
|
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].
|
* Creates a list item for a [FlagKey].
|
||||||
|
@ -48,7 +48,7 @@ private fun BooleanFlagItem(
|
||||||
onValueChange: (key: FlagKey<Boolean>, value: Boolean) -> Unit,
|
onValueChange: (key: FlagKey<Boolean>, value: Boolean) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = label,
|
label = label,
|
||||||
isChecked = currentValue,
|
isChecked = currentValue,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
|
|
|
@ -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.divider.BitwardenHorizontalDivider
|
||||||
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
||||||
|
@ -165,7 +165,7 @@ private fun ContentColumn(
|
||||||
) {
|
) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
if (state.shouldShowCrashLogsButton) {
|
if (state.shouldShowCrashLogsButton) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.submit_crash_logs),
|
label = stringResource(id = R.string.submit_crash_logs),
|
||||||
isChecked = state.isSubmitCrashLogsEnabled,
|
isChecked = state.isSubmitCrashLogsEnabled,
|
||||||
onCheckedChange = onSubmitCrashLogsCheckedChange,
|
onCheckedChange = onSubmitCrashLogsCheckedChange,
|
||||||
|
|
|
@ -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.BitwardenExternalLinkRow
|
||||||
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
|
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.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.BitwardenUnlockWithBiometricsSwitch
|
||||||
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenUnlockWithPinSwitch
|
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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalBiometricsManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalBiometricsManager
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
|
@ -705,7 +705,7 @@ private fun SyncWithAuthenticatorRow(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(R.string.allow_bitwarden_authenticator_syncing),
|
label = stringResource(R.string.allow_bitwarden_authenticator_syncing),
|
||||||
onCheckedChange = onCheckedChange,
|
onCheckedChange = onCheckedChange,
|
||||||
isChecked = isChecked,
|
isChecked = isChecked,
|
||||||
|
|
|
@ -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.dialog.row.BitwardenSelectionRow
|
||||||
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppLanguage
|
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppLanguage
|
||||||
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
|
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
|
||||||
|
@ -100,7 +100,7 @@ fun AppearanceScreen(
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
)
|
)
|
||||||
|
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.show_website_icons),
|
label = stringResource(id = R.string.show_website_icons),
|
||||||
description = stringResource(id = R.string.show_website_icons_description),
|
description = stringResource(id = R.string.show_website_icons_description),
|
||||||
isChecked = state.showWebsiteIcons,
|
isChecked = state.showWebsiteIcons,
|
||||||
|
|
|
@ -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.BitwardenExternalLinkRow
|
||||||
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
import com.x8bit.bitwarden.ui.platform.feature.settings.autofill.util.displayLabel
|
import com.x8bit.bitwarden.ui.platform.feature.settings.autofill.util.displayLabel
|
||||||
|
@ -165,7 +165,7 @@ fun AutoFillScreen(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.autofill_services),
|
label = stringResource(id = R.string.autofill_services),
|
||||||
description = stringResource(id = R.string.autofill_services_explanation_long),
|
description = stringResource(id = R.string.autofill_services_explanation_long),
|
||||||
isChecked = state.isAutoFillServicesEnabled,
|
isChecked = state.isAutoFillServicesEnabled,
|
||||||
|
@ -178,7 +178,7 @@ fun AutoFillScreen(
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
if (state.showInlineAutofillOption) {
|
if (state.showInlineAutofillOption) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.inline_autofill),
|
label = stringResource(id = R.string.inline_autofill),
|
||||||
description = stringResource(
|
description = stringResource(
|
||||||
id = R.string.use_inline_autofill_explanation_long,
|
id = R.string.use_inline_autofill_explanation_long,
|
||||||
|
@ -226,7 +226,7 @@ fun AutoFillScreen(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.copy_totp_automatically),
|
label = stringResource(id = R.string.copy_totp_automatically),
|
||||||
description = stringResource(id = R.string.copy_totp_automatically_description),
|
description = stringResource(id = R.string.copy_totp_automatically_description),
|
||||||
isChecked = state.isCopyTotpAutomaticallyEnabled,
|
isChecked = state.isCopyTotpAutomaticallyEnabled,
|
||||||
|
@ -238,7 +238,7 @@ fun AutoFillScreen(
|
||||||
.testTag("CopyTotpAutomaticallySwitch")
|
.testTag("CopyTotpAutomaticallySwitch")
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.ask_to_add_login),
|
label = stringResource(id = R.string.ask_to_add_login),
|
||||||
description = stringResource(id = R.string.ask_to_add_login_description),
|
description = stringResource(id = R.string.ask_to_add_login_description),
|
||||||
isChecked = state.isAskToAddLoginEnabled,
|
isChecked = state.isAskToAddLoginEnabled,
|
||||||
|
@ -281,7 +281,7 @@ private fun AccessibilityAutofillSwitch(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
var shouldShowDialog by rememberSaveable { mutableStateOf(value = false) }
|
var shouldShowDialog by rememberSaveable { mutableStateOf(value = false) }
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.accessibility),
|
label = stringResource(id = R.string.accessibility),
|
||||||
description = stringResource(id = R.string.accessibility_description5),
|
description = stringResource(id = R.string.accessibility_description5),
|
||||||
isChecked = isAccessibilityAutoFillEnabled,
|
isChecked = isAccessibilityAutoFillEnabled,
|
||||||
|
|
|
@ -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.dialog.row.BitwardenSelectionRow
|
||||||
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ fun OtherScreen(
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.verticalScroll(rememberScrollState()),
|
.verticalScroll(rememberScrollState()),
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.enable_sync_on_refresh),
|
label = stringResource(id = R.string.enable_sync_on_refresh),
|
||||||
description = stringResource(id = R.string.enable_sync_on_refresh_description),
|
description = stringResource(id = R.string.enable_sync_on_refresh_description),
|
||||||
isChecked = state.allowSyncOnRefresh,
|
isChecked = state.allowSyncOnRefresh,
|
||||||
|
@ -183,7 +183,7 @@ private fun ScreenCaptureRow(
|
||||||
) {
|
) {
|
||||||
var shouldShowScreenCaptureConfirmDialog by remember { mutableStateOf(false) }
|
var shouldShowScreenCaptureConfirmDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.allow_screen_capture),
|
label = stringResource(id = R.string.allow_screen_capture),
|
||||||
isChecked = currentValue,
|
isChecked = currentValue,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
|
|
|
@ -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.BitwardenSnackbarHost
|
||||||
import com.x8bit.bitwarden.ui.platform.components.snackbar.rememberBitwardenSnackbarHostState
|
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.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.nonLetterColorVisualTransformation
|
||||||
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
|
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
import com.x8bit.bitwarden.ui.platform.composition.LocalIntentManager
|
||||||
|
@ -531,7 +531,7 @@ private fun PasswordCapitalLettersToggleItem(
|
||||||
onPasswordToggleCapitalLettersChange: (Boolean) -> Unit,
|
onPasswordToggleCapitalLettersChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = "A—Z",
|
label = "A—Z",
|
||||||
isChecked = useCapitals,
|
isChecked = useCapitals,
|
||||||
onCheckedChange = onPasswordToggleCapitalLettersChange,
|
onCheckedChange = onPasswordToggleCapitalLettersChange,
|
||||||
|
@ -550,7 +550,7 @@ private fun PasswordLowercaseLettersToggleItem(
|
||||||
onPasswordToggleLowercaseLettersChange: (Boolean) -> Unit,
|
onPasswordToggleLowercaseLettersChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = "a—z",
|
label = "a—z",
|
||||||
isChecked = useLowercase,
|
isChecked = useLowercase,
|
||||||
onCheckedChange = onPasswordToggleLowercaseLettersChange,
|
onCheckedChange = onPasswordToggleLowercaseLettersChange,
|
||||||
|
@ -569,7 +569,7 @@ private fun PasswordNumbersToggleItem(
|
||||||
onPasswordToggleNumbersChange: (Boolean) -> Unit,
|
onPasswordToggleNumbersChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = "0-9",
|
label = "0-9",
|
||||||
isChecked = useNumbers,
|
isChecked = useNumbers,
|
||||||
onCheckedChange = onPasswordToggleNumbersChange,
|
onCheckedChange = onPasswordToggleNumbersChange,
|
||||||
|
@ -588,7 +588,7 @@ private fun PasswordSpecialCharactersToggleItem(
|
||||||
onPasswordToggleSpecialCharactersChange: (Boolean) -> Unit,
|
onPasswordToggleSpecialCharactersChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = "!@#$%^&*",
|
label = "!@#$%^&*",
|
||||||
isChecked = useSpecialChars,
|
isChecked = useSpecialChars,
|
||||||
onCheckedChange = onPasswordToggleSpecialCharactersChange,
|
onCheckedChange = onPasswordToggleSpecialCharactersChange,
|
||||||
|
@ -647,7 +647,7 @@ private fun PasswordAvoidAmbiguousCharsToggleItem(
|
||||||
onPasswordToggleAvoidAmbiguousCharsChange: (Boolean) -> Unit,
|
onPasswordToggleAvoidAmbiguousCharsChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.avoid_ambiguous_characters),
|
label = stringResource(id = R.string.avoid_ambiguous_characters),
|
||||||
isChecked = avoidAmbiguousChars,
|
isChecked = avoidAmbiguousChars,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
|
@ -758,7 +758,7 @@ private fun PassphraseCapitalizeToggleItem(
|
||||||
onPassphraseCapitalizeToggleChange: (Boolean) -> Unit,
|
onPassphraseCapitalizeToggleChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.capitalize),
|
label = stringResource(id = R.string.capitalize),
|
||||||
isChecked = capitalize,
|
isChecked = capitalize,
|
||||||
onCheckedChange = onPassphraseCapitalizeToggleChange,
|
onCheckedChange = onPassphraseCapitalizeToggleChange,
|
||||||
|
@ -776,7 +776,7 @@ private fun PassphraseIncludeNumberToggleItem(
|
||||||
onPassphraseIncludeNumberToggleChange: (Boolean) -> Unit,
|
onPassphraseIncludeNumberToggleChange: (Boolean) -> Unit,
|
||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.include_number),
|
label = stringResource(id = R.string.include_number),
|
||||||
isChecked = includeNumber,
|
isChecked = includeNumber,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
|
@ -1127,7 +1127,7 @@ private fun RandomWordCapitalizeToggleItem(
|
||||||
capitalize: Boolean,
|
capitalize: Boolean,
|
||||||
onRandomWordCapitalizeToggleChange: (Boolean) -> Unit,
|
onRandomWordCapitalizeToggleChange: (Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.capitalize),
|
label = stringResource(id = R.string.capitalize),
|
||||||
isChecked = capitalize,
|
isChecked = capitalize,
|
||||||
onCheckedChange = onRandomWordCapitalizeToggleChange,
|
onCheckedChange = onRandomWordCapitalizeToggleChange,
|
||||||
|
@ -1143,7 +1143,7 @@ private fun RandomWordIncludeNumberToggleItem(
|
||||||
includeNumber: Boolean,
|
includeNumber: Boolean,
|
||||||
onRandomWordIncludeNumberToggleChange: (Boolean) -> Unit,
|
onRandomWordIncludeNumberToggleChange: (Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.include_number),
|
label = stringResource(id = R.string.include_number),
|
||||||
isChecked = includeNumber,
|
isChecked = includeNumber,
|
||||||
onCheckedChange = onRandomWordIncludeNumberToggleChange,
|
onCheckedChange = onRandomWordIncludeNumberToggleChange,
|
||||||
|
|
|
@ -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.BitwardenSegmentedButton
|
||||||
import com.x8bit.bitwarden.ui.platform.components.segment.SegmentedButtonState
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
|
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
|
@ -242,7 +242,7 @@ fun AddSendContent(
|
||||||
onValueChange = addSendHandlers.onTextChange,
|
onValueChange = addSendHandlers.onTextChange,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.testTag(tag = "SendHideTextByDefaultToggle")
|
.testTag(tag = "SendHideTextByDefaultToggle")
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
@ -502,7 +502,7 @@ private fun AddSendOptions(
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.testTag("SendHideEmailSwitch")
|
.testTag("SendHideEmailSwitch")
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
@ -514,7 +514,7 @@ private fun AddSendOptions(
|
||||||
enabled = state.common.isHideEmailChecked || state.common.isHideEmailAddressEnabled,
|
enabled = state.common.isHideEmailChecked || state.common.isHideEmailAddressEnabled,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.testTag("SendDeactivateSwitch")
|
.testTag("SendDeactivateSwitch")
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
@ -15,7 +15,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.header.BitwardenListHeaderText
|
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.platform.theme.BitwardenTheme
|
||||||
import com.x8bit.bitwarden.ui.vault.model.VaultCollection
|
import com.x8bit.bitwarden.ui.vault.model.VaultCollection
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ fun LazyListScope.collectionItemsSelector(
|
||||||
if (collectionList?.isNotEmpty() == true) {
|
if (collectionList?.isNotEmpty() == true) {
|
||||||
items(collectionList) {
|
items(collectionList) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = it.name,
|
label = it.name,
|
||||||
isChecked = it.isSelected,
|
isChecked = it.isSelected,
|
||||||
onCheckedChange = { _ ->
|
onCheckedChange = { _ ->
|
||||||
|
|
|
@ -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.field.BitwardenTextField
|
||||||
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
|
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.BitwardenSwitch
|
||||||
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
|
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCardTypeHandlers
|
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCardTypeHandlers
|
||||||
|
@ -214,7 +213,7 @@ fun LazyListScope.vaultAddEditCardItems(
|
||||||
if (commonState.isUnlockWithPasswordEnabled) {
|
if (commonState.isUnlockWithPasswordEnabled) {
|
||||||
item {
|
item {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenSwitchWithActions(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.password_prompt),
|
label = stringResource(id = R.string.password_prompt),
|
||||||
isChecked = commonState.masterPasswordReprompt,
|
isChecked = commonState.masterPasswordReprompt,
|
||||||
onCheckedChange = commonHandlers.onToggleMasterPasswordReprompt,
|
onCheckedChange = commonHandlers.onToggleMasterPasswordReprompt,
|
||||||
|
|
|
@ -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.BitwardenPasswordFieldWithActions
|
||||||
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions
|
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.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.feature.addedit.model.CustomFieldAction
|
||||||
import com.x8bit.bitwarden.ui.vault.model.VaultLinkedFieldType
|
import com.x8bit.bitwarden.ui.vault.model.VaultLinkedFieldType
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
@ -146,7 +146,7 @@ private fun CustomFieldBoolean(
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = label,
|
label = label,
|
||||||
isChecked = value,
|
isChecked = value,
|
||||||
onCheckedChange = onValueChanged,
|
onCheckedChange = onValueChanged,
|
||||||
|
|
|
@ -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.field.BitwardenTextField
|
||||||
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
|
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.BitwardenSwitch
|
||||||
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
|
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
|
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
|
||||||
|
@ -315,7 +314,7 @@ fun LazyListScope.vaultAddEditIdentityItems(
|
||||||
if (commonState.isUnlockWithPasswordEnabled) {
|
if (commonState.isUnlockWithPasswordEnabled) {
|
||||||
item {
|
item {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenSwitchWithActions(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.password_prompt),
|
label = stringResource(id = R.string.password_prompt),
|
||||||
isChecked = commonState.masterPasswordReprompt,
|
isChecked = commonState.masterPasswordReprompt,
|
||||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||||
|
|
|
@ -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.field.BitwardenTextFieldWithActions
|
||||||
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
|
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.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.components.util.rememberVectorPainter
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
||||||
|
@ -235,7 +234,7 @@ fun LazyListScope.vaultAddEditLoginItems(
|
||||||
if (commonState.isUnlockWithPasswordEnabled) {
|
if (commonState.isUnlockWithPasswordEnabled) {
|
||||||
item {
|
item {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenSwitchWithActions(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.password_prompt),
|
label = stringResource(id = R.string.password_prompt),
|
||||||
isChecked = commonState.masterPasswordReprompt,
|
isChecked = commonState.masterPasswordReprompt,
|
||||||
onCheckedChange = commonActionHandler.onToggleMasterPasswordReprompt,
|
onCheckedChange = commonActionHandler.onToggleMasterPasswordReprompt,
|
||||||
|
|
|
@ -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.field.BitwardenTextField
|
||||||
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
|
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.BitwardenSwitch
|
||||||
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitchWithActions
|
|
||||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||||
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
import com.x8bit.bitwarden.ui.vault.components.collectionItemsSelector
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
|
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
|
||||||
|
@ -94,7 +93,7 @@ fun LazyListScope.vaultAddEditSecureNotesItems(
|
||||||
if (commonState.isUnlockWithPasswordEnabled) {
|
if (commonState.isUnlockWithPasswordEnabled) {
|
||||||
item {
|
item {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
BitwardenSwitchWithActions(
|
BitwardenSwitch(
|
||||||
label = stringResource(id = R.string.password_prompt),
|
label = stringResource(id = R.string.password_prompt),
|
||||||
isChecked = commonState.masterPasswordReprompt,
|
isChecked = commonState.masterPasswordReprompt,
|
||||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||||
|
|
|
@ -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.BitwardenTextField
|
||||||
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextFieldWithActions
|
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.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
|
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ fun CustomField(
|
||||||
) {
|
) {
|
||||||
when (customField) {
|
when (customField) {
|
||||||
is VaultItemState.ViewState.Content.Common.Custom.BooleanField -> {
|
is VaultItemState.ViewState.Content.Common.Custom.BooleanField -> {
|
||||||
BitwardenWideSwitch(
|
BitwardenSwitch(
|
||||||
label = customField.name,
|
label = customField.name,
|
||||||
isChecked = customField.value,
|
isChecked = customField.value,
|
||||||
readOnly = true,
|
readOnly = true,
|
||||||
|
|
Loading…
Reference in a new issue