Rename BitwardenPolicyWarning to BitwardenInfoCalloutCard (#4048)

This commit is contained in:
David Perez 2024-10-08 11:49:16 -05:00 committed by GitHub
parent 49d9a46917
commit 94791b4256
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 33 additions and 53 deletions

View file

@ -24,7 +24,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@ -32,6 +31,7 @@ import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
@ -40,8 +40,6 @@ 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.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* The top level composable for the Reset Password screen.
@ -167,10 +165,8 @@ private fun ResetPasswordScreenContent(
} else {
R.string.update_master_password_warning
}
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = instructionsTextId),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth(),
@ -184,10 +180,8 @@ private fun ResetPasswordScreenContent(
)
.plus(state.policies.map { it() })
.joinToString("\n")
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = passwordPolicyContent,
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth(),

View file

@ -24,13 +24,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
@ -38,7 +38,6 @@ 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.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
@ -130,10 +129,8 @@ private fun SetPasswordScreenContent(
Spacer(modifier = Modifier.height(16.dp))
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.reset_password_auto_enroll_invite_warning),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth(),

View file

@ -1,4 +1,4 @@
package com.x8bit.bitwarden.ui.platform.components.text
package com.x8bit.bitwarden.ui.platform.components.card
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
@ -6,31 +6,26 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* Represents a Bitwarden-styled policy warning label.
* Represents a Bitwarden-styled info callout.
*
* @param text The text content for the policy warning.
* @param textAlign The text alignment to use.
* @param style The text style to use.
* @param modifier The [Modifier] to be applied to the label.
*/
@Composable
fun BitwardenPolicyWarningText(
fun BitwardenInfoCalloutCard(
text: String,
modifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Center,
style: TextStyle = BitwardenTheme.typography.bodySmall,
) {
Text(
text = text,
textAlign = textAlign,
style = style,
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = modifier
.background(
@ -43,8 +38,8 @@ fun BitwardenPolicyWarningText(
@Preview
@Composable
private fun BitwardenPolicyWarningText_preview() {
BitwardenPolicyWarningText(
private fun BitwardenInfoCallout_preview() {
BitwardenInfoCalloutCard(
text = "text",
)
}

View file

@ -41,6 +41,7 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.badge.NotificationBadge
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenActionCard
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.card.actionCardExitAnimation
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
@ -55,7 +56,6 @@ 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.text.BitwardenPolicyWarningText
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
@ -462,7 +462,7 @@ private fun SessionTimeoutPolicyRow(
R.string.vault_timeout_policy_with_action_in_effect.asText(hours, minutes, action)
}
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = policyText(),
modifier = modifier,
)

View file

@ -37,6 +37,7 @@ import com.x8bit.bitwarden.ui.auth.feature.completeregistration.PasswordStrength
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledTonalButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
@ -45,7 +46,6 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectButton
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.text.BitwardenPolicyWarningText
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.exportvault.model.ExportVaultFormat
@ -206,7 +206,7 @@ private fun ExportVaultScreenContent(
) {
if (state.policyPreventsExport) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.disable_personal_vault_export_policy_in_effect),
modifier = Modifier
.testTag("DisablePrivateVaultPolicyLabel")

View file

@ -43,6 +43,7 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflo
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledIconButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectButton
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
@ -52,7 +53,6 @@ import com.x8bit.bitwarden.ui.platform.components.model.TooltipData
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
import com.x8bit.bitwarden.ui.platform.components.slider.BitwardenSlider
import com.x8bit.bitwarden.ui.platform.components.stepper.BitwardenStepper
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.util.nonLetterColorVisualTransformation
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
@ -314,7 +314,7 @@ private fun ScrollContent(
) {
if (state.isUnderPolicy) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.password_generator_policy_in_effect),
modifier = Modifier
.testTag("PasswordGeneratorPolicyInEffectLabel")

View file

@ -13,11 +13,11 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderTextWithSupportLabel
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenGroupItem
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.tools.feature.send.handlers.SendHandlers
import kotlinx.collections.immutable.toImmutableList
@ -36,7 +36,7 @@ fun SendContent(
LazyColumn(modifier = modifier) {
item {
if (policyDisablesSend) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_disabled_warning),
modifier = Modifier
.testTag("SendOptionsPolicyInEffectLabel")

View file

@ -17,7 +17,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledTonalButton
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
@ -34,7 +34,7 @@ fun SendEmpty(
modifier = modifier.verticalScroll(rememberScrollState()),
) {
if (policyDisablesSend) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_disabled_warning),
modifier = Modifier
.padding(horizontal = 16.dp)

View file

@ -35,13 +35,13 @@ import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledTonalButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
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.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.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
@ -73,7 +73,7 @@ fun AddSendContent(
.verticalScroll(rememberScrollState()),
) {
if (policyDisablesSend) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_disabled_warning),
modifier = Modifier
.padding(horizontal = 16.dp)
@ -83,7 +83,7 @@ fun AddSendContent(
}
if (policySendOptionsInEffect) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_options_policy_in_effect),
modifier = Modifier
.testTag("SendOptionsPolicyInEffectLabel")

View file

@ -13,9 +13,9 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectButton
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCardTypeHandlers
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
@ -55,7 +55,7 @@ fun VaultAddEditContent(
LazyColumn(modifier = modifier) {
item {
if (state.isIndividualVaultDisabled && isAddItemMode) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(R.string.personal_ownership_policy_in_effect),
modifier = Modifier
.padding(horizontal = 16.dp)

View file

@ -15,9 +15,9 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPasswordDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.divider.BitwardenHorizontalDivider
@ -26,9 +26,7 @@ import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenGroupItem
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenListItem
import com.x8bit.bitwarden.ui.platform.components.listitem.SelectionItemData
import com.x8bit.bitwarden.ui.platform.components.model.toIconResources
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.toPersistentList
@ -81,7 +79,7 @@ fun VaultItemListingContent(
is ListingItemOverflowAction.VaultAction.ViewClick,
is ListingItemOverflowAction.VaultAction.CopyTotpClick,
null,
-> Unit
-> Unit
}
var masterPasswordRepromptData by remember { mutableStateOf<MasterPasswordRepromptData?>(null) }
@ -106,10 +104,8 @@ fun VaultItemListingContent(
item {
if (showAddTotpBanner) {
Spacer(modifier = Modifier.height(height = 12.dp))
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.add_this_authenticator_key_to_a_login),
style = BitwardenTheme.typography.bodyMedium,
textAlign = TextAlign.Start,
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth(),
@ -120,7 +116,7 @@ fun VaultItemListingContent(
item {
if (policyDisablesSend) {
Spacer(modifier = Modifier.height(height = 12.dp))
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_disabled_warning),
modifier = Modifier
.padding(horizontal = 16.dp)

View file

@ -22,7 +22,7 @@ import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButtonWithIcon
import com.x8bit.bitwarden.ui.platform.components.text.BitwardenPolicyWarningText
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
@ -43,7 +43,7 @@ fun VaultNoItems(
horizontalAlignment = Alignment.CenterHorizontally,
) {
if (policyDisablesSend) {
BitwardenPolicyWarningText(
BitwardenInfoCalloutCard(
text = stringResource(id = R.string.send_disabled_warning),
modifier = Modifier
.standardHorizontalMargin()
@ -101,7 +101,6 @@ fun VaultNoItems(
@Composable
private fun VaultNoItems_preview() {
BitwardenTheme {
Column(
modifier = Modifier.background(BitwardenTheme.colorScheme.background.primary),
) {
@ -118,7 +117,6 @@ private fun VaultNoItems_preview() {
@Composable
private fun VaultNoItemsPolicyDisabled_preview() {
BitwardenTheme {
Column(
modifier = Modifier.background(BitwardenTheme.colorScheme.background.primary),
) {