-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceViewController.swift
More file actions
63 lines (43 loc) · 1.72 KB
/
DeviceViewController.swift
File metadata and controls
63 lines (43 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// DeviceControlView.swift
// Bourbon-iOS
//
// Created by Alyssa Torres on 3/13/17.
// Copyright © 2017 Ourglass. All rights reserved.
//
import UIKit
import PKHUD
class DeviceViewController: WebViewBaseViewController {
var ogDevice: OGDevice!
var appDisplayName: String?
var controlAppUrlString: String?
override func viewDidLoad() {
targetUrlString = self.ogDevice.getUrl()
super.viewDidLoad()
self.title = ogDevice.name
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.webView.alpha = 0
self.webView.reload();
}
// override func viewDidAppear(_ animated: Bool) {
// super.viewDidAppear(animated);
// self.webView.reload();
// }
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let rUrl = request.url?.absoluteString, let _ = rUrl.range(of: "app/control/index.html") {
// TODO: This "range" with just control is a hack for StreetFight...changing to redirect endpoint
//if let rUrl = request.url?.absoluteString, let _ = rUrl.range(of: "control") {
controlAppUrlString = rUrl
self.performSegue(withIdentifier: "toAppControl", sender: self)
return false
}
return true;
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toAppControl" && sender != nil {
(segue.destination as! WebViewBaseViewController).targetUrlString = controlAppUrlString
}
}
}