Skip to content

Commit

Permalink
Example project tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fdocr committed Nov 5, 2020
1 parent 9f0275e commit c390115
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ class ViewController: UIViewController {
webView.foremWebViewDelegate = self
webView.load("https://dev.to")
activityIndicator.startAnimating()

// Observations need to be retained in order for them to work
observations = [
webView.observe(\ForemWebView.userData, options: .new, changeHandler: { (webView, _) in
webView.observe(\ForemWebView.userData, options: .new) { (webView, _) in
if let userData = webView.userData {
print("UserID [config_body_class]: \(userData.userID) [\(userData.configBodyClass)]")
} else {
print("User Logged out")
}
}),
webView.observe(\ForemWebView.estimatedProgress, options: .new, changeHandler: { (webView, _) in
},
webView.observe(\ForemWebView.estimatedProgress, options: .new) { (webView, _) in
self.progressView.progress = Float(webView.estimatedProgress)
})
}
]
}
}
Expand All @@ -41,23 +43,25 @@ extension ViewController: ForemWebViewDelegate {
}

func requestedExternalSite(url: URL) {
print("This was the external site requested: \(url.absoluteString)")
// You can open a custom WKWebView for external sites, present SFSafariViewController, etc.
print("This was the external site requested: \(url.absoluteString)")
}

func requestedMailto(url: URL) {
if UIApplication.shared.canOpenURL(url) {
// Should open the default Mail app
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}

func didStartNavigation() {
activityIndicator.isHidden = false
progressView.progress = 0
progressView.isHidden = false
}

func didFinishNavigation() {
activityIndicator.isHidden = true
progressView.progress = 0
progressView.isHidden = true
}
}

0 comments on commit c390115

Please sign in to comment.