mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-05-12 00:05:17 +00:00
COVIDSafe code from version 2.4 (#45)
This commit is contained in:
parent
f14aa60482
commit
377bc0009b
63 changed files with 3096 additions and 372 deletions
54
CovidSafe/RestrictionDetailsViewController.swift
Normal file
54
CovidSafe/RestrictionDetailsViewController.swift
Normal 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
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue