COVIDSafe code from version 2.4 ()

This commit is contained in:
COVIDSafe Support 2021-02-25 19:41:20 -08:00 committed by GitHub
parent f14aa60482
commit 377bc0009b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 3096 additions and 372 deletions

View file

@ -0,0 +1,54 @@
//
// RestrictionDetailsViewController.swift
// CovidSafe
//
// Copyright © 2021 Australian Government. All rights reserved.
//
import UIKit
import SafariServices
class RestrictionDetailsViewController: CovidHeaderContentViewController {
var htmlString: String?
var hasLoadedInitialContent = false
override func viewDidLoad() {
super.viewDidLoad()
guard let restrictionsDetailsView = Bundle.main.loadNibNamed("WebContentView", owner: self, options: nil)?.first as? WebContentView else {
return
}
restrictionsDetailsView.webContentView.delegate = self
guard let htmlString = self.htmlString else { return }
restrictionsDetailsView.webContentView.loadHTMLString(htmlString.htmlDocumentString(font: UIFont.preferredFont(forTextStyle: .body), withAdditionalCSS: "a{color:\(UIColor.covidSafeButtonDarkerColor.hexString)}"), baseURL: nil)
setupContentView(contentView: restrictionsDetailsView)
}
}
extension RestrictionDetailsViewController: UIWebViewDelegate {
func webViewDidFinishLoad(_ webView: UIWebView) {
hasLoadedInitialContent = true
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
if !hasLoadedInitialContent {
return true
}
guard let urlToLoad = request.url else {
return false
}
let safariVC = SFSafariViewController(url: urlToLoad)
present(safariVC, animated: true, completion: nil)
return false
}
}