Skip to content

Commit

Permalink
Add webView
Browse files Browse the repository at this point in the history
  • Loading branch information
VictoriaKostyleva committed Oct 12, 2022
1 parent 62a988b commit 9e24eb4
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,36 @@
//

import UIKit
import WebKit

class ViewController: UIViewController {
let server = DVPNServer(context: ContextBuilder().buildContext())
final class ViewController: UIViewController {
private let server = DVPNServer(context: ContextBuilder().buildContext())
private var webView: WKWebView!

override func viewDidLoad() {
super.viewDidLoad()

server.start()
setUpWebView()
}
}

// MARK: Private

extension ViewController {
private func setUpWebView() {
let webConfiguration = WKWebViewConfiguration()

webConfiguration.setValue(true, forKey: "_allowUniversalAccessFromFileURLs")

webView = WKWebView(frame: .zero, configuration: webConfiguration)
view = webView

guard let path = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "dist") else {
log.error("Fail to load UI from resources")
return
}

webView.loadFileURL(path, allowingReadAccessTo: path)
}
}

0 comments on commit 9e24eb4

Please sign in to comment.