forked from ameriod/ForestKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppMainView.swift
71 lines (64 loc) · 2.09 KB
/
AppMainView.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
65
66
67
68
69
70
71
import ForestKitView
import SwiftUI
@main
struct AppMainView: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
.navigationBarTitle(Text("ForestKit Sample"), displayMode: .inline)
}
}
}
}
struct ContentView: View {
@State var message: String = ""
@State var errorMessage: String = ""
var body: some View {
VStack {
Group {
TextField("Log Message", text: $message)
TextField("Error message, empty for no error", text: $errorMessage)
Button("Log \(ForestKitLogging.Priority.default.rawValue)") {
Forest.log(error, message)
}
Button("Log \(ForestKitLogging.Priority.info.rawValue)") {
Forest.i(error, message)
}
Button("Log \(ForestKitLogging.Priority.debug.rawValue)") {
Forest.d(error, message)
}
Button("Log \(ForestKitLogging.Priority.error.rawValue)") {
Forest.e(error, message)
}
Button("Log \(ForestKitLogging.Priority.fault.rawValue)") {
Forest.f(error, message)
}
Button("Log \(ForestKitLogging.Priority.wtf.rawValue)") {
Forest.wtf(error, message)
}
}
Spacer()
Button(action: { }, label: {
NavigationLink(destination: fileTreeOutputView()) {
Text("FileOutputTree View")
}
})
}
.padding()
}
var error: Error? {
if errorMessage.isEmpty {
return nil
}
return TestError.runtimeError(errorMessage)
}
func fileTreeOutputView() -> some View {
ForestKitView.LogViewer()
.navigationBarTitle(Text("FileOutputTree"), displayMode: .inline)
}
}
enum TestError: Error {
case runtimeError(String)
}