Skip to content

Commit

Permalink
Only show one viewer at a time.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 20, 2021
1 parent e6bb53c commit 1c2f4d3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
12 changes: 12 additions & 0 deletions PatientScannerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
CE7DE7FA2625EF18007E6694 /* SwiftCBOR in Frameworks */ = {isa = PBXBuildFile; productRef = CE7DE7F92625EF18007E6694 /* SwiftCBOR */; };
CEA15558262F639C0024B7AC /* JSONSchema in Frameworks */ = {isa = PBXBuildFile; productRef = CEA15557262F639C0024B7AC /* JSONSchema */; };
CEA1555D262F63B30024B7AC /* EuDgcSchema.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */; };
CEA15563262F6DAB0024B7AC /* ChildDismissedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA15562262F6DAB0024B7AC /* ChildDismissedDelegate.swift */; };
CEA6D6EC261F8D2700715333 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA6D6EB261F8D2700715333 /* AppDelegate.swift */; };
CEA6D6EE261F8D2700715333 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA6D6ED261F8D2700715333 /* SceneDelegate.swift */; };
CEA6D6F0261F8D2700715333 /* Scan.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA6D6EF261F8D2700715333 /* Scan.swift */; };
Expand Down Expand Up @@ -69,6 +70,7 @@
CE3CC93B2628A7820079FB78 /* ASN1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ASN1.swift; sourceTree = "<group>"; };
CE3CC9432628C2130079FB78 /* CBOR.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CBOR.swift; sourceTree = "<group>"; };
CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EuDgcSchema.swift; sourceTree = "<group>"; };
CEA15562262F6DAB0024B7AC /* ChildDismissedDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChildDismissedDelegate.swift; sourceTree = "<group>"; };
CEA6D6E8261F8D2700715333 /* PatientScannerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PatientScannerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
CEA6D6EB261F8D2700715333 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CEA6D6ED261F8D2700715333 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -196,6 +198,14 @@
path = Models;
sourceTree = "<group>";
};
CEA15561262F6DA10024B7AC /* Protocols */ = {
isa = PBXGroup;
children = (
CEA15562262F6DAB0024B7AC /* ChildDismissedDelegate.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
CEA6D6DF261F8D2700715333 = {
isa = PBXGroup;
children = (
Expand All @@ -219,6 +229,7 @@
CEA6D6EA261F8D2700715333 /* PatientScannerDemo */ = {
isa = PBXGroup;
children = (
CEA15561262F6DA10024B7AC /* Protocols */,
CE157F8B262E24EC00FE4821 /* Models */,
CE13CF1E262DDE800070C80E /* SupportingFiles */,
CE13CF1D262DDE730070C80E /* Components */,
Expand Down Expand Up @@ -408,6 +419,7 @@
CEFAD86D2625F164009AFEF9 /* Signature.swift in Sources */,
CE13CF23262DDF810070C80E /* RoundedButton.swift in Sources */,
CEA6D6EC261F8D2700715333 /* AppDelegate.swift in Sources */,
CEA15563262F6DAB0024B7AC /* ChildDismissedDelegate.swift in Sources */,
CEFAD8722625F29E009AFEF9 /* String+JSON.swift in Sources */,
CEC2C4C22625ED030056E406 /* ZLib.swift in Sources */,
CEA6D6EE261F8D2700715333 /* SceneDelegate.swift in Sources */,
Expand Down
12 changes: 12 additions & 0 deletions PatientScannerDemo/Protocols/ChildDismissedDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ChildDismissedDelegate.swift
// PatientScannerDemo
//
// Created by Yannick Spreen on 4/20/21.
//

import Foundation

protocol ChildDismissedDelegate {
func childDismissed()
}
9 changes: 8 additions & 1 deletion PatientScannerDemo/ViewControllers/CertificateViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class CertificateViewerVC: UIViewController {
}
}

var childDismissedDelegate: ChildDismissedDelegate?

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

override func viewDidLoad() {
Expand All @@ -47,6 +48,12 @@ class CertificateViewerVC: UIViewController {
return
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

childDismissedDelegate?.childDismissed()
}

@IBAction
func closeButton() {
dismiss(animated: true, completion: nil)
Expand Down
18 changes: 15 additions & 3 deletions PatientScannerDemo/ViewControllers/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class ScanVC: UIViewController {
super.viewWillDisappear(animated)
captureSession.stopRunning()
}

// let curve: EllipticCurve = .prime256v1
let name: String = "ECDSA"
var presentingViewer: CertificateViewerVC?

// Send the base64URLencoded signature and `header.claims` to BlueECC for verification.
// func verifySignature(key: Data, signature: Data, for data: Data) -> Bool {
Expand All @@ -62,22 +64,26 @@ class ScanVC: UIViewController {
//
// }

func presentViewer(for certificate: HCert) {
let fpc = FloatingPanelController()
func presentViewer(for certificate: HCert?) {
guard
presentingViewer == nil,
let certificate = certificate,
let contentVC = UIStoryboard(name: "CertificateViewer", bundle: nil)
.instantiateInitialViewController(),
let viewer = contentVC as? CertificateViewerVC
else {
return
}

let fpc = FloatingPanelController()
fpc.set(contentViewController: viewer)
fpc.isRemovalInteractionEnabled = true // Let it removable by a swipe-down
fpc.layout = FullFloatingPanelLayout()
fpc.surfaceView.layer.cornerRadius = 24.0
fpc.surfaceView.clipsToBounds = true
viewer.hCert = certificate
viewer.childDismissedDelegate = self
presentingViewer = viewer

present(fpc, animated: true, completion: nil)
}
Expand Down Expand Up @@ -150,7 +156,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? = payloadS ?? "HC1:NCFI.L:9QL$Q9S2CB9SSVYUDU+SOT0I7UTLPI2S6/O0HEWAH7SHMSHCYRVKPXL7MVJ6WCY2MO:UQRQ5NGN/KSXPT8FQI4M+KLDP554CGTKSVLJTZTJB774-3F5RGGU0FU*%FG38HEVZ-RG4ORST6WTK3703T625M/UF3O.$NYQL4KOQZVQ$D.BRFGD62R9 MH16V3O$NK2DB/M9HXHT3T7X9Y4I:X1VEM94DM6LNI9E4TFR6S3K%P6QVJ3 C$Z3H60HA2XN2ZXKQLIW$5I126A4ALRFQD-5Q%668PLIW2VY9O6TNS9Q$DTP57EO2XMY122*SEES:57/ O/SKCO9DWAV6A4$1VH6MYP5:QBXUHB0TI1MKE*3PWJD0%4Y2D0F4YOEMSJ-:2WVR820.+7T948MLW66/3JMOQ8%SNDCO O*KHX$6Y5IDRP*%CYYSF63MICGKPOKUG8O8QT4JAI%1S62ZY8QFJ%:3MRL:839 CXX864K1MH0UCK.NUR4:NQ2S4-L5L+H$SV/G5NK7 7F-8A73D8-S3/HYGNH6CDYDCBM7VRJFOZWT2SFJ*O8YMO8WQHR*9D:/3$01DI7M45TKBU:FG3QSZA4COD8UU3ISPSN:42$3FM1Q.3V26L7NO1KFTRPQM0SIA8S5*52ZDBLBN-N-XF*9WPVQ.7O*LBZFJ3HEY 8W3O6RA2RNVFVU VV4WR6ONAD%GR"
guard
let payloadString = payloadS,
let compressed = try? String(payloadString.dropFirst(4)).fromBase45()
Expand Down Expand Up @@ -209,3 +215,9 @@ extension ScanVC {
)
}
}

extension ScanVC: ChildDismissedDelegate {
func childDismissed() {
presentingViewer = nil
}
}

0 comments on commit 1c2f4d3

Please sign in to comment.