Skip to content

Commit

Permalink
Fix warnings and linting. (eu-digital-green-certificates#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 31, 2021
1 parent fa73405 commit 64d7b1d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
1 change: 0 additions & 1 deletion DGCAVerifier/Components/LicenseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Paul Ballmann on 24.05.21.
//


import UIKit
import SwiftyJSON
Expand Down
2 changes: 1 addition & 1 deletion DGCAVerifier/Storyboards/Base.lproj/Settings.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="8lQ-1B-URM">
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="8lQ-1B-URM">
<rect key="frame" x="197" y="508" width="20" height="20"/>
</activityIndicatorView>
</subviews>
Expand Down
43 changes: 23 additions & 20 deletions DGCAVerifier/ViewControllers/LicenseVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Paul Ballmann on 24.05.21.
//


import Foundation
import UIKit
Expand All @@ -37,13 +36,13 @@ class LicenseTableVC: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.loadLicenses()
loadLicenses()
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.destination is LicenseVC {
if let destVC = segue.destination as? LicenseVC {
destVC.licenseObject = self.selectedLicense
destVC.licenseObject = selectedLicense
}
}
}
Expand All @@ -54,20 +53,20 @@ class LicenseTableVC: UITableViewController {
return UITableViewCell()
}
let index = indexPath.row
cell.drawLabel(self.licenses[index])
cell.drawLabel(licenses[index])
return cell
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? LicenseCell {
self.selectedLicense = cell.licenseObject
selectedLicense = cell.licenseObject
}
// segue to the vc
performSegue(withIdentifier: "licenseSegue", sender: nil)
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.licenses.count
return licenses.count
}

private func loadLicenses() {
Expand All @@ -81,13 +80,13 @@ class LicenseTableVC: UITableViewController {
return
}
let jsonDoc = try JSON(data: jsonData)
self.licenses = jsonDoc["licenses"].array ?? []
licenses = jsonDoc["licenses"].array ?? []
} catch {
print(error)
return
}

print(self.licenses)
print(licenses)
}
}

Expand All @@ -96,36 +95,40 @@ class LicenseVC: UIViewController, WKNavigationDelegate {
@IBOutlet weak var licenseWebView: WKWebView!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!


var licenseObject: JSON = []

override func viewDidLoad() {
super.viewDidLoad()

self.packageNameLabel.text = licenseObject["name"].string
self.licenseWebView.isUserInteractionEnabled = false
self.licenseWebView.navigationDelegate = self

packageNameLabel.text = licenseObject["name"].string
licenseWebView.isUserInteractionEnabled = false
licenseWebView.navigationDelegate = self
if #available(iOS 13.0, *) {
activityIndicator.style = .medium
} else {
activityIndicator.style = .gray
}

if let licenseUrl = licenseObject["licenseUrl"].string {
loadWebView(licenseUrl)
}
}

func loadWebView(_ packageLink: String) {
DispatchQueue.main.async {
let request = URLRequest(url: URL(string: packageLink)!)
self.licenseWebView?.load(request)
DispatchQueue.main.async { [weak self] in
let request = URLRequest(url: URL(string: packageLink)!)
self?.licenseWebView?.load(request)
}

self.activityIndicator.startAnimating()
self.licenseWebView.navigationDelegate = self
activityIndicator.startAnimating()
licenseWebView.navigationDelegate = self
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.activityIndicator.stopAnimating()
activityIndicator.stopAnimating()
}

func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
self.activityIndicator.stopAnimating()
activityIndicator.stopAnimating()
}
}

0 comments on commit 64d7b1d

Please sign in to comment.