Skip to content

Commit

Permalink
fixed wallet scaner (#93)
Browse files Browse the repository at this point in the history
* fixed wallet scanner

* fixed name section

Co-authored-by: Alexandr Chernyy <[email protected]>
  • Loading branch information
alexchornyi and pingus-nikalex authored Jul 29, 2021
1 parent fb82652 commit ea7f671
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 44 deletions.
5 changes: 5 additions & 0 deletions Localization/SwiftDGC/en.xcloc/Localized Contents/en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,11 @@
<target>Issuer Country</target>
<note/>
</trans-unit>
<trans-unit id="section.name" xml:space="preserve">
<source>Name</source>
<target>Name</target>
<note/>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,4 @@
"country.ZM" = "Zambia";
"country.ZW" = "Zimbabwe";
"issuer.country" = "Issuer Country";
"section.name" = "Name";
156 changes: 114 additions & 42 deletions Sources/Models/HCert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
]
Expand Down Expand Up @@ -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
)
]
Expand Down Expand Up @@ -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
)
]
Expand Down
5 changes: 3 additions & 2 deletions Sources/ViewControllers/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit ea7f671

Please sign in to comment.