Skip to content

Commit

Permalink
Merge branch '7.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Jul 16, 2024
2 parents 78fb06a + b70a0b4 commit cdd0098
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Wikipedia/Code/SinglePageWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SinglePageWebViewController: ViewController {
private lazy var webView: WKWebView = {
let webView = WKWebView(frame: UIScreen.main.bounds, configuration: webViewConfiguration)
webView.navigationDelegate = self
webView.uiDelegate = self
return webView
}()

Expand Down Expand Up @@ -274,3 +275,20 @@ extension SinglePageWebViewController: WKNavigationDelegate {
fakeProgressController.finish()
}
}

extension SinglePageWebViewController: WKUIDelegate {
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {

let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let action1 = UIAlertAction(title: CommonStrings.okTitle, style: .default) { _ in
completionHandler(true)
}
let action2 = UIAlertAction(title: CommonStrings.cancelActionTitle, style: .default) { _ in
completionHandler(false)
}
alertController.addAction(action1)
alertController.addAction(action2)

present(alertController, animated: true)
}
}

0 comments on commit cdd0098

Please sign in to comment.