Skip to content

Commit

Permalink
Display First Name.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 19, 2021
1 parent 2422448 commit b783c6c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
6 changes: 6 additions & 0 deletions PatientScannerDemo/Models/HCert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ struct HCert {

var header: JSON
var body: JSON

var fullName: String {
let first = body["-259"]["1"]["sub"]["gn"].string ?? ""
let last = body["-259"]["1"]["sub"]["fn"].string ?? ""
return "\(first) \(last)"
}
}
3 changes: 2 additions & 1 deletion PatientScannerDemo/Storyboards/CertificateViewer.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="734"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a9u-Ia-KEX" customClass="RoundedButton" customModule="PatientScannerDemo" customModuleProvider="target">
<rect key="frame" x="149" y="679" width="77" height="51"/>
<rect key="frame" x="161" y="691" width="53" height="39"/>
<color key="backgroundColor" systemColor="systemBlueColor"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<state key="normal" title="Okay">
Expand Down Expand Up @@ -101,6 +101,7 @@
<connections>
<outlet property="loadingBackground" destination="Sd1-4U-jsd" id="oGA-cg-0zT"/>
<outlet property="loadingBackgroundTrailing" destination="Xl8-Re-0ql" id="BX9-az-2fc"/>
<outlet property="nameLabel" destination="DVW-2y-e4I" id="cyN-o4-vZQ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="9ZE-rf-pHy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
Expand Down
2 changes: 2 additions & 0 deletions PatientScannerDemo/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>NSCameraUsageDescription</key>
<string>Scan barcodes with your camera.</string>
<key>CFBundleDevelopmentRegion</key>
Expand Down
12 changes: 12 additions & 0 deletions PatientScannerDemo/ViewControllers/CertificateViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ import FloatingPanel
let DISMISS_TIMEOUT = 15.0

class CertificateViewerVC: UIViewController {
@IBOutlet var nameLabel: UILabel!
@IBOutlet var loadingBackground: UIView!
@IBOutlet var loadingBackgroundTrailing: NSLayoutConstraint!

var hCert: HCert! {
didSet {
self.draw()
}
}

func draw() {
nameLabel.text = hCert.fullName
print(hCert.body)
}

override func viewDidLoad() {
super.viewDidLoad()

Expand Down
17 changes: 9 additions & 8 deletions PatientScannerDemo/ViewControllers/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class ScanVC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// checkPermissions()
// setupCameraLiveView()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.observationHandler(payloadS: nil)
}
checkPermissions()
setupCameraLiveView()
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
// self.observationHandler(payloadS: nil)
// }
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
Expand Down Expand Up @@ -62,7 +62,7 @@ class ScanVC: UIViewController {
//
// }

func presentViewer(for certificate: Any?) {
func presentViewer(for certificate: HCert) {
let fpc = FloatingPanelController()
guard
let contentVC = UIStoryboard(name: "CertificateViewer", bundle: nil)
Expand All @@ -77,6 +77,7 @@ class ScanVC: UIViewController {
fpc.layout = FullFloatingPanelLayout()
fpc.surfaceView.layer.cornerRadius = 24.0
fpc.surfaceView.clipsToBounds = true
viewer.hCert = certificate

present(fpc, animated: true, completion: nil)
}
Expand Down Expand Up @@ -149,7 +150,7 @@ extension ScanVC {
}

func observationHandler(payloadS: String?) {
let payloadS: String? = "HC1:NCFI.LDVNOJ2J52O/SCFR078MG4:T7WNDXC5$OS9/NQ FD*7L$O:XJ345Y13WIRJXRE7RAYOY1UGZJR$1VAWKCI:248D1P%3CQSP7DZ554GVY55:35QOGVERIS2NBA8Y9YTKW/UD4O$02E$0N6DF:1P:MDXO6$V4:EA6GCMTH0DHJTPOEKYTGBND0GG7M76E$*LHO7:W1V.84QM-0JBQ2FAV7X9R-1:X1XLUI8QF2A1$ID$PGFT+JN*UROVD66HD8F4O03F4L25K/NT89*KMX*8RCH7HDI.BZ-OOC68PLIW2Q1U2 PWHJ$OB RJ BGO/CAA6/DP4IOADM+ZO4PSNTLI+Q EQT*6HN67WP.0W19Q620.C0W-6FJV8G34JH09B4FPTU0PWK2JSSXA410:8KUA6RNLW66/3JZADZCM/13:B6LG40+ERQCELE0R9J477G7+830JE3+NB:56URMXA2K4QP0N8AK%0ICW4*A7ZHCQM*G4B2Q$R8%H659U%D9JBVDB1J8VW7U77IDNG2TKH.5-RU5Y5 WBD-EL8NDWDT%GD$2-RLJGRTVD 8M09BK*2-1E6M9H 5RRK5KOM7PI:SLUH026C 8MOL9/J56J40RG/02481972OFQRI:SFGMM:VUYIH.ZJ+7S5+FJ35*-JE7UE4Q1JMQ%FXVF8KN$7TKUJC2D5.0NAMX53K%V7$R9+QE.NA+I1LQ"
// let payloadS: String? = "HC1:NCFI.LDVNOJ2J52O/SCFR078MG4:T7WNDXC5$OS9/NQ FD*7L$O:XJ345Y13WIRJXRE7RAYOY1UGZJR$1VAWKCI:248D1P%3CQSP7DZ554GVY55:35QOGVERIS2NBA8Y9YTKW/UD4O$02E$0N6DF:1P:MDXO6$V4:EA6GCMTH0DHJTPOEKYTGBND0GG7M76E$*LHO7:W1V.84QM-0JBQ2FAV7X9R-1:X1XLUI8QF2A1$ID$PGFT+JN*UROVD66HD8F4O03F4L25K/NT89*KMX*8RCH7HDI.BZ-OOC68PLIW2Q1U2 PWHJ$OB RJ BGO/CAA6/DP4IOADM+ZO4PSNTLI+Q EQT*6HN67WP.0W19Q620.C0W-6FJV8G34JH09B4FPTU0PWK2JSSXA410:8KUA6RNLW66/3JZADZCM/13:B6LG40+ERQCELE0R9J477G7+830JE3+NB:56URMXA2K4QP0N8AK%0ICW4*A7ZHCQM*G4B2Q$R8%H659U%D9JBVDB1J8VW7U77IDNG2TKH.5-RU5Y5 WBD-EL8NDWDT%GD$2-RLJGRTVD 8M09BK*2-1E6M9H 5RRK5KOM7PI:SLUH026C 8MOL9/J56J40RG/02481972OFQRI:SFGMM:VUYIH.ZJ+7S5+FJ35*-JE7UE4Q1JMQ%FXVF8KN$7TKUJC2D5.0NAMX53K%V7$R9+QE.NA+I1LQ"
guard
let payloadString = payloadS,
let compressed = try? String(payloadString.dropFirst(4)).fromBase45()
Expand All @@ -160,7 +161,7 @@ extension ScanVC {
// presentViewer(for: payload)
// print(CBOR.payload(from: data)?.toString() ?? "")
// print(CBOR.header(from: data)?.toString() ?? "")
HCert(from: data)
presentViewer(for: HCert(from: data))
}

}
Expand Down

0 comments on commit b783c6c

Please sign in to comment.