2023-06-14 16:16:56 +02:00
|
|
|
import SwiftUI
|
|
|
|
|
2023-06-14 17:52:43 +02:00
|
|
|
private let df: DateFormatter = {
|
|
|
|
let df = DateFormatter()
|
|
|
|
df.dateStyle = .short
|
|
|
|
df.timeStyle = .medium
|
|
|
|
return df
|
|
|
|
}()
|
|
|
|
|
2023-06-14 16:16:56 +02:00
|
|
|
struct LogView: View {
|
|
|
|
|
|
|
|
@EnvironmentObject
|
|
|
|
var log: Log
|
|
|
|
|
2023-07-03 13:28:51 +02:00
|
|
|
@EnvironmentObject
|
|
|
|
var storage: PersistentStorage
|
|
|
|
|
2023-06-14 16:16:56 +02:00
|
|
|
var body: some View {
|
2023-07-02 17:29:39 +02:00
|
|
|
NavigationView {
|
2023-07-03 13:28:51 +02:00
|
|
|
List {
|
|
|
|
Text("\(storage.numberOfStoredDeviceInfos) device infos")
|
|
|
|
.font(.body)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
Text("\(storage.numberOfStoredTransfers) transfers")
|
|
|
|
.font(.body)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
ForEach(log.logEntries) { entry in
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
HStack {
|
|
|
|
Text(entry.level.description)
|
|
|
|
Spacer()
|
|
|
|
Text(df.string(from: entry.date))
|
|
|
|
}.font(.footnote)
|
|
|
|
Text(entry.message)
|
|
|
|
}
|
2023-07-02 17:29:39 +02:00
|
|
|
}
|
2023-06-14 16:16:56 +02:00
|
|
|
}
|
2023-07-02 17:29:39 +02:00
|
|
|
.navigationTitle("Log")
|
|
|
|
.navigationBarTitleDisplayMode(.large)
|
2023-06-14 16:16:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LogView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
LogView()
|
|
|
|
.environmentObject(Log())
|
|
|
|
}
|
|
|
|
}
|