Skip to content

Commit

Permalink
Business rules (#104)
Browse files Browse the repository at this point in the history
* busines rules

* fixed merge conflicts

* added show errors for open result
refactoring code

* optimizing code

* fixed issueCode for external parameter

* Fixed context

* done rule validation

* fixed branch

* fixed rules sorting

* fixed rule sorting

* added Filtering class from CertLogic

* added hash value checking for downloaded data

* fixed some issues

* new version 1.1.6

Co-authored-by: Alexandr Chernyy <[email protected]>
  • Loading branch information
alexchornyi and pingus-nikalex authored Jul 16, 2021
1 parent f043892 commit c29a0f2
Show file tree
Hide file tree
Showing 25 changed files with 1,435 additions and 130 deletions.
175 changes: 143 additions & 32 deletions DGCAVerifier.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,30 @@
"version": "5.4.3"
}
},
{
"package": "ASN1Decoder",
"repositoryURL": "https://github.com/filom/ASN1Decoder",
"state": {
"branch": null,
"revision": "65953a42a0f039f53c73e48fd88c02809f7db607",
"version": "1.8.0"
}
},
{
"package": "CertLogic",
"repositoryURL": "https://github.com/eu-digital-green-certificates/dgc-certlogic-ios",
"state": {
"branch": "main",
"revision": "8b7f86a2aed4f2c60dd2c7c4f28eb129d9fe379d",
"version": null
}
},
{
"package": "SwiftDGC",
"repositoryURL": "https://github.com/eu-digital-green-certificates/dgca-app-core-ios",
"repositoryURL": "https://github.com/eu-digital-green-certificates/dgca-app-core-ios.git",
"state": {
"branch": "main",
"revision": "91775cfc517331d39196dbdac26cff1a40eb9c71",
"revision": "1dbcdb800312a7986404ec76764ed592aa895875",
"version": null
}
},
Expand All @@ -28,6 +46,15 @@
"version": "2.4.0"
}
},
{
"package": "jsonlogic",
"repositoryURL": "https://github.com/eu-digital-green-certificates/json-logic-swift.git",
"state": {
"branch": null,
"revision": "8dc339147b27ae633a1857503ed8d091c7935d0d",
"version": "1.1.5"
}
},
{
"package": "JSONSchema",
"repositoryURL": "https://github.com/eu-digital-green-certificates/JSONSchema.swift",
Expand Down Expand Up @@ -63,15 +90,6 @@
"revision": "b76024995f6909e4615f943c7a03268fd29778fc",
"version": null
}
},
{
"package": "SwiftyJSON",
"repositoryURL": "https://github.com/SwiftyJSON/SwiftyJSON",
"state": {
"branch": null,
"revision": "b3dcd7dbd0d488e1a7077cb33b00f2083e382f07",
"version": "5.0.1"
}
}
]
},
Expand Down
93 changes: 93 additions & 0 deletions DGCAVerifier/Components/InfoCellDropDown.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*/
//
// InfoCellDropDown.swift
// DGCAVerifier
//
// Created by Alexandr Chernyy on 06.07.2021.
//
import UIKit
import SwiftDGC

typealias DropDownBlock = (Bool) -> Void

final class InfoCellDropDown: UITableViewCell {
private enum Constants {
static let iconCollapsed = "icon_collapsed"
static let iconExpanded = "icon_expanded"
}
@IBOutlet private weak var headerLabel: UILabel!
@IBOutlet private weak var contentLabel: UILabel!
@IBOutlet private weak var dropDownButton: UIButton!
private var dropDownBlock: DropDownBlock?
private var info: InfoSection = InfoSection(header: "", content: "") {
didSet {
setupView()
}
}

override func awakeFromNib() {
super.awakeFromNib()
clearView()
}
override func prepareForReuse() {
super.prepareForReuse()

clearView()
}
func setupCell(with info: InfoSection, dropDownBlock: @escaping DropDownBlock) {
self.info = info
self.dropDownBlock = dropDownBlock
}
private func setupView() {
setDropDownIcon()
headerLabel?.text = info.header
contentLabel?.text = info.content
let fontSize = contentLabel.font.pointSize
let fontWeight = contentLabel.font.weight
switch info.style {
case .fixedWidthFont:
if #available(iOS 13.0, *) {
contentLabel.font = .monospacedSystemFont(ofSize: fontSize, weight: fontWeight)
} else {
contentLabel.font = .monospacedDigitSystemFont(ofSize: fontSize, weight: fontWeight)
}
default:
contentLabel.font = .systemFont(ofSize: fontSize, weight: fontWeight)
}
}
private func clearView() {
headerLabel.text = ""
contentLabel.text = ""
}
@IBAction func dropDownUpAction(_ sender: Any) {
info.isExpanded = !info.isExpanded
setDropDownIcon()
dropDownBlock?(info.isExpanded)
}
private func setDropDownIcon() {
if !info.isExpanded {
dropDownButton.setImage(UIImage(named: Constants.iconCollapsed), for: .normal)
} else {
dropDownButton.setImage(UIImage(named: Constants.iconExpanded), for: .normal)
}
}
}
100 changes: 100 additions & 0 deletions DGCAVerifier/Components/RuleErrorTVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*/
//
// RuleErrorTVC.swift
// DGCAVerifier
//
// Created by Alexandr Chernyy on 05.07.2021.
//

import UIKit
import SwiftDGC

class RuleErrorTVC: UITableViewCell {

@IBOutlet weak var ruleLabel: UILabel!
@IBOutlet weak var ruleValueLabel: UILabel!
@IBOutlet weak var currentLabel: UILabel!
@IBOutlet weak var currentValueLabel: UILabel!
@IBOutlet weak var resultLabel: UILabel!
@IBOutlet weak var resultValueLabel: UILabel!
@IBOutlet weak var failedLabel: UILabel!
private var infoItem: InfoSection? {
didSet {
setupView()
}
}
override func awakeFromNib() {
super.awakeFromNib()
setLabels()
}

override func prepareForReuse() {
setLabels()
}
private func setLabels() {
ruleLabel.text = l10n("rule")
ruleValueLabel.text = ""
currentLabel.text = l10n("current")
currentValueLabel.text = ""
resultLabel.text = l10n("result")
resultValueLabel.text = ""
}
private func setupView() {
guard let infoItem = infoItem else { return }
ruleValueLabel.text = infoItem.header
currentValueLabel.text = infoItem.content
switch infoItem.ruleValidationResult {
case .error:
failedLabel.textColor = .red
failedLabel.text = l10n("failed")
case .passed:
failedLabel.textColor = .green
failedLabel.text = l10n("passed")
case .open:
failedLabel.textColor = .green
failedLabel.text = l10n("open")
}

if let countryName = infoItem.countryName {
switch infoItem.ruleValidationResult {
case .error:
resultValueLabel.text = String(format: l10n("failed_for_country"), countryName)
case .passed:
resultValueLabel.text = String(format: l10n("passed_for_country"), countryName)
case .open:
resultValueLabel.text = String(format: l10n("open_for_country"), countryName)
}
} else {
switch infoItem.ruleValidationResult {
case .error:
resultValueLabel.text = l10n("failed")
case .passed:
resultValueLabel.text = l10n("passed")
case .open:
resultValueLabel.text = l10n("open")
}
}
}
public func setupCell(with info: InfoSection) {
self.infoItem = info
}
}
Loading

0 comments on commit c29a0f2

Please sign in to comment.