Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum EventType: Int, Codable, Sendable {
case cipherSoftDeleted = 1115
case cipherRestored = 1116
case cipherClientToggledCardNumberVisible = 1117
// need to add case for ssn?

case collectionCreated = 1300
case collectionUpdated = 1301
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct IdentityItemState: Equatable {
/// The social security number for this item.
var socialSecurityNumber: String = ""

/// A flag indicating if the social security number field is visible.
var showSocialSecurityNumber: Bool = false

/// The passport number for this item.
var passportNumber: String = ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,25 @@ struct ViewIdentityItemView: View {
ContentBlock {
if !store.state.socialSecurityNumber.isEmpty {
let socialSecurityNumber = store.state.socialSecurityNumber
BitwardenTextValueField(
title: Localizations.ssn,
value: socialSecurityNumber,
valueAccessibilityIdentifier: "IdentitySsnEntry",
copyButtonAccessibilityIdentifier: "IdentityCopySsnButton",
copyButtonAction: { store.send(
.copyPressed(
value: socialSecurityNumber,
field: .socialSecurityNumber
)
)
BitwardenField(title: Localizations.ssn) {
PasswordText(password: socialSecurityNumber, isPasswordVisible: store.state.showSocialSecurityNumber)
.styleGuide(.body)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.accessibilityIdentifier("IdentitySsnEntry")
} accessoryContent: {
PasswordVisibilityButton(isPasswordVisible: store.state.showSocialSecurityNumber) {
store.send(.ssnVisibilityPressed)
}
)

Button {
store.send(.copyPressed(value: socialSecurityNumber, field: .socialSecurityNumber))
} label: {
Asset.Images.copy24.swiftUIImage
.imageStyle(.accessoryIcon24)
}
.accessibilityLabel(Localizations.copy)
.accessibilityIdentifier("IdentityCopySsnButton")
}
.accessibilityElement(children: .contain)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ enum ViewItemAction: Equatable, Sendable {
/// The toast was shown or hidden.
case toastShown(Toast?)

/// The SSN visiblity button was pressed
case ssnVisibilityPressed

/// A flag indicating if this action requires the user to reenter their master password to
/// complete. This value works hand-in-hand with the `isMasterPasswordRequired` value in
/// `ViewItemState`.
Expand All @@ -53,7 +56,8 @@ enum ViewItemAction: Equatable, Sendable {
.editPressed,
.morePressed,
.passwordVisibilityPressed,
.sshKeyItemAction:
.sshKeyItemAction,
.ssnVisibilityPressed:
true
case let .copyPressed(_, field):
field.requiresMasterPasswordReprompt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ final class ViewItemProcessor: StateProcessor<ViewItemState, ViewItemAction, Vie
handleSSHKeyAction(sshKeyAction)
case let .toastShown(newValue):
state.toast = newValue
case .ssnVisibilityPressed:
guard case var .data(cipherState) = state.loadingState else {
services.errorReporter.log(
error: ActionError.dataNotLoaded("Cannot toggle ssn for non-loaded item.")
)
return
}
cipherState.identityState.showSocialSecurityNumber.toggle()
state.loadingState = .data(cipherState)
// if cipherState.identityState.showSocialSecurityNumber {
// Task {
// await services.eventService.collect(
// )
// }
// }
return
}
}
}
Expand Down
Loading