-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentView.swift
64 lines (56 loc) · 2.01 KB
/
ContentView.swift
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
64
import SwiftUI
let defaultUserUrl = "<user url>"
struct ContentView: View {
@State private var inputText: String = ""
@State var activeWebView = false
var body: some View {
ZStack {
Color(UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.0)).edgesIgnoringSafeArea(.all)
VStack(alignment: .center, spacing: 20) {
Text("CT iOS Tester")
.foregroundColor(.white)
.font(.title)
// Single-line text input
TextField("Paste Column Tax URL here", text: $inputText)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()
Button(action: {
self.activeWebView = true
}) {
Text("Open Column")
.foregroundColor(.white)
.font(.title)
.padding()
.border(Color(.white), width: 5)
}.sheet(isPresented: $activeWebView, content: {
ColumnModuleView(
urlRequest: URLRequest(url: URL(string: getUrlText())!),
isPresented: self.$activeWebView,
moduleEventController: ColumnMessageHandler(eventHandler: self.eventHandler)).edgesIgnoringSafeArea(.all)
})
}
}
}
func getUrlText() -> String {
if (self.inputText.isEmpty) {
return defaultUserUrl;
} else {
return self.inputText;
}
}
func eventHandler(_ event: String, payload: NSDictionary) {
switch event {
case "column-on-close":
activeWebView = false
case "column-on-user-event":
print("Received user event: '\(event)'")
default:
print("Unrecognized event: '\(event)'")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}