diff --git a/ios-pwa-wrapper/Base.lproj/Main.storyboard b/ios-pwa-wrapper/Base.lproj/Main.storyboard
index cd8c349..8ba463a 100644
--- a/ios-pwa-wrapper/Base.lproj/Main.storyboard
+++ b/ios-pwa-wrapper/Base.lproj/Main.storyboard
@@ -54,6 +54,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -61,14 +74,18 @@
+
+
+
+
@@ -85,6 +102,8 @@
+
+
@@ -95,7 +114,7 @@
-
+
diff --git a/ios-pwa-wrapper/Constants.swift b/ios-pwa-wrapper/Constants.swift
index e6cbc97..ed0957d 100644
--- a/ios-pwa-wrapper/Constants.swift
+++ b/ios-pwa-wrapper/Constants.swift
@@ -32,6 +32,7 @@ let navigationButtonColor = navigationTitleColor
let progressBarColor = getColorFromHex(hex: 0x4CAF50, alpha: 1.0)
let offlineIconColor = UIColor.darkGray
let buttonColor = navigationBarColor
+let activityIndicatorColor = navigationBarColor
// Color Helper function
func getColorFromHex(hex: UInt, alpha: CGFloat) -> UIColor {
diff --git a/ios-pwa-wrapper/ViewController.swift b/ios-pwa-wrapper/ViewController.swift
index 89510ab..5055010 100644
--- a/ios-pwa-wrapper/ViewController.swift
+++ b/ios-pwa-wrapper/ViewController.swift
@@ -18,6 +18,8 @@ class ViewController: UIViewController {
@IBOutlet weak var offlineView: UIView!
@IBOutlet weak var offlineIcon: UIImageView!
@IBOutlet weak var offlineButton: UIButton!
+ @IBOutlet weak var activityIndicatorView: UIView!
+ @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
// MARK: Globals
var webView: WKWebView!
@@ -56,12 +58,13 @@ class ViewController: UIViewController {
// Observers for updating UI
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
- /*
if (keyPath == #keyPath(WKWebView.isLoading)) {
- // does not fire for PWAs if links are clicked
- // leftButton.isEnabled = webView.canGoBack
+ // show activity indicator
+ if (webView.isLoading) {
+ activityIndicatorView.isHidden = false
+ activityIndicator.startAnimating()
+ }
}
- */
if (keyPath == #keyPath(WKWebView.estimatedProgress)) {
progressBar.progress = Float(webView.estimatedProgress)
rightButton.isEnabled = (webView.estimatedProgress == 1)
@@ -120,6 +123,10 @@ class ViewController: UIViewController {
progressBar.tintColor = progressBarColor
webView.addSubview(progressBar)
+ // activity indicator
+ activityIndicator.color = activityIndicatorColor
+ activityIndicator.startAnimating()
+
// offline container
offlineIcon.tintColor = offlineIconColor
offlineButton.tintColor = buttonColor
@@ -173,6 +180,9 @@ extension ViewController: WKNavigationDelegate {
}
// hide progress bar after initial load
progressBar.isHidden = true
+ // hide activity indicator
+ activityIndicatorView.isHidden = true
+ activityIndicator.stopAnimating()
}
// didFailProvisionalNavigation
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {