Skip to content

Commit

Permalink
BIT-2278: ID refactor cont.
Browse files Browse the repository at this point in the history
  • Loading branch information
jubie-livefront committed May 8, 2024
1 parent 5dde814 commit de23d49
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ struct ViewCardItemView: View {
if !store.state.cardholderName.isEmpty {
BitwardenTextValueField(
title: Localizations.cardholderName,
value: store.state.cardholderName
value: store.state.cardholderName,
valueAccessibilityIdentifier: "CardholderNameEntry"
)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("CardholderNameEntry")
}
}

Expand All @@ -41,6 +41,7 @@ struct ViewCardItemView: View {
PasswordText(password: number, isPasswordVisible: isVisible)
.styleGuide(.body)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.accessibilityIdentifier("CardNumberEntry")
} accessoryContent: {
PasswordVisibilityButton(
accessibilityIdentifier: "ShowCardNumberButton",
Expand All @@ -63,7 +64,6 @@ struct ViewCardItemView: View {
.accessibilityIdentifier("CopyValueButton")
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("CardNumberEntry")
}
}

Expand Down Expand Up @@ -93,10 +93,10 @@ struct ViewCardItemView: View {
if !expirationString.isEmpty {
BitwardenTextValueField(
title: Localizations.expiration,
value: expirationString
value: expirationString,
valueAccessibilityIdentifier: "CardExpirationYearEntry"
)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("CardExpirationYearEntry")
}
}

Expand All @@ -108,6 +108,7 @@ struct ViewCardItemView: View {
PasswordText(password: code, isPasswordVisible: isVisible)
.styleGuide(.body)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.accessibilityIdentifier("CardSecurityCodeEntry")
} accessoryContent: {
PasswordVisibilityButton(
accessibilityIdentifier: "CardShowSecurityCodeButton",
Expand All @@ -130,7 +131,6 @@ struct ViewCardItemView: View {
.accessibilityIdentifier("CopyValueButton")
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("CardSecurityCodeEntry")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,84 @@ struct ViewIdentityItemView: View {

var body: some View {
if !store.state.identityName.isEmpty {
BitwardenTextValueField(title: Localizations.identityName, value: store.state.identityName)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("ItemNameEntry")
BitwardenTextValueField(
title: Localizations.identityName,
value: store.state.identityName,
valueAccessibilityIdentifier: "ItemNameEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.userName.isEmpty {
BitwardenTextValueField(title: Localizations.username, value: store.state.userName)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityUsernameEntry")
BitwardenTextValueField(
title: Localizations.username,
value: store.state.userName,
valueAccessibilityIdentifier: "IdentityUsernameEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.company.isEmpty {
BitwardenTextValueField(title: Localizations.company, value: store.state.company)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityCompanyEntry")
BitwardenTextValueField(
title: Localizations.company,
value: store.state.company,
valueAccessibilityIdentifier: "IdentityCompanyEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.socialSecurityNumber.isEmpty {
BitwardenTextValueField(title: Localizations.ssn, value: store.state.socialSecurityNumber)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentitySsnEntry")
BitwardenTextValueField(
title: Localizations.ssn,
value: store.state.socialSecurityNumber,
valueAccessibilityIdentifier: "IdentitySsnEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.passportNumber.isEmpty {
BitwardenTextValueField(title: Localizations.passportNumber, value: store.state.passportNumber)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityPassportNumberEntry")
BitwardenTextValueField(
title: Localizations.passportNumber,
value: store.state.passportNumber,
valueAccessibilityIdentifier: "IdentityPassportNumberEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.licenseNumber.isEmpty {
BitwardenTextValueField(title: Localizations.licenseNumber, value: store.state.licenseNumber)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityLicenseNumberEntry")
BitwardenTextValueField(
title: Localizations.licenseNumber,
value: store.state.licenseNumber,
valueAccessibilityIdentifier: "IdentityLicenseNumberEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.email.isEmpty {
BitwardenTextValueField(title: Localizations.email, value: store.state.email)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityEmailEntry")
BitwardenTextValueField(
title: Localizations.email,
value: store.state.email,
valueAccessibilityIdentifier: "IdentityEmailEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.phone.isEmpty {
BitwardenTextValueField(title: Localizations.phone, value: store.state.phone)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityPhoneEntry")
BitwardenTextValueField(
title: Localizations.phone,
value: store.state.phone,
valueAccessibilityIdentifier: "IdentityPhoneEntry"
)
.accessibilityElement(children: .contain)
}

if !store.state.fullAddress.isEmpty {
BitwardenTextValueField(title: Localizations.address, value: store.state.fullAddress)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("IdentityAddressOneEntry")
BitwardenTextValueField(
title: Localizations.address,
value: store.state.fullAddress,
valueAccessibilityIdentifier: "IdentityAddressOneEntry"
)
.accessibilityElement(children: .contain)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ struct ViewItemDetailsView: View {
ForEach(store.state.loginState.uris, id: \.self) { uri in
BitwardenTextValueField(
title: Localizations.uri,
value: URL(string: uri.uri)?.host ?? uri.uri
value: URL(string: uri.uri)?.host ?? uri.uri,
valueAccessibilityIdentifier: "LoginUriEntry"
) {
if let url = URL(string: uri.uri)?.sanitized, url.hasValidURLComponents {
Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ struct ViewLoginItemView: View {
var body: some View {
if !store.state.username.isEmpty {
let username = store.state.username
BitwardenTextValueField(title: Localizations.username, value: username) {
BitwardenTextValueField(
title: Localizations.username,
value: username,
valueAccessibilityIdentifier: "LoginUsernameEntry"
) {
Button {
store.send(.copyPressed(value: username, field: .username))
} label: {
Expand All @@ -33,7 +37,6 @@ struct ViewLoginItemView: View {
.accessibilityIdentifier("LoginCopyUsernameButton")
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("LoginUsernameEntry")
}

if !store.state.password.isEmpty {
Expand All @@ -42,7 +45,7 @@ struct ViewLoginItemView: View {
PasswordText(password: password, isPasswordVisible: store.state.isPasswordVisible)
.styleGuide(.body)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.accessibilityIdentifier("ItemValue")
.accessibilityIdentifier("LoginPasswordEntry")
} accessoryContent: {
if store.state.canViewPassword {
PasswordVisibilityButton(
Expand All @@ -59,7 +62,7 @@ struct ViewLoginItemView: View {
.imageStyle(.accessoryIcon)
}
.accessibilityLabel(Localizations.checkPassword)
.accessibilityIdentifier("LoginCheckPasswordButton")
.accessibilityIdentifier("CheckPasswordButton")

Button {
store.send(.copyPressed(value: password, field: .password))
Expand All @@ -72,7 +75,6 @@ struct ViewLoginItemView: View {
}
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("LoginPasswordEntry")
}

if let fido2Credential = store.state.fido2Credentials.first {
Expand All @@ -84,7 +86,6 @@ struct ViewLoginItemView: View {
)
)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("ItemRow")
}

if !store.state.isTOTPAvailable {
Expand All @@ -95,10 +96,8 @@ struct ViewLoginItemView: View {
Text(Localizations.premiumSubscriptionRequired)
.styleGuide(.footnote)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
.accessibilityIdentifier("ItemValue")
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("LoginTotpEntry")
} else if let totpModel = store.state.totpCode {
BitwardenField(
title: Localizations.verificationCodeTotp,
Expand All @@ -108,7 +107,7 @@ struct ViewLoginItemView: View {
.styleGuide(.bodyMonospaced)
.multilineTextAlignment(.leading)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.accessibilityIdentifier("ItemValue")
.accessibilityIdentifier("LoginTotpEntry")
},
accessoryContent: {
TOTPCountdownTimerView(
Expand All @@ -127,11 +126,10 @@ struct ViewLoginItemView: View {
.imageStyle(.accessoryIcon)
}
.accessibilityLabel(Localizations.copy)
.accessibilityIdentifier("CopyValueButton")
.accessibilityIdentifier("LoginCopyTotpButton")
}
)
.accessibilityElement(children: .contain)
.accessibilityIdentifier("LoginTotpEntry")
}
}
}

0 comments on commit de23d49

Please sign in to comment.