Skip to content

Commit

Permalink
Start adding info table.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 20, 2021
1 parent 1bd19f4 commit 0e6e71f
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 19 deletions.
8 changes: 8 additions & 0 deletions PatientScannerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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 */; };
CEA1556B262F784E0024B7AC /* SelfSizedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */; };
CEA15570262F79DE0024B7AC /* InfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1556F262F79DE0024B7AC /* InfoCell.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 @@ -71,6 +73,8 @@
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>"; };
CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizedTableView.swift; sourceTree = "<group>"; };
CEA1556F262F79DE0024B7AC /* InfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoCell.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 @@ -174,6 +178,8 @@
children = (
CE13CF0E262DD0D80070C80E /* FullFloatingPanelLayout.swift */,
CE13CF22262DDF810070C80E /* RoundedButton.swift */,
CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */,
CEA1556F262F79DE0024B7AC /* InfoCell.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -410,6 +416,7 @@
CEC2C4C42625ED030056E406 /* Base45.swift in Sources */,
CE3CC9442628C2130079FB78 /* CBOR.swift in Sources */,
CE13CF0F262DD0D80070C80E /* FullFloatingPanelLayout.swift in Sources */,
CEA1556B262F784E0024B7AC /* SelfSizedTableView.swift in Sources */,
CE157F81262E1F7A00FE4821 /* Date.swift in Sources */,
CE1BDF99262A4CD600766F97 /* X509.swift in Sources */,
CEA1555D262F63B30024B7AC /* EuDgcSchema.swift in Sources */,
Expand All @@ -422,6 +429,7 @@
CEA15563262F6DAB0024B7AC /* ChildDismissedDelegate.swift in Sources */,
CEFAD8722625F29E009AFEF9 /* String+JSON.swift in Sources */,
CEC2C4C22625ED030056E406 /* ZLib.swift in Sources */,
CEA15570262F79DE0024B7AC /* InfoCell.swift in Sources */,
CEA6D6EE261F8D2700715333 /* SceneDelegate.swift in Sources */,
CE157F9B262E2A9F00FE4821 /* SwiftCBOR.CBOR.swift in Sources */,
);
Expand Down
18 changes: 18 additions & 0 deletions PatientScannerDemo/Components/InfoCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// InfoCell.swift
// PatientScannerDemo
//
// Created by Yannick Spreen on 4/20/21.
//

import UIKit

class InfoCell: UITableViewCell {
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var contentLabel: UILabel!

func draw(_ info: InfoSection) {
headerLabel?.text = info.header
contentLabel?.text = info.content
}
}
25 changes: 25 additions & 0 deletions PatientScannerDemo/Components/SelfSizedTableView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// SelfSizedTableView.swift
// PatientScannerDemo
//
// Created by Yannick Spreen on 4/20/21.
//
// https://dushyant37.medium.com/swift-4-recipe-self-sizing-table-view-2635ac3df8ab
//

import UIKit

class SelfSizedTableView: UITableView {
var maxHeight: CGFloat = UIScreen.main.bounds.size.height

override func reloadData() {
super.reloadData()
self.invalidateIntrinsicContentSize()
self.layoutIfNeeded()
}

override var intrinsicContentSize: CGSize {
let height = min(contentSize.height, maxHeight)
return CGSize(width: contentSize.width, height: height)
}
}
15 changes: 13 additions & 2 deletions PatientScannerDemo/Models/HCert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import Foundation
import SwiftyJSON
import JSONSchema

struct InfoSection {
var header: String
var content: String
}

struct HCert {
init?(from cborData: Data) {
let headerStr = CBOR.header(from: cborData)?.toString() ?? "{}"
Expand Down Expand Up @@ -100,8 +105,14 @@ struct HCert {
var body: JSON

var fullName: String {
let first = body["-259"]["1"]["sub"]["gn"].string ?? ""
let last = body["-259"]["1"]["sub"]["fn"].string ?? ""
let first = body["sub"]["gn"].string ?? ""
let last = body["sub"]["fn"].string ?? ""
return "\(first) \(last)"
}

var info: [InfoSection] {
[
InfoSection(header: "Test", content: "Test Test")
]
}
}
Loading

0 comments on commit 0e6e71f

Please sign in to comment.