Skip to content

Commit

Permalink
Bugfix FXIOS-10655 ⁃ [Felt privacy-Unified panel] - The name in the C…
Browse files Browse the repository at this point in the history
…ommon Name should be blue and underlined on the certificate sheet (#24199)

FXIOS-10655 #23315 ⁃ [Felt privacy-Unified panel] - The name in the Common Name should be blue and underlined on the certificate sheet
  • Loading branch information
dicarobinho authored Jan 17, 2025
1 parent a87d7b1 commit 9a2cd13
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ final class CertificatesCell: UITableViewCell, ReusableCell, ThemeApplicable {
fatalError("init(coder:) has not been implemented")
}

func configure(theme: Theme, sectionTitle: String, items: CertificateItems) {
func configure(theme: Theme, sectionTitle: String, items: CertificateItems, isIssuerName: Bool = false) {
applyTheme(theme: theme)
sectionLabel.text = sectionTitle
for (key, value) in items {
let isUnderlined = isIssuerName && key == .Menu.EnhancedTrackingProtection.certificateCommonName
let stackView = getSectionItemStackView()
let titleLabel = getItemLabel(theme: theme, with: key, isTitle: true)
let titleLabel = getItemLabel(theme: theme, with: key, isTitle: true, isUnderlined: isUnderlined)
titleLabel.widthAnchor.constraint(equalToConstant: UX.sectionLabelWidth).isActive = true
stackView.addArrangedSubview(titleLabel)
stackView.addArrangedSubview(getItemLabel(theme: theme, with: value, isTitle: false))
stackView.addArrangedSubview(getItemLabel(
theme: theme,
with: value,
isTitle: false,
isUnderlined: isUnderlined
))
allSectionItemsStackView.addArrangedSubview(stackView)
}
}
Expand All @@ -87,15 +93,25 @@ final class CertificatesCell: UITableViewCell, ReusableCell, ThemeApplicable {
sectionLabel.textColor = theme.colors.textPrimary
}

private func getItemLabel(theme: Theme, with title: String, isTitle: Bool) -> UILabel {
let itemLabel: UILabel = .build { label in
label.font = FXFontStyles.Bold.headline.scaledFont()
label.textColor = isTitle ? theme.colors.textSecondary : theme.colors.textPrimary
label.text = title
label.textAlignment = isTitle ? .right : .left
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.accessibilityIdentifier = AccessibilityIdentifiers.EnhancedTrackingProtection.DetailsScreen.itemLabel
private func getItemLabel(theme: Theme, with title: String, isTitle: Bool, isUnderlined: Bool) -> UILabel {
let itemLabel: UILabel = .build()
itemLabel.font = FXFontStyles.Bold.headline.scaledFont()
itemLabel.textAlignment = isTitle ? .right : .left
itemLabel.numberOfLines = 0
itemLabel.lineBreakMode = .byWordWrapping
itemLabel.accessibilityIdentifier = AccessibilityIdentifiers.EnhancedTrackingProtection.DetailsScreen.itemLabel
if isUnderlined, !isTitle {
let attributedString = NSAttributedString(
string: title,
attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue
]
)
itemLabel.textColor = theme.colors.textAccent
itemLabel.attributedText = attributedString
} else {
itemLabel.textColor = isTitle ? theme.colors.textSecondary : theme.colors.textPrimary
itemLabel.text = title
}
return itemLabel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class CertificatesViewController: UIViewController,
sectionTitle: .Menu.EnhancedTrackingProtection.certificateIssuerName,
items: [(.Menu.EnhancedTrackingProtection.certificateIssuerCountry, country),
(.Menu.EnhancedTrackingProtection.certificateIssuerOrganization, organization),
(.Menu.EnhancedTrackingProtection.certificateCommonName, commonName)])
(.Menu.EnhancedTrackingProtection.certificateCommonName, commonName)],
isIssuerName: true)
}

case .validity:
Expand Down

0 comments on commit 9a2cd13

Please sign in to comment.