Manos Chorianopoulos

add webviewDidFocus at CampaignViewController

...@@ -29,6 +29,8 @@ var timer2: DispatchSourceTimer? ...@@ -29,6 +29,8 @@ var timer2: DispatchSourceTimer?
29 var locationManager: CLLocationManager! 29 var locationManager: CLLocationManager!
30 var listenersCount = 0; 30 var listenersCount = 0;
31 31
32 + var webViewLoaded: Bool = false
33 +
32 public override func loadView() { 34 public override func loadView() {
33 super.loadView(); 35 super.loadView();
34 36
...@@ -85,6 +87,18 @@ var timer2: DispatchSourceTimer? ...@@ -85,6 +87,18 @@ var timer2: DispatchSourceTimer?
85 } else { 87 } else {
86 self.navigationController?.hideHairline() 88 self.navigationController?.hideHairline()
87 } 89 }
90 +
91 + if(webViewLoaded) {
92 +
93 + let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded));"
94 +
95 + webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
96 +// print("==== object viewWillAppear ====")
97 +// print(object)
98 +// print("==== error viewWillAppear ====")
99 +// print(error)
100 + })
101 + }
88 } 102 }
89 103
90 public override func viewWillDisappear(_ animated: Bool) { 104 public override func viewWillDisappear(_ animated: Bool) {
...@@ -158,10 +172,10 @@ var timer2: DispatchSourceTimer? ...@@ -158,10 +172,10 @@ var timer2: DispatchSourceTimer?
158 let scriptSource = "passMeters(\(metersParam));" 172 let scriptSource = "passMeters(\(metersParam));"
159 173
160 self?.webview.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in 174 self?.webview.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in
161 - // print("==== object ====") 175 +// print("==== object passMeters ====")
162 - // print(object) 176 +// print(object)
163 - // print("==== error ====") 177 +// print("==== error passMeters ====")
164 - // print(error) 178 +// print(error)
165 179
166 swiftApi().setSavedStepsWebview(swiftApi().getSavedStepsWebview() + swiftApi().getStepsWebview()) 180 swiftApi().setSavedStepsWebview(swiftApi().getSavedStepsWebview() + swiftApi().getStepsWebview())
167 swiftApi().setStepsWebview(0) 181 swiftApi().setStepsWebview(0)
...@@ -336,6 +350,7 @@ var timer2: DispatchSourceTimer? ...@@ -336,6 +350,7 @@ var timer2: DispatchSourceTimer?
336 350
337 // MARK: - WKNavigationDelegate 351 // MARK: - WKNavigationDelegate
338 public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { 352 public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
353 + self.webViewLoaded = true
339 354
340 let scriptSource = "passParams(\(params));" 355 let scriptSource = "passParams(\(params));"
341 356
...@@ -350,6 +365,14 @@ var timer2: DispatchSourceTimer? ...@@ -350,6 +365,14 @@ var timer2: DispatchSourceTimer?
350 } 365 }
351 }) 366 })
352 367
368 + let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded));"
369 +
370 + webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
371 +// print("==== object webView ====")
372 +// print(object)
373 +// print("==== error webView ====")
374 +// print(error)
375 + })
353 } 376 }
354 377
355 public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { 378 public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
......