diff --git a/Localization/SwiftDGC/en.xcloc/Localized Contents/en.xliff b/Localization/SwiftDGC/en.xcloc/Localized Contents/en.xliff index 258523f..b593fc6 100644 --- a/Localization/SwiftDGC/en.xcloc/Localized Contents/en.xliff +++ b/Localization/SwiftDGC/en.xcloc/Localized Contents/en.xliff @@ -1838,6 +1838,11 @@ Issuer Country + + Name + Name + + diff --git a/Localization/SwiftDGC/en.xcloc/Sources/SupportingFiles/en.lproj/Localizable.strings b/Localization/SwiftDGC/en.xcloc/Sources/SupportingFiles/en.lproj/Localizable.strings index ba7fd8c..9fb10a6 100644 --- a/Localization/SwiftDGC/en.xcloc/Sources/SupportingFiles/en.lproj/Localizable.strings +++ b/Localization/SwiftDGC/en.xcloc/Sources/SupportingFiles/en.lproj/Localizable.strings @@ -398,3 +398,4 @@ "country.ZM" = "Zambia"; "country.ZW" = "Zimbabwe"; "issuer.country" = "Issuer Country"; +"section.name" = "Name"; diff --git a/Sources/Models/HCert.swift b/Sources/Models/HCert.swift index 3c84be8..8d16010 100644 --- a/Sources/Models/HCert.swift +++ b/Sources/Models/HCert.swift @@ -371,24 +371,48 @@ public struct HCert { ] } } - if let last = get(.lastNameStandardized).string { - info += [ - InfoSection( - header: l10n("header.std-fn"), - content: last.replacingOccurrences( + var fullName = "" + if let last = get(.lastName).string { + fullName = fullName + last.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstName).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } + + if fullName.isEmpty { + if let last = get(.lastNameStandardized).string { + fullName = fullName + last.replacingOccurrences( of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), - style: .fixedWidthFont - ) - ] + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstNameStandardized).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } } - if let first = get(.firstNameStandardized).string { + + if !fullName.isEmpty { info += [ InfoSection( - header: l10n("header.std-gn"), - content: first.replacingOccurrences( - of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), + header: l10n("section.name"), + content: fullName, style: .fixedWidthFont ) ] @@ -419,24 +443,48 @@ public struct HCert { ] } } - if let last = get(.lastNameStandardized).string { - info += [ - InfoSection( - header: l10n("header.std-fn"), - content: last.replacingOccurrences( + var fullName = "" + if let last = get(.lastName).string { + fullName = fullName + last.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstName).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } + + if fullName.isEmpty { + if let last = get(.lastNameStandardized).string { + fullName = fullName + last.replacingOccurrences( of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), - style: .fixedWidthFont - ) - ] + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstNameStandardized).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } } - if let first = get(.firstNameStandardized).string { + + if !fullName.isEmpty { info += [ InfoSection( - header: l10n("header.std-gn"), - content: first.replacingOccurrences( - of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), + header: l10n("section.name"), + content: fullName, style: .fixedWidthFont ) ] @@ -467,24 +515,48 @@ public struct HCert { ] } } - if let last = get(.lastNameStandardized).string { - info += [ - InfoSection( - header: l10n("header.std-fn"), - content: last.replacingOccurrences( + var fullName = "" + if let last = get(.lastName).string { + fullName = fullName + last.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstName).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } + + if fullName.isEmpty { + if let last = get(.lastNameStandardized).string { + fullName = fullName + last.replacingOccurrences( of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), - style: .fixedWidthFont - ) - ] + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + if let first = get(.firstNameStandardized).string { + if !fullName.isEmpty { + fullName = fullName + " " + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } else { + fullName = fullName + first.replacingOccurrences( + of: "<", + with: String.zeroWidthSpace + "<" + String.zeroWidthSpace) + } + } } - if let first = get(.firstNameStandardized).string { + + if !fullName.isEmpty { info += [ InfoSection( - header: l10n("header.std-gn"), - content: first.replacingOccurrences( - of: "<", - with: String.zeroWidthSpace + "<" + String.zeroWidthSpace), + header: l10n("section.name"), + content: fullName, style: .fixedWidthFont ) ] diff --git a/Sources/ViewControllers/Scan.swift b/Sources/ViewControllers/Scan.swift index a7a05cc..aee9d49 100644 --- a/Sources/ViewControllers/Scan.swift +++ b/Sources/ViewControllers/Scan.swift @@ -41,7 +41,8 @@ public protocol ScanVCDelegate: AnyObject { open class ScanVC: UIViewController { var captureSession: AVCaptureSession? public weak var delegate: ScanVCDelegate? - + public var applicationType: AppType = .verifier + lazy var detectBarcodeRequest = VNDetectBarcodesRequest { request, error in guard error == nil else { self.showAlert(withTitle: l10n("err.barcode"), message: error?.localizedDescription ?? l10n("err.misc")) @@ -237,7 +238,7 @@ extension ScanVC { } func observationHandler(payloadS: String?) { - if var hCert = HCert(from: payloadS ?? "") { + if var hCert = HCert(from: payloadS ?? "", applicationType: applicationType) { hCert.ruleCountryCode = getSelectedCountryCode() delegate?.hCertScanned(hCert) }