|
@@ -10,7 +10,7 @@ import WebKit
|
|
|
import NexilisLite
|
|
|
import Speech
|
|
|
|
|
|
-class FirstTabViewController: UIViewController, WKUIDelegate, UIScrollViewDelegate, UIGestureRecognizerDelegate, WKScriptMessageHandler {
|
|
|
+class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate, WKScriptMessageHandler {
|
|
|
|
|
|
@IBOutlet weak var webView: WKWebView!
|
|
|
var address = ""
|
|
@@ -42,6 +42,7 @@ class FirstTabViewController: UIViewController, WKUIDelegate, UIScrollViewDelega
|
|
|
refreshControl.addTarget(self, action: #selector(reloadWebView(_:)), for: .valueChanged)
|
|
|
webView.scrollView.addSubview(refreshControl)
|
|
|
webView.scrollView.delegate = self
|
|
|
+ webView.navigationDelegate = self
|
|
|
webView.allowsBackForwardNavigationGestures = true
|
|
|
|
|
|
let contentController = self.webView.configuration.userContentController
|
|
@@ -51,6 +52,7 @@ class FirstTabViewController: UIViewController, WKUIDelegate, UIScrollViewDelega
|
|
|
contentController.add(self, name: "blockUser")
|
|
|
contentController.add(self, name: "showAlert")
|
|
|
contentController.add(self, name: "closeProfile")
|
|
|
+ contentController.add(self, name: "tabShowHide")
|
|
|
|
|
|
let source: String = "var meta = document.createElement('meta');" +
|
|
|
"meta.name = 'viewport';" +
|
|
@@ -294,6 +296,18 @@ class FirstTabViewController: UIViewController, WKUIDelegate, UIScrollViewDelega
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else if message.name == "tabShowHide" {
|
|
|
+ guard let dict = message.body as? [String: AnyObject],
|
|
|
+ let param1 = dict["param1"] as? Bool else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if param1 {
|
|
|
+ ViewController.alwaysHideButton = false
|
|
|
+ showTabBar()
|
|
|
+ } else {
|
|
|
+ ViewController.alwaysHideButton = true
|
|
|
+ hideTabBar()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -425,3 +439,17 @@ extension FirstTabViewController: SFSpeechRecognizerDelegate {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension FirstTabViewController: WKUIDelegate, WKNavigationDelegate {
|
|
|
+ func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
|
|
+ if let urlStr = navigationAction.request.url?.absoluteString {
|
|
|
+ collapseDocked()
|
|
|
+ if urlStr.contains("nexilis/pages/tab1-main-only") || urlStr.contains("nexilis/pages/tab3-main-only") || urlStr.contains("nexilis/pages/tab1-main") || urlStr.contains("nexilis/pages/tab3-commerce") {
|
|
|
+ ViewController.alwaysHideButton = false
|
|
|
+ showTabBar()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ decisionHandler(.allow)
|
|
|
+ }
|
|
|
+}
|