PM-25654: Update premium dialog for attachments (#6663)

This commit is contained in:
David Perez
2026-03-13 18:08:40 +00:00
committed by GitHub
parent 8707a8db95
commit 53afde1509
9 changed files with 28 additions and 21 deletions
@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -19,7 +18,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.bitwarden.ui.platform.base.util.cardStyle
import com.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
import com.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.bitwarden.ui.platform.components.model.CardStyle
import com.bitwarden.ui.platform.resource.BitwardenDrawable
@@ -34,6 +32,7 @@ import com.bitwarden.ui.platform.theme.BitwardenTheme
fun AttachmentItemContent(
attachmentItem: VaultItemState.ViewState.Content.Common.AttachmentItem,
onAttachmentDownloadClick: (VaultItemState.ViewState.Content.Common.AttachmentItem) -> Unit,
onUpgradeToPremiumClick: () -> Unit,
cardStyle: CardStyle,
modifier: Modifier = Modifier,
) {
@@ -91,24 +90,17 @@ fun AttachmentItemContent(
}
if (shouldShowPremiumWarningDialog) {
AlertDialog(
BitwardenTwoButtonDialog(
title = stringResource(id = BitwardenString.attachments_unavailable),
message = stringResource(id = BitwardenString.attachments_are_a_premium_feature),
confirmButtonText = stringResource(id = BitwardenString.upgrade_to_premium),
dismissButtonText = stringResource(id = BitwardenString.cancel),
onConfirmClick = {
shouldShowPremiumWarningDialog = false
onUpgradeToPremiumClick()
},
onDismissClick = { shouldShowPremiumWarningDialog = false },
onDismissRequest = { shouldShowPremiumWarningDialog = false },
confirmButton = {
BitwardenTextButton(
label = stringResource(BitwardenString.okay),
onClick = { shouldShowPremiumWarningDialog = false },
)
},
text = {
Text(
text = stringResource(BitwardenString.premium_required),
style = BitwardenTheme.typography.bodyMedium,
)
},
containerColor = BitwardenTheme.colorScheme.background.primary,
iconContentColor = BitwardenTheme.colorScheme.icon.secondary,
titleContentColor = BitwardenTheme.colorScheme.text.primary,
textContentColor = BitwardenTheme.colorScheme.text.primary,
)
}
@@ -300,6 +300,7 @@ fun VaultItemCardContent(
attachmentItem = attachmentItem,
onAttachmentDownloadClick = vaultCommonItemTypeHandlers
.onAttachmentDownloadClick,
onUpgradeToPremiumClick = vaultCommonItemTypeHandlers.onUpgradeToPremiumClick,
cardStyle = attachments.toListItemCardStyle(index = index),
)
}
@@ -361,6 +361,7 @@ fun VaultItemIdentityContent(
attachmentItem = attachmentItem,
onAttachmentDownloadClick = vaultCommonItemTypeHandlers
.onAttachmentDownloadClick,
onUpgradeToPremiumClick = vaultCommonItemTypeHandlers.onUpgradeToPremiumClick,
cardStyle = attachments.toListItemCardStyle(index = index),
)
}
@@ -266,6 +266,7 @@ fun VaultItemLoginContent(
cardStyle = attachments.toListItemCardStyle(index = index),
onAttachmentDownloadClick = vaultCommonItemTypeHandlers
.onAttachmentDownloadClick,
onUpgradeToPremiumClick = vaultCommonItemTypeHandlers.onUpgradeToPremiumClick,
)
}
}
@@ -148,6 +148,7 @@ fun VaultItemSecureNoteContent(
attachmentItem = attachmentItem,
onAttachmentDownloadClick = vaultCommonItemTypeHandlers
.onAttachmentDownloadClick,
onUpgradeToPremiumClick = vaultCommonItemTypeHandlers.onUpgradeToPremiumClick,
cardStyle = attachments.toListItemCardStyle(index = index),
)
}
@@ -233,6 +233,7 @@ fun VaultItemSshKeyContent(
attachmentItem = attachmentItem,
onAttachmentDownloadClick = vaultCommonItemTypeHandlers
.onAttachmentDownloadClick,
onUpgradeToPremiumClick = vaultCommonItemTypeHandlers.onUpgradeToPremiumClick,
cardStyle = attachments.toListItemCardStyle(index = index),
)
}
@@ -19,6 +19,7 @@ data class VaultCommonItemTypeHandlers(
val onAttachmentDownloadClick: (VaultItemState.ViewState.Content.Common.AttachmentItem) -> Unit,
val onCopyNotesClick: () -> Unit,
val onPasswordHistoryClick: () -> Unit,
val onUpgradeToPremiumClick: () -> Unit,
) {
@Suppress("UndocumentedPublicClass")
companion object {
@@ -56,6 +57,9 @@ data class VaultCommonItemTypeHandlers(
onPasswordHistoryClick = {
viewModel.trySendAction(VaultItemAction.Common.PasswordHistoryClick)
},
onUpgradeToPremiumClick = {
viewModel.trySendAction(VaultItemAction.Common.UpgradeToPremiumClick)
},
)
}
}
@@ -767,17 +767,21 @@ class VaultItemScreenTest : BitwardenComposeTest() {
composeTestRule
.onAllNodesWithText(
"A premium membership is required to use this feature.",
text = "Attachments are a Premium feature. " +
"Your current plan does not include access to this feature.",
)
.filterToOne(hasAnyAncestor(isDialog()))
.assertIsDisplayed()
composeTestRule
.onAllNodesWithText(text = "Okay")
.onAllNodesWithText(text = "Upgrade to premium")
.filterToOne(hasAnyAncestor(isDialog()))
.performClick()
composeTestRule.assertNoDialogExists()
verify(exactly = 1) {
viewModel.trySendAction(VaultItemAction.Common.UpgradeToPremiumClick)
}
}
@Suppress("MaxLineLength")
+2
View File
@@ -200,6 +200,8 @@ Scanning will happen automatically.</string>
<string name="copy_totp_automatically">Copy TOTP automatically</string>
<string name="premium_required">A premium membership is required to use this feature.</string>
<string name="attachment_deleted">Attachment deleted</string>
<string name="attachments_unavailable">Attachments unavailable</string>
<string name="attachments_are_a_premium_feature">Attachments are a Premium feature. Your current plan does not include access to this feature.</string>
<string name="choose_file">Choose file</string>
<string name="file">File</string>
<string name="no_file_chosen">No file chosen</string>