Skip to content

Commit

Permalink
Merge pull request #82 from AppSci/release/1.0.14
Browse files Browse the repository at this point in the history
feature/WBIOS-2972 Add custom font access to WebViewController
  • Loading branch information
nick-softwaredev authored Apr 20, 2023
2 parents 8b0818d + 428b41c commit f80256a
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions Sources/PandaSDK/Views/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ final class WebViewController: UIViewController, WKScriptMessageHandler {
var onPurchaseCmpld: (() -> Void)?
var isAutoDismissable: Bool = true

var url: URLComponents?

private lazy var wv: WKWebView = {
let config = getWKWebViewConfiguration()
let wv = WKWebView(frame: view.bounds, configuration: config)
Expand Down Expand Up @@ -83,17 +81,8 @@ final class WebViewController: UIViewController, WKScriptMessageHandler {
_ = view // trigger viewdidload
wv.alpha = 0


if let html = html {
load(html: html, baseURL: url?.url)
return
}
guard let url = url?.url else { return }

if url.isFileURL {
load(local: url)
} else {
load(url: url)
load(html: html, baseURL: URL(fileURLWithPath: Bundle.main.bundlePath))
}
}

Expand All @@ -104,21 +93,12 @@ final class WebViewController: UIViewController, WKScriptMessageHandler {
}
}

private func load(url: URL) {
wv.load(URLRequest(url: url))
}

private func load(html: String, baseURL: URL?) {
let html = replaceProductInfo(html: html)

wv.loadHTMLString(html, baseURL: baseURL)
}

private func load(local url: URL) {
wv.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
wv.loadFileURL(url, allowingReadAccessTo: url)
}

deinit {
onFinishLoad()
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(failedByTimeOut), object: nil)
Expand Down

0 comments on commit f80256a

Please sign in to comment.