Manos Chorianopoulos

add webviewDidFocus at CampaignViewController

......@@ -28,6 +28,8 @@ var timer2: DispatchSourceTimer?
var webView: WKWebView!
var locationManager: CLLocationManager!
var listenersCount = 0;
var webViewLoaded: Bool = false
public override func loadView() {
super.loadView();
......@@ -85,6 +87,18 @@ var timer2: DispatchSourceTimer?
} else {
self.navigationController?.hideHairline()
}
if(webViewLoaded) {
let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded));"
webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
// print("==== object viewWillAppear ====")
// print(object)
// print("==== error viewWillAppear ====")
// print(error)
})
}
}
public override func viewWillDisappear(_ animated: Bool) {
......@@ -158,10 +172,10 @@ var timer2: DispatchSourceTimer?
let scriptSource = "passMeters(\(metersParam));"
self?.webview.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in
// print("==== object ====")
// print(object)
// print("==== error ====")
// print(error)
// print("==== object passMeters ====")
// print(object)
// print("==== error passMeters ====")
// print(error)
swiftApi().setSavedStepsWebview(swiftApi().getSavedStepsWebview() + swiftApi().getStepsWebview())
swiftApi().setStepsWebview(0)
......@@ -336,6 +350,7 @@ var timer2: DispatchSourceTimer?
// MARK: - WKNavigationDelegate
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.webViewLoaded = true
let scriptSource = "passParams(\(params));"
......@@ -349,7 +364,15 @@ var timer2: DispatchSourceTimer?
self.startTimer()
}
})
let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded));"
webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
// print("==== object webView ====")
// print(object)
// print("==== error webView ====")
// print(error)
})
}
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
......